use of org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper in project spring-security by spring-projects.
the class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSourceTests method getJ2eeUserRoles2GrantedAuthoritiesMapper.
private Attributes2GrantedAuthoritiesMapper getJ2eeUserRoles2GrantedAuthoritiesMapper() {
SimpleAttributes2GrantedAuthoritiesMapper result = new SimpleAttributes2GrantedAuthoritiesMapper();
result.setAddPrefixIfAlreadyExisting(false);
result.setConvertAttributeToLowerCase(false);
result.setConvertAttributeToUpperCase(false);
result.setAttributePrefix("");
return result;
}
use of org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper in project spring-security by spring-projects.
the class WebSpherePreAuthenticatedProcessingFilterTests method principalsAndCredentialsAreExtractedCorrectly.
@Test
public void principalsAndCredentialsAreExtractedCorrectly() throws Exception {
new WebSpherePreAuthenticatedProcessingFilter();
WASUsernameAndGroupsExtractor helper = mock(WASUsernameAndGroupsExtractor.class);
when(helper.getCurrentUserName()).thenReturn("jerry");
WebSpherePreAuthenticatedProcessingFilter filter = new WebSpherePreAuthenticatedProcessingFilter(helper);
assertThat(filter.getPreAuthenticatedPrincipal(new MockHttpServletRequest())).isEqualTo("jerry");
assertThat(filter.getPreAuthenticatedCredentials(new MockHttpServletRequest())).isEqualTo("N/A");
AuthenticationManager am = mock(AuthenticationManager.class);
when(am.authenticate(any(Authentication.class))).thenAnswer(new Answer<Authentication>() {
public Authentication answer(InvocationOnMock invocation) throws Throwable {
return (Authentication) invocation.getArguments()[0];
}
});
filter.setAuthenticationManager(am);
WebSpherePreAuthenticatedWebAuthenticationDetailsSource ads = new WebSpherePreAuthenticatedWebAuthenticationDetailsSource(helper);
ads.setWebSphereGroups2GrantedAuthoritiesMapper(new SimpleAttributes2GrantedAuthoritiesMapper());
filter.setAuthenticationDetailsSource(ads);
filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), mock(FilterChain.class));
}
Aggregations