Java Code Examples for org.springframework.security.saml.metadata.ExtendedMetadata

The following examples show how to use org.springframework.security.saml.metadata.ExtendedMetadata. These examples are extracted from open source projects. 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 Project: blackduck-alert   Source File: SamlManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateSamlDisabled() throws Exception {
    SAMLContext context = Mockito.mock(SAMLContext.class);
    ParserPool parserPool = Mockito.mock(ParserPool.class);
    ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class);
    MetadataManager metadataManager = Mockito.mock(MetadataManager.class);
    MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class);
    ConfigurationModel currentConfiguration = Mockito.mock(ConfigurationModel.class);
    FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class);
    Mockito.when(context.getCurrentConfiguration()).thenReturn(currentConfiguration);
    Mockito.when(context.isSAMLEnabled(Mockito.any(ConfigurationModel.class))).thenReturn(Boolean.FALSE.booleanValue());

    SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context);
    samlManager.updateSAMLConfiguration(Boolean.FALSE.booleanValue(), "metadataURL", "entityId", "baseURL");
    Mockito.verify(metadataGenerator).setEntityId(null);
    Mockito.verify(metadataGenerator).setEntityBaseURL(null);
    Mockito.verify(metadataManager).setProviders(Mockito.anyList());
    Mockito.verify(metadataManager).setDefaultIDP(null);
    Mockito.verify(metadataManager).setHostedSPName(null);
    Mockito.verify(metadataManager).afterPropertiesSet();
}
 
Example 2
Source Project: blackduck-alert   Source File: SamlManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateSamlEnabled() throws Exception {
    SAMLContext context = Mockito.mock(SAMLContext.class);
    ParserPool parserPool = Mockito.mock(ParserPool.class);
    ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class);
    MetadataManager metadataManager = Mockito.mock(MetadataManager.class);
    MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class);
    ConfigurationModel currentConfiguration = Mockito.mock(ConfigurationModel.class);
    FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class);
    Mockito.when(context.getCurrentConfiguration()).thenReturn(currentConfiguration);
    Mockito.when(context.isSAMLEnabled(Mockito.any(ConfigurationModel.class))).thenReturn(Boolean.TRUE.booleanValue());
    Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("metadataURL");
    Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("entityId");
    Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("baseURL");

    SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context);
    samlManager.updateSAMLConfiguration(Boolean.TRUE.booleanValue(), "metadataURL", "entityId", "baseURL");

    Mockito.verify(metadataGenerator).setEntityId(Mockito.anyString());
    Mockito.verify(metadataGenerator).setEntityBaseURL(Mockito.anyString());
    // these methods are called to clear the existing metadata and then set it if true.
    Mockito.verify(metadataManager, Mockito.times(2)).setProviders(Mockito.anyList());
    Mockito.verify(metadataManager, Mockito.times(2)).afterPropertiesSet();
}
 
Example 3
Source Project: blackduck-alert   Source File: SAMLStartupComponentTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testInitialize() throws Exception {
    SAMLContext context = Mockito.mock(SAMLContext.class);
    ParserPool parserPool = Mockito.mock(ParserPool.class);
    ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class);
    MetadataManager metadataManager = Mockito.mock(MetadataManager.class);
    MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class);
    ConfigurationModel currentConfiguration = Mockito.mock(ConfigurationModel.class);
    FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class);
    Mockito.when(context.getCurrentConfiguration()).thenReturn(currentConfiguration);
    Mockito.when(context.isSAMLEnabled(Mockito.any(ConfigurationModel.class))).thenReturn(Boolean.TRUE.booleanValue());
    Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("metadataURL");
    Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("entityId");
    Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("baseURL");

    SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context);
    SAMLStartupComponent startupComponent = new SAMLStartupComponent(context, samlManager);
    startupComponent.initializeComponent();

    Mockito.verify(metadataGenerator).setEntityId(Mockito.anyString());
    Mockito.verify(metadataGenerator).setEntityBaseURL(Mockito.anyString());
    Mockito.verify(metadataManager, Mockito.times(2)).setProviders(Mockito.anyList());
    Mockito.verify(metadataManager, Mockito.times(2)).afterPropertiesSet();
}
 
Example 4
Source Project: blackduck-alert   Source File: SAMLStartupComponentTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testInitializeException() throws Exception {
    SAMLContext context = Mockito.mock(SAMLContext.class);
    ParserPool parserPool = Mockito.mock(ParserPool.class);
    ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class);
    MetadataManager metadataManager = Mockito.mock(MetadataManager.class);
    MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class);
    FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class);
    Mockito.when(context.getCurrentConfiguration()).thenThrow(new AlertDatabaseConstraintException("Test exception"));

    SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context);
    SAMLStartupComponent startupComponent = new SAMLStartupComponent(context, samlManager);
    startupComponent.initializeComponent();

    Mockito.verify(metadataGenerator, Mockito.times(0)).setEntityId(Mockito.anyString());
    Mockito.verify(metadataGenerator, Mockito.times(0)).setEntityBaseURL(Mockito.anyString());
    Mockito.verify(metadataManager, Mockito.times(0)).setProviders(Mockito.anyList());
    Mockito.verify(metadataManager, Mockito.times(0)).afterPropertiesSet();
}
 
Example 5
@Before
public void setup() {
    properties = mock(SAMLSSOProperties.class);
    metadataManagerProperties = spy(new MetadataManagerProperties());
    extendedMetadataDelegateProperties = spy(new ExtendedMetadataDelegateProperties());
    idpConfiguration = spy(new IdentityProvidersProperties());
    extendedMetadata = spy(new ExtendedMetadata());
    when(properties.getMetadataManager()).thenReturn(metadataManagerProperties);
    when(properties.getExtendedDelegate()).thenReturn(extendedMetadataDelegateProperties);
    when(properties.getIdp()).thenReturn(idpConfiguration);
    builder = mock(ServiceProviderBuilder.class);
    when(builder.getSharedObject(SAMLSSOProperties.class)).thenReturn(properties);
    when(builder.getSharedObject(ExtendedMetadata.class)).thenReturn(extendedMetadata);
    resourceLoader = new DefaultResourceLoader();
    when(builder.getSharedObject(ResourceLoader.class)).thenReturn(resourceLoader);
    parserPool = mock(ParserPool.class);
    when(builder.getSharedObject(ParserPool.class)).thenReturn(parserPool);
}
 
Example 6
Source Project: blackduck-alert   Source File: SAMLManager.java    License: Apache License 2.0 5 votes vote down vote up
public SAMLManager(ParserPool parserPool, ExtendedMetadata extendedMetadata, MetadataManager metadataManager, MetadataGenerator metadataGenerator,
    FilePersistenceUtil filePersistenceUtil, SAMLContext samlContext) {
    this.parserPool = parserPool;
    this.extendedMetadata = extendedMetadata;
    this.metadataManager = metadataManager;
    this.metadataGenerator = metadataGenerator;
    this.filePersistenceUtil = filePersistenceUtil;
    this.samlContext = samlContext;
}
 
Example 7
@SneakyThrows
private ExtendedMetadataDelegate getExtendedProvider(MetadataProvider provider, ExtendedMetadata extendedMetadata, DelegateProps props, ExtendedMetadataDelegateProperties extendedDelegateConfig) {
    if (provider instanceof ExtendedMetadataDelegate) {
        return (ExtendedMetadataDelegate) provider;
    }
    ExtendedMetadataDelegate delegate = createDefaultExtendedMetadataDelegate(provider, extendedMetadata);

    delegate.setForceMetadataRevocationCheck(Optional.ofNullable(props.forceMetadataRevocationCheck)
            .orElseGet(extendedDelegateConfig::isForceMetadataRevocationCheck));

    delegate.setMetadataRequireSignature(Optional.ofNullable(props.metadataRequireSignature)
            .orElseGet(extendedDelegateConfig::isMetadataRequireSignature));

    delegate.setMetadataTrustCheck(Optional.ofNullable(props.metadataTrustCheck)
            .orElseGet(extendedDelegateConfig::isMetadataTrustCheck));

    delegate.setMetadataTrustedKeys(Optional.ofNullable(props.metadataTrustedKeys)
            .orElseGet(extendedDelegateConfig::getMetadataTrustedKeys));

    delegate.setRequireValidMetadata(Optional.ofNullable(props.requireValidMetadata)
            .orElseGet(extendedDelegateConfig::isRequireValidMetadata));

    delegate.setMetadataFilter(Optional.ofNullable(props.metadataFilter)
            .map(this::postProcess)
            .orElse(null));

    return postProcess(delegate);
}
 
Example 8
@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 9
@Before
    public void setup() {
        SAMLSSOProperties properties = mock(SAMLSSOProperties.class);
        extendedMetadataProperties = mock(ExtendedMetadataProperties.class);
        when(properties.getExtendedMetadata()).thenReturn(extendedMetadataProperties);
//        when(extendedMetadataProperties.isLocal()).thenReturn(false);
        when(extendedMetadataProperties.isIdpDiscoveryEnabled()).thenReturn(false);
        when(extendedMetadataProperties.isEcpEnabled()).thenReturn(false);
        when(extendedMetadataProperties.isSignMetadata()).thenReturn(false);
        when(extendedMetadataProperties.isRequireLogoutRequestSigned()).thenReturn(false);
        when(extendedMetadataProperties.isRequireLogoutResponseSigned()).thenReturn(false);
        when(extendedMetadataProperties.isRequireArtifactResolveSigned()).thenReturn(false);
        when(extendedMetadataProperties.isSupportUnsolicitedResponse()).thenReturn(false);
        when(extendedMetadataProperties.getAlias()).thenReturn("default");
        when(extendedMetadataProperties.getIdpDiscoveryUrl()).thenReturn("default");
        when(extendedMetadataProperties.getIdpDiscoveryResponseUrl()).thenReturn("default");
        when(extendedMetadataProperties.getSecurityProfile()).thenReturn("default");
        when(extendedMetadataProperties.getSslSecurityProfile()).thenReturn("default");
        when(extendedMetadataProperties.getSslHostnameVerification()).thenReturn("default");
        when(extendedMetadataProperties.getSigningKey()).thenReturn("default");
        when(extendedMetadataProperties.getSigningAlgorithm()).thenReturn("default");
        when(extendedMetadataProperties.getKeyInfoGeneratorName()).thenReturn("default");
        when(extendedMetadataProperties.getEncryptionKey()).thenReturn("default");
        when(extendedMetadataProperties.getTlsKey()).thenReturn("default");
        when(extendedMetadataProperties.getTrustedKeys()).thenReturn(Collections.singleton("default"));

        builder = mock(ServiceProviderBuilder.class);
        when(builder.getSharedObject(ExtendedMetadata.class)).thenReturn(null);
        when(builder.getSharedObject(SAMLSSOProperties.class)).thenReturn(properties);
    }
 
Example 10
@Test
public void init() throws Exception {
    ExtendedMetadataConfigurer configurer = new ExtendedMetadataConfigurer();
    configurer.init(builder);
    verify(builder).getSharedObject(eq(ExtendedMetadata.class));
    verify(builder).getSharedObject(eq(SAMLSSOProperties.class));
}
 
Example 11
@Test
public void configure() throws Exception {
    ExtendedMetadataConfigurer configurer = new ExtendedMetadataConfigurer();
    configurer.init(builder);
    configurer.configure(builder);
    verify(builder).setSharedObject(eq(ExtendedMetadata.class), any(ExtendedMetadata.class));
}
 
Example 12
@Test
public void configure_forBean() throws Exception {
    ExtendedMetadata extendedMetadata = mock(ExtendedMetadata.class);
    when(builder.getSharedObject(ExtendedMetadata.class)).thenReturn(extendedMetadata);
    ExtendedMetadataConfigurer configurer = new ExtendedMetadataConfigurer();
    configurer.init(builder);
    configurer.configure(builder);
    verify(builder, never()).setSharedObject(any(), any());
    verifyZeroInteractions(extendedMetadata, extendedMetadataProperties);
}
 
Example 13
@Test
public void configure_forConstructor() throws Exception {
    ExtendedMetadata extendedMetadata = mock(ExtendedMetadata.class);
    ExtendedMetadataConfigurer configurer = new ExtendedMetadataConfigurer(extendedMetadata);
    configurer.init(builder);
    configurer.configure(builder);
    verify(builder).setSharedObject(eq(ExtendedMetadata.class), eq(extendedMetadata));
    verifyZeroInteractions(extendedMetadata, extendedMetadataProperties);
}
 
Example 14
Source Project: spring-security-saml-dsl   Source File: SAMLConfigurer.java    License: MIT License 5 votes vote down vote up
private MetadataGenerator getMetadataGenerator(SAMLEntryPoint samlEntryPoint, ExtendedMetadata extendedMetadata) {
	MetadataGenerator metadataGenerator = new MetadataGenerator();

	metadataGenerator.setSamlEntryPoint(samlEntryPoint);
	metadataGenerator.setEntityBaseURL(entityBaseURL());
	metadataGenerator.setKeyManager(serviceProvider.keyManager);
	metadataGenerator.setEntityId(serviceProvider.entityId);
	metadataGenerator.setIncludeDiscoveryExtension(false);
	metadataGenerator.setExtendedMetadata(extendedMetadata);

	return metadataGenerator;
}
 
Example 15
@VisibleForTesting
protected ExtendedMetadataDelegate createDefaultExtendedMetadataDelegate(MetadataProvider provider, ExtendedMetadata extendedMetadata) {
    return new ExtendedMetadataDelegate(provider, extendedMetadata);
}
 
Example 16
public ExtendedMetadataConfigurer(ExtendedMetadata extendedMetadata) {
    this.extendedMetadata = extendedMetadata;
}
 
Example 17
@Override
public void init(ServiceProviderBuilder builder) throws Exception {
    extendedMetadataBean = builder.getSharedObject(ExtendedMetadata.class);
    extendedMetadataConfig = builder.getSharedObject(SAMLSSOProperties.class).getExtendedMetadata();

}
 
Example 18
protected ExtendedMetadata createExtendedMetadata() {
    return new ExtendedMetadata();
}
 
Example 19
protected void shareExtendedMetadata(ServiceProviderBuilder builder) {
    builder.setSharedObject(ExtendedMetadata.class, extendedMetadata);
}
 
Example 20
public LocalExtendedMetadataConfigurer(ExtendedMetadata extendedMetadata) {
    super(extendedMetadata);
}
 
Example 21
@Override
protected ExtendedMetadata createExtendedMetadata() {
    return new LocalExtendedMetadata();
}
 
Example 22
@Test
public void configure_arguments() throws Exception {
    MetadataManagerConfigurer configurer = spy(new MetadataManagerConfigurer());
    CachingMetadataManager metadataManager = mock(CachingMetadataManager.class);
    when(configurer.createDefaultMetadataManager()).thenReturn(metadataManager);
    ResourceBackedMetadataProvider provider = mock(ResourceBackedMetadataProvider.class);
    doReturn(provider).when(configurer).createDefaultMetadataProvider("classpath:idp-provided.xml");
    ExtendedMetadataDelegate delegate = mock(ExtendedMetadataDelegate.class);
    doReturn(delegate).when(configurer).createDefaultExtendedMetadataDelegate(eq(provider), any(ExtendedMetadata.class));
    MetadataFilter metadataFilter = mock(MetadataFilter.class);
    configurer.setBuilder(builder);
    configurer
            .metadataLocations("classpath:idp-provided.xml")
            .defaultIDP("default")
            .hostedSPName("spname")
            .refreshCheckInterval(999L)
            .forceMetadataRevocationCheck(true)
            .metadataRequireSignature(true)
            .metadataTrustCheck(true)
            .requireValidMetadata(true)
            .metadataTrustedKeys("one", "two")
            .metadataFilter(metadataFilter);
    configurer.init(builder);
    configurer.configure(builder);
    verify(builder).setSharedObject(eq(MetadataManager.class), eq(metadataManager));
    ArgumentCaptor<List> providersCaptor = ArgumentCaptor.forClass(List.class);
    verify(metadataManager).setProviders((List<MetadataProvider>) providersCaptor.capture());
    verify(configurer).createDefaultMetadataProvider(eq("classpath:idp-provided.xml"));
    verify(configurer).createDefaultExtendedMetadataDelegate(eq(provider), any());
    verify(metadataManagerProperties, never()).getDefaultIdp();
    verify(metadataManagerProperties, never()).getHostedSpName();
    verify(metadataManagerProperties, never()).getRefreshCheckInterval();
    verify(extendedMetadataDelegateProperties, never()).isForceMetadataRevocationCheck();
    verify(extendedMetadataDelegateProperties, never()).isMetadataRequireSignature();
    verify(extendedMetadataDelegateProperties, never()).isMetadataTrustCheck();
    verify(extendedMetadataDelegateProperties, never()).isRequireValidMetadata();
    verify(extendedMetadataDelegateProperties, never()).getMetadataTrustedKeys();
    List<MetadataProvider> providers = providersCaptor.getValue();
    assertThat(providers).hasSize(1);
    assertThat(providers.get(0)).isEqualTo(delegate);
    verify(metadataManager).setDefaultIDP(eq("default"));
    verify(metadataManager).setHostedSPName(eq("spname"));
    verify(metadataManager).setRefreshCheckInterval(eq(999L));
    verify(delegate).setForceMetadataRevocationCheck(eq(true));
    verify(delegate).setMetadataRequireSignature(eq(true));
    verify(delegate).setMetadataTrustCheck(eq(true));
    verify(delegate).setMetadataTrustedKeys((Set<String>) MockitoHamcrest.argThat(contains("one", "two")));
    verify(delegate).setRequireValidMetadata(eq(true));
    verify(delegate).setMetadataFilter(eq(metadataFilter));
}
 
Example 23
@Test
    public void testArguments() throws Exception {
        ExtendedMetadataConfigurer configurer = new ExtendedMetadataConfigurer();
        configurer
//                .local(true)
                .idpDiscoveryEnabled(true)
                .ecpEnabled(true)
                .signMetadata(true)
                .requireLogoutRequestSigned(true)
                .requireLogoutResponseSigned(true)
                .requireArtifactResolveSigned(true)
                .supportUnsolicitedResponse(true)
                .alias("prop")
                .idpDiscoveryURL("prop")
                .idpDiscoveryResponseURL("prop")
                .securityProfile("prop")
                .sslSecurityProfile("prop")
                .sslHostnameVerification("prop")
                .signingKey("prop")
                .signingAlgorithm("prop")
                .keyInfoGeneratorName("prop")
                .encryptionKey("prop")
                .tlsKey("prop")
                .trustedKeys("prop");
        configurer.init(builder);
        configurer.configure(builder);
        ArgumentCaptor<ExtendedMetadata> extendedMetadataCaptor = ArgumentCaptor.forClass(ExtendedMetadata.class);
        verify(builder).setSharedObject(eq(ExtendedMetadata.class), extendedMetadataCaptor.capture());
        verifyZeroInteractions(extendedMetadataProperties);
        assertThat(extendedMetadataCaptor.getValue()).isNotNull();
        ExtendedMetadata extendedMetadata = extendedMetadataCaptor.getValue();
        //assertThat(extendedMetadata.isLocal()).isTrue();
        assertThat(extendedMetadata.isIdpDiscoveryEnabled()).isTrue();
        assertThat(extendedMetadata.isEcpEnabled()).isTrue();
        assertThat(extendedMetadata.isSignMetadata()).isTrue();
        assertThat(extendedMetadata.isRequireLogoutRequestSigned()).isTrue();
        assertThat(extendedMetadata.isRequireLogoutResponseSigned()).isTrue();
        assertThat(extendedMetadata.isRequireArtifactResolveSigned()).isTrue();
        assertThat(extendedMetadata.isSupportUnsolicitedResponse()).isTrue();
        assertThat(extendedMetadata.getAlias()).isEqualTo("prop");
        assertThat(extendedMetadata.getIdpDiscoveryURL()).isEqualTo("prop");
        assertThat(extendedMetadata.getIdpDiscoveryResponseURL()).isEqualTo("prop");
        assertThat(extendedMetadata.getSecurityProfile()).isEqualTo("prop");
        assertThat(extendedMetadata.getSslSecurityProfile()).isEqualTo("prop");
        assertThat(extendedMetadata.getSslHostnameVerification()).isEqualTo("prop");
        assertThat(extendedMetadata.getSigningKey()).isEqualTo("prop");
        assertThat(extendedMetadata.getSigningAlgorithm()).isEqualTo("prop");
        assertThat(extendedMetadata.getKeyInfoGeneratorName()).isEqualTo("prop");
        assertThat(extendedMetadata.getEncryptionKey()).isEqualTo("prop");
        assertThat(extendedMetadata.getTlsKey()).isEqualTo("prop");
        assertThat(extendedMetadata.getTrustedKeys()).containsExactly("prop");
    }
 
Example 24
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
public void testProperties() throws Exception {
    ExtendedMetadataConfigurer configurer = new ExtendedMetadataConfigurer();
    configurer.init(builder);
    configurer.configure(builder);
    //verify(extendedMetadataProperties).isLocal();
    verify(extendedMetadataProperties).isIdpDiscoveryEnabled();
    verify(extendedMetadataProperties).isEcpEnabled();
    verify(extendedMetadataProperties).isSignMetadata();
    verify(extendedMetadataProperties).isRequireLogoutRequestSigned();
    verify(extendedMetadataProperties).isRequireLogoutResponseSigned();
    verify(extendedMetadataProperties).isRequireArtifactResolveSigned();
    verify(extendedMetadataProperties).isSupportUnsolicitedResponse();
    verify(extendedMetadataProperties).getAlias();
    verify(extendedMetadataProperties).getIdpDiscoveryUrl();
    verify(extendedMetadataProperties).getIdpDiscoveryResponseUrl();
    verify(extendedMetadataProperties).getSecurityProfile();
    verify(extendedMetadataProperties).getSslSecurityProfile();
    verify(extendedMetadataProperties).getSslHostnameVerification();
    verify(extendedMetadataProperties).getSigningKey();
    verify(extendedMetadataProperties).getSigningAlgorithm();
    verify(extendedMetadataProperties).getKeyInfoGeneratorName();
    verify(extendedMetadataProperties).getEncryptionKey();
    verify(extendedMetadataProperties).getTlsKey();
    verify(extendedMetadataProperties).getTrustedKeys();
    ArgumentCaptor<ExtendedMetadata> extendedMetadataCaptor = ArgumentCaptor.forClass(ExtendedMetadata.class);
    verify(builder).setSharedObject(eq(ExtendedMetadata.class), extendedMetadataCaptor.capture());
    verifyZeroInteractions(extendedMetadataProperties);
    assertThat(extendedMetadataCaptor.getValue()).isNotNull();
    ExtendedMetadata extendedMetadata = extendedMetadataCaptor.getValue();
    assertThat(extendedMetadata.isLocal()).isFalse();
    assertThat(extendedMetadata.isIdpDiscoveryEnabled()).isFalse();
    assertThat(extendedMetadata.isEcpEnabled()).isFalse();
    assertThat(extendedMetadata.isSignMetadata()).isFalse();
    assertThat(extendedMetadata.isRequireLogoutRequestSigned()).isFalse();
    assertThat(extendedMetadata.isRequireLogoutResponseSigned()).isFalse();
    assertThat(extendedMetadata.isRequireArtifactResolveSigned()).isFalse();
    assertThat(extendedMetadata.isSupportUnsolicitedResponse()).isFalse();
    assertThat(extendedMetadata.getAlias()).isEqualTo("default");
    assertThat(extendedMetadata.getIdpDiscoveryURL()).isEqualTo("default");
    assertThat(extendedMetadata.getIdpDiscoveryResponseURL()).isEqualTo("default");
    assertThat(extendedMetadata.getSecurityProfile()).isEqualTo("default");
    assertThat(extendedMetadata.getSslSecurityProfile()).isEqualTo("default");
    assertThat(extendedMetadata.getSslHostnameVerification()).isEqualTo("default");
    assertThat(extendedMetadata.getSigningKey()).isEqualTo("default");
    assertThat(extendedMetadata.getSigningAlgorithm()).isEqualTo("default");
    assertThat(extendedMetadata.getKeyInfoGeneratorName()).isEqualTo("default");
    assertThat(extendedMetadata.getEncryptionKey()).isEqualTo("default");
    assertThat(extendedMetadata.getTlsKey()).isEqualTo("default");
    assertThat(extendedMetadata.getTrustedKeys()).containsExactly("default");
}