mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-679: Corrected regular expression matching logic in DefaultRemoteUserMapper
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19986 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -207,6 +207,10 @@ public class DefaultRemoteUserMapper implements RemoteUserMapper, ActivateableBe
|
|||||||
{
|
{
|
||||||
userId = matcher.group(1).trim();
|
userId = matcher.group(1).trim();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return userId.length() == 0 ? null : userId;
|
return userId.length() == 0 ? null : userId;
|
||||||
}
|
}
|
||||||
|
@@ -115,11 +115,15 @@ public class DefaultRemoteUserMapperTest extends AbstractChainedSubsystemTest
|
|||||||
assertEquals("admin", ((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean(
|
assertEquals("admin", ((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean(
|
||||||
"remoteUserMapper")).getRemoteUser(mockRequest));
|
"remoteUserMapper")).getRemoteUser(mockRequest));
|
||||||
|
|
||||||
|
// Try a request with an invalid match
|
||||||
|
when(mockRequest.getHeader("X-Alfresco-Remote-User")).thenReturn("abc-AdMiN-998");
|
||||||
|
assertNull(((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean(
|
||||||
|
"remoteUserMapper")).getRemoteUser(mockRequest));
|
||||||
|
|
||||||
// Try a request without the remote user
|
// Try a request without the remote user
|
||||||
when(mockRequest.getRemoteUser()).thenReturn(null);
|
when(mockRequest.getRemoteUser()).thenReturn(null);
|
||||||
assertNull(((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean(
|
assertNull(((RemoteUserMapper) childApplicationContextFactory.getApplicationContext().getBean(
|
||||||
"remoteUserMapper")).getRemoteUser(mockRequest));
|
"remoteUserMapper")).getRemoteUser(mockRequest));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user