org.springframework.security.saml.trust.httpclient.TLSProtocolConfigurer Java Examples

The following examples show how to use org.springframework.security.saml.trust.httpclient.TLSProtocolConfigurer. 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: TLSConfigurerTest.java    From spring-boot-security-saml with MIT License 6 votes vote down vote up
@Test
public void configure_defaults() throws Exception {
    TLSConfigurer configurer = spy(new TLSConfigurer());
    TLSProtocolConfigurer tlsProtocolConfigurer = mock(TLSProtocolConfigurer.class);
    when(configurer.createDefaultTlsProtocolConfigurer()).thenReturn(tlsProtocolConfigurer);
    configurer.init(builder);
    configurer.configure(builder);
    verify(tlsConfig).getProtocolName();
    verify(tlsConfig).getProtocolPort();
    verify(tlsConfig).getSslHostnameVerification();
    verify(tlsConfig).getTrustedKeys();
    verify(builder).setSharedObject(eq(TLSProtocolConfigurer.class), eq(tlsProtocolConfigurer));
    verify(tlsProtocolConfigurer).setProtocolName(eq(tlsConfig.getProtocolName()));
    verify(tlsProtocolConfigurer).setProtocolPort(eq(tlsConfig.getProtocolPort()));
    verify(tlsProtocolConfigurer).setSslHostnameVerification(eq(tlsConfig.getSslHostnameVerification()));
    verify(tlsProtocolConfigurer).setTrustedKeys(eq(tlsConfig.getTrustedKeys()));
}
 
Example #2
Source File: TLSConfigurerTest.java    From spring-boot-security-saml with MIT License 6 votes vote down vote up
@Test
public void configure_custom() throws Exception {
    TLSConfigurer configurer = spy(new TLSConfigurer());
    TLSProtocolConfigurer tlsProtocolConfigurer = mock(TLSProtocolConfigurer.class);
    when(configurer.createDefaultTlsProtocolConfigurer()).thenReturn(tlsProtocolConfigurer);
    configurer
            .protocolName("protocol")
            .protocolPort(9999)
            .sslHostnameVerification("strict")
            .trustedKeys("one", "two");
    configurer.init(builder);
    configurer.configure(builder);
    verify(tlsConfig, never()).getProtocolName();
    verify(tlsConfig, never()).getProtocolPort();
    verify(tlsConfig, never()).getSslHostnameVerification();
    verify(tlsConfig, never()).getTrustedKeys();
    verify(builder).setSharedObject(eq(TLSProtocolConfigurer.class), eq(tlsProtocolConfigurer));
    verify(tlsProtocolConfigurer).setProtocolName(eq("protocol"));
    verify(tlsProtocolConfigurer).setProtocolPort(eq(9999));
    verify(tlsProtocolConfigurer).setSslHostnameVerification(eq("strict"));
    verify(tlsProtocolConfigurer).setTrustedKeys((Set<String>) MockitoHamcrest.argThat(contains("one", "two")));
}
 
Example #3
Source File: TLSConfigurer.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Override
public void configure(ServiceProviderBuilder builder) throws Exception {
    KeyManager keyManager = builder.getSharedObject(KeyManager.class);
    TLSProtocolConfigurer configurer = createDefaultTlsProtocolConfigurer();
    configurer.setProtocolName(Optional.ofNullable(protocolName).orElseGet(config::getProtocolName));
    configurer.setProtocolPort(Optional.ofNullable(protocolPort).orElseGet(config::getProtocolPort));
    configurer.setSslHostnameVerification(Optional.ofNullable(sslHostnameVerification).orElseGet(config::getSslHostnameVerification));
    configurer.setTrustedKeys(Optional.ofNullable(trustedKeys).orElseGet(config::getTrustedKeys));
    configurer.setKeyManager(keyManager);
    configurer.afterPropertiesSet();
    builder.setSharedObject(TLSProtocolConfigurer.class, configurer);
}
 
Example #4
Source File: TLSConfigurer.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
@VisibleForTesting
protected TLSProtocolConfigurer createDefaultTlsProtocolConfigurer() {
    return new TLSProtocolConfigurer();
}
 
Example #5
Source File: SAMLConfig.java    From spring-boot-security-saml-samples with MIT License 4 votes vote down vote up
@Bean
public TLSProtocolConfigurer tlsProtocolConfigurer(KeyManager keyManager) {
    TLSProtocolConfigurer configurer = new TLSProtocolConfigurer();
    configurer.setKeyManager(keyManager);
    return configurer;
}