org.springframework.security.saml.SAMLAuthenticationProvider Java Examples

The following examples show how to use org.springframework.security.saml.SAMLAuthenticationProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthenticationProviderConfigurerTest.java    From spring-boot-security-saml with MIT License 6 votes vote down vote up
@Test
public void testArguments() throws Exception {
    AuthenticationProviderConfigurer configurer = new AuthenticationProviderConfigurer();
    configurer
            .excludeCredential(true)
            .forcePrincipalAsString(false);
    configurer.init(builder);
    configurer.configure(builder);
    ArgumentCaptor<SAMLAuthenticationProvider> providerCaptor = ArgumentCaptor.forClass(SAMLAuthenticationProvider.class);
    verify(builder).setSharedObject(eq(SAMLAuthenticationProvider.class), providerCaptor.capture());
    verifyZeroInteractions(authProviderProperties);
    assertThat(providerCaptor.getValue()).isNotNull();
    SAMLAuthenticationProvider authenticationProvider = providerCaptor.getValue();
    assertThat(authenticationProvider.isExcludeCredential()).isTrue();
    assertThat(authenticationProvider.isForcePrincipalAsString()).isFalse();
    assertThat(authenticationProvider.getUserDetails()).isExactlyInstanceOf(SimpleSAMLUserDetailsService.class);
}
 
Example #2
Source File: SAMLServiceProviderSecurityConfiguration.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
    //All existing beans are thrown as shared objects to the ServiceProviderSecurityBuilder, which will wire all
    //beans/objects related to spring security SAML.
    serviceProviderBuilder.setSharedObject(ParserPool.class, ParserPoolHolder.getPool());
    serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerImpl.class, (WebSSOProfileConsumerImpl) webSSOProfileConsumer);
    serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerHoKImpl.class, hokWebSSOProfileConsumer);
    serviceProviderBuilder.setSharedObject(ServiceProviderEndpoints.class, new ServiceProviderEndpoints());
    serviceProviderBuilder.setSharedObject(ResourceLoader.class, resourceLoader);
    serviceProviderBuilder.setSharedObject(SAMLSSOProperties.class, sAMLSsoProperties);
    serviceProviderBuilder.setSharedObject(ExtendedMetadata.class, extendedMetadata);
    serviceProviderBuilder.setSharedObject(LocalExtendedMetadata.class, localExtendedMetadata);
    serviceProviderBuilder.setSharedObject(SAMLAuthenticationProvider.class, samlAuthenticationProvider);
    serviceProviderBuilder.setSharedObject(SAMLContextProvider.class, samlContextProvider);
    serviceProviderBuilder.setSharedObject(KeyManager.class, keyManager);
    serviceProviderBuilder.setSharedObject(MetadataManager.class, metadataManager);
    serviceProviderBuilder.setSharedObject(MetadataGenerator.class, metadataGenerator);
    serviceProviderBuilder.setSharedObject(SAMLProcessor.class, samlProcessor);
    serviceProviderBuilder.setSharedObject(WebSSOProfile.class, webSSOProfile);
    serviceProviderBuilder.setSharedObject(WebSSOProfileECPImpl.class, ecpProfile);
    serviceProviderBuilder.setSharedObject(WebSSOProfileHoKImpl.class, hokWebSSOProfile);
    serviceProviderBuilder.setSharedObject(SingleLogoutProfile.class, sloProfile);
    serviceProviderBuilder.setSharedObject(WebSSOProfileConsumer.class, webSSOProfileConsumer);
    serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerHoKImpl.class, hokWebSSOProfileConsumer);
    serviceProviderBuilder.setSharedObject(SAMLLogger.class, samlLogger);
    serviceProviderBuilder.setSharedObject(ApplicationEventPublisher.class, eventPublisher);
}
 
Example #3
Source File: AuthenticationProviderConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Before
public void setup() {
    SAMLSSOProperties properties = mock(SAMLSSOProperties.class);
    authProviderProperties = mock(AuthenticationProviderProperties.class);
    when(properties.getAuthenticationProvider()).thenReturn(authProviderProperties);
    when(authProviderProperties.isExcludeCredential()).thenReturn(false);
    when(authProviderProperties.isForcePrincipalAsString()).thenReturn(false);
    builder = mock(ServiceProviderBuilder.class);
    when(builder.getSharedObject(SAMLAuthenticationProvider.class)).thenReturn(null);
    when(builder.getSharedObject(SAMLSSOProperties.class)).thenReturn(properties);
}
 
Example #4
Source File: AuthenticationProviderConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void init() throws Exception {
    AuthenticationProviderConfigurer configurer = new AuthenticationProviderConfigurer();
    configurer.init(builder);
    verify(builder).getSharedObject(eq(SAMLAuthenticationProvider.class));
    verify(builder).getSharedObject(eq(SAMLSSOProperties.class));
}
 
Example #5
Source File: AuthenticationProviderConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void configure() throws Exception {
    AuthenticationProviderConfigurer configurer = new AuthenticationProviderConfigurer();
    configurer.init(builder);
    configurer.configure(builder);
    verify(builder).setSharedObject(eq(SAMLAuthenticationProvider.class), any(SAMLAuthenticationProvider.class));
}
 
Example #6
Source File: AuthenticationProviderConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void configure_forBean() throws Exception {
    SAMLAuthenticationProvider samlAuthenticationProvider = mock(SAMLAuthenticationProvider.class);
    when(builder.getSharedObject(SAMLAuthenticationProvider.class)).thenReturn(samlAuthenticationProvider);
    AuthenticationProviderConfigurer configurer = new AuthenticationProviderConfigurer();
    configurer.init(builder);
    configurer.configure(builder);
    verify(builder, never()).setSharedObject(any(), any());
    verifyZeroInteractions(samlAuthenticationProvider, authProviderProperties);
}
 
Example #7
Source File: AuthenticationProviderConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void configure_forConstructor() throws Exception {
    SAMLAuthenticationProvider samlAuthenticationProvider = mock(SAMLAuthenticationProvider.class);
    AuthenticationProviderConfigurer configurer = new AuthenticationProviderConfigurer(samlAuthenticationProvider);
    configurer.init(builder);
    configurer.configure(builder);
    verify(builder).setSharedObject(eq(SAMLAuthenticationProvider.class), eq(samlAuthenticationProvider));
    verifyZeroInteractions(samlAuthenticationProvider, authProviderProperties);
}
 
Example #8
Source File: AuthenticationProviderConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void testProperties() throws Exception {
    AuthenticationProviderConfigurer configurer = new AuthenticationProviderConfigurer();
    configurer.init(builder);
    configurer.configure(builder);
    ArgumentCaptor<SAMLAuthenticationProvider> providerCaptor = ArgumentCaptor.forClass(SAMLAuthenticationProvider.class);
    verify(builder).setSharedObject(eq(SAMLAuthenticationProvider.class), providerCaptor.capture());
    verify(authProviderProperties).isExcludeCredential();
    verify(authProviderProperties).isForcePrincipalAsString();
    assertThat(providerCaptor.getValue()).isNotNull();
    SAMLAuthenticationProvider authenticationProvider = providerCaptor.getValue();
    assertThat(authenticationProvider.isExcludeCredential()).isFalse();
    assertThat(authenticationProvider.isForcePrincipalAsString()).isFalse();
    assertThat(authenticationProvider.getUserDetails()).isExactlyInstanceOf(SimpleSAMLUserDetailsService.class);
}
 
Example #9
Source File: AuthenticationProviderConfigurer.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
@Override
public void init(ServiceProviderBuilder builder) throws Exception {
    authenticationProviderBean = builder.getSharedObject(SAMLAuthenticationProvider.class);
    config = builder.getSharedObject(SAMLSSOProperties.class).getAuthenticationProvider();
}
 
Example #10
Source File: AuthenticationProviderConfigurer.java    From spring-boot-security-saml with MIT License 2 votes vote down vote up
/**
 * Provide the provider to be used.
 *
 * @param provider the {@link SAMLAuthenticationProvider} to be used.
 */
public AuthenticationProviderConfigurer(SAMLAuthenticationProvider provider) {
    authenticationProvider = provider;
}