Search in sources :

Example 1 with NullAuthoritiesMapper

use of org.springframework.security.core.authority.mapping.NullAuthoritiesMapper in project spring-security by spring-projects.

the class OpenIDAuthenticationProviderTests method testAuthenticateCancel.

// ~ Methods
// ========================================================================================================
/*
	 * Test method for
	 * 'org.springframework.security.authentication.openid.OpenIDAuthenticationProvider.
	 * authenticate(Authentication)'
	 */
@Test
public void testAuthenticateCancel() {
    OpenIDAuthenticationProvider provider = new OpenIDAuthenticationProvider();
    provider.setUserDetailsService(new MockUserDetailsService());
    provider.setAuthoritiesMapper(new NullAuthoritiesMapper());
    Authentication preAuth = new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.CANCELLED, USERNAME, "", null);
    assertThat(preAuth.isAuthenticated()).isFalse();
    try {
        provider.authenticate(preAuth);
        fail("Should throw an AuthenticationException");
    } catch (AuthenticationCancelledException expected) {
        assertThat(expected.getMessage()).isEqualTo("Log in cancelled");
    }
}
Also used : Authentication(org.springframework.security.core.Authentication) NullAuthoritiesMapper(org.springframework.security.core.authority.mapping.NullAuthoritiesMapper) Test(org.junit.Test)

Example 2 with NullAuthoritiesMapper

use of org.springframework.security.core.authority.mapping.NullAuthoritiesMapper in project service-authorization by reportportal.

the class ActiveDirectoryAuthProvider method getDelegate.

@Override
protected AuthenticationProvider getDelegate() {
    ActiveDirectoryConfig adConfig = authConfigRepository.findActiveDirectory(true).orElseThrow(() -> new BadCredentialsException("Active Directory is not configured"));
    ActiveDirectoryLdapAuthenticationProvider adAuth = new ActiveDirectoryLdapAuthenticationProvider(adConfig.getDomain(), adConfig.getUrl(), adConfig.getBaseDn());
    adAuth.setAuthoritiesMapper(new NullAuthoritiesMapper());
    adAuth.setUserDetailsContextMapper(new DetailsContextMapper(ldapUserReplicator, adConfig.getSynchronizationAttributes()));
    return adAuth;
}
Also used : ActiveDirectoryConfig(com.epam.reportportal.auth.store.entity.ldap.ActiveDirectoryConfig) ActiveDirectoryLdapAuthenticationProvider(org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider) BadCredentialsException(org.springframework.security.authentication.BadCredentialsException) NullAuthoritiesMapper(org.springframework.security.core.authority.mapping.NullAuthoritiesMapper)

Example 3 with NullAuthoritiesMapper

use of org.springframework.security.core.authority.mapping.NullAuthoritiesMapper in project spring-security by spring-projects.

the class LdapAuthenticationProviderConfigurerTest method getAuthoritiesMapper.

// SEC-2557
@Test
public void getAuthoritiesMapper() throws Exception {
    assertThat(configurer.getAuthoritiesMapper()).isInstanceOf(SimpleAuthorityMapper.class);
    configurer.authoritiesMapper(new NullAuthoritiesMapper());
    assertThat(configurer.getAuthoritiesMapper()).isInstanceOf(NullAuthoritiesMapper.class);
}
Also used : NullAuthoritiesMapper(org.springframework.security.core.authority.mapping.NullAuthoritiesMapper) Test(org.junit.Test)

Aggregations

NullAuthoritiesMapper (org.springframework.security.core.authority.mapping.NullAuthoritiesMapper)3 Test (org.junit.Test)2 ActiveDirectoryConfig (com.epam.reportportal.auth.store.entity.ldap.ActiveDirectoryConfig)1 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)1 Authentication (org.springframework.security.core.Authentication)1 ActiveDirectoryLdapAuthenticationProvider (org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider)1