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");
}
}
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;
}
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);
}
Aggregations