List of usage examples for org.springframework.security.core.authority.mapping SimpleAuthorityMapper SimpleAuthorityMapper
SimpleAuthorityMapper
From source file:org.keycloak.adapters.springsecurity.support.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);//from www . j a va2s. com when(AdapterUtils.createPrincipal(eq(deployment), eq(context))).thenReturn(principal); }
From source file:io.gravitee.management.idp.ldap.authentication.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); }//from ww w .j a v a2s . co m return ldapAuthenticationProvider; }