Java 类org.springframework.security.core.authority.mapping.SimpleAuthorityMapper 实例源码

项目:gravitee-management-rest-api    文件:LdapAuthenticationProviderConfigurer.java   
private LdapAuthenticationProvider build() throws Exception {
    BaseLdapPathContextSource contextSource = getContextSource();
    LdapAuthenticator ldapAuthenticator = createLdapAuthenticator(contextSource);

    LdapAuthoritiesPopulator authoritiesPopulator = getLdapAuthoritiesPopulator();

    LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProviderProxy(
            ldapAuthenticator, authoritiesPopulator);
    SimpleAuthorityMapper simpleAuthorityMapper = new SimpleAuthorityMapper();
    simpleAuthorityMapper.setPrefix(rolePrefix);
    simpleAuthorityMapper.afterPropertiesSet();
    ldapAuthenticationProvider.setAuthoritiesMapper(simpleAuthorityMapper);
    if (userDetailsContextMapper != null) {
        ldapAuthenticationProvider
                .setUserDetailsContextMapper(userDetailsContextMapper);
    }
    return ldapAuthenticationProvider;
}
项目:keycloak_training    文件:SecurityConfig.java   
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
    KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
    SimpleAuthorityMapper grantedAuthorityMapper = new SimpleAuthorityMapper();
    grantedAuthorityMapper.setPrefix("ROLE_");
    grantedAuthorityMapper.setConvertToUpperCase(true);
    keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(grantedAuthorityMapper);
    auth.authenticationProvider(keycloakAuthenticationProvider);
}
项目:smartling-keycloak-extras    文件:KeycloakSpringAdapterUtilsTest.java   
@Before
public void setUp() throws Exception {

    MockitoAnnotations.initMocks(this);
    SimpleAuthorityMapper roleMapper = new SimpleAuthorityMapper();
    roleMapper.setConvertToUpperCase(true);
    grantedAuthoritiesMapper = roleMapper;

    PowerMockito.mockStatic(AdapterUtils.class);
    when(AdapterUtils.getRolesFromSecurityContext(any(RefreshableKeycloakSecurityContext.class))).thenReturn(AUTHORITIES);
    when(AdapterUtils.createPrincipal(eq(deployment), eq(context))).thenReturn(principal);
}