org.springframework.security.saml.metadata.MetadataManager Java Examples

The following examples show how to use org.springframework.security.saml.metadata.MetadataManager. 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: SamlManagerTest.java    From blackduck-alert with 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 File: SamlManagerTest.java    From blackduck-alert with 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 File: SAMLStartupComponentTest.java    From blackduck-alert with 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 File: SAMLStartupComponentTest.java    From blackduck-alert with 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
Source File: MetadataManagerConfigurerTest.java    From spring-boot-security-saml with MIT License 6 votes vote down vote up
@Test
public void configure_constructor() throws Exception {
    MetadataManager metadataManager = mock(MetadataManager.class);
    MetadataManagerConfigurer configurer = spy(new MetadataManagerConfigurer(metadataManager));
    configurer.setBuilder(builder);
    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(idpConfiguration.getMetadataLocation()));
    verify(configurer).createDefaultExtendedMetadataDelegate(any(ResourceBackedMetadataProvider.class), any());
    verify(metadataManagerProperties, never()).getDefaultIdp();
    verify(metadataManagerProperties, never()).getHostedSpName();
    verify(metadataManagerProperties, never()).getRefreshCheckInterval();
    verify(extendedMetadataDelegateProperties).isForceMetadataRevocationCheck();
    verify(extendedMetadataDelegateProperties).isMetadataRequireSignature();
    verify(extendedMetadataDelegateProperties).isMetadataTrustCheck();
    verify(extendedMetadataDelegateProperties).isRequireValidMetadata();
    verify(extendedMetadataDelegateProperties).getMetadataTrustedKeys();
    List<MetadataProvider> providers = providersCaptor.getValue();
    assertThat(providers).hasSize(1);
    assertThat(providers.get(0)).isExactlyInstanceOf(ExtendedMetadataDelegate.class);
    assertThat(((ExtendedMetadataDelegate) providers.get(0)).getDelegate()).isExactlyInstanceOf(ResourceBackedMetadataProvider.class);
}
 
Example #6
Source File: SAMLManager.java    From blackduck-alert with 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
Source File: MetadataManagerConfigurer.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Override
public void init(ServiceProviderBuilder builder) throws Exception {
    resourceLoader = builder.getSharedObject(ResourceLoader.class);
    metadataManagerBean = builder.getSharedObject(MetadataManager.class);
    extendedDelegateConfig = builder.getSharedObject(SAMLSSOProperties.class).getExtendedDelegate();
    localExtendedDelegateConfig = builder.getSharedObject(SAMLSSOProperties.class).getLocalExtendedDelegate();
    managerConfig = builder.getSharedObject(SAMLSSOProperties.class).getMetadataManager();
    idpConfig = builder.getSharedObject(SAMLSSOProperties.class).getIdp();
}
 
Example #8
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 #9
Source File: MetadataManagerConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void configure_defaults_withProviderLocation() throws Exception {
    MetadataManagerConfigurer configurer = spy(new MetadataManagerConfigurer());
    CachingMetadataManager metadataManager = mock(CachingMetadataManager.class);
    when(configurer.createDefaultMetadataManager()).thenReturn(metadataManager);
    configurer.setBuilder(builder);
    configurer.metadataLocations("classpath:idp-provided.xml");
    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(any(ResourceBackedMetadataProvider.class), any());
    verify(metadataManagerProperties).getDefaultIdp();
    verify(metadataManagerProperties).getHostedSpName();
    verify(metadataManagerProperties).getRefreshCheckInterval();
    verify(extendedMetadataDelegateProperties).isForceMetadataRevocationCheck();
    verify(extendedMetadataDelegateProperties).isMetadataRequireSignature();
    verify(extendedMetadataDelegateProperties).isMetadataTrustCheck();
    verify(extendedMetadataDelegateProperties).isRequireValidMetadata();
    verify(extendedMetadataDelegateProperties).getMetadataTrustedKeys();
    List<MetadataProvider> providers = providersCaptor.getValue();
    assertThat(providers).hasSize(1);
    assertThat(providers.get(0)).isExactlyInstanceOf(ExtendedMetadataDelegate.class);
    assertThat(((ExtendedMetadataDelegate) providers.get(0)).getDelegate()).isExactlyInstanceOf(ResourceBackedMetadataProvider.class);
}
 
Example #10
Source File: MetadataManagerConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void configure_defaults_withProviderDelegate() throws Exception {
    MetadataManagerConfigurer configurer = spy(new MetadataManagerConfigurer());
    CachingMetadataManager metadataManager = mock(CachingMetadataManager.class);
    when(configurer.createDefaultMetadataManager()).thenReturn(metadataManager);
    configurer.setBuilder(builder);
    MetadataProvider provider = mock(ExtendedMetadataDelegate.class);
    configurer.metadataProvider(provider);
    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, never()).createDefaultMetadataProvider(eq(idpConfiguration.getMetadataLocation()));
    verify(configurer, never()).createDefaultExtendedMetadataDelegate(any(ResourceBackedMetadataProvider.class), any());
    verify(metadataManagerProperties).getDefaultIdp();
    verify(metadataManagerProperties).getHostedSpName();
    verify(metadataManagerProperties).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(provider);
    assertThat(((ExtendedMetadataDelegate) providers.get(0)).getDelegate()).isNull();
}
 
Example #11
Source File: MetadataManagerConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void configure_defaults_withProvider() throws Exception {
    MetadataManagerConfigurer configurer = spy(new MetadataManagerConfigurer());
    CachingMetadataManager metadataManager = mock(CachingMetadataManager.class);
    when(configurer.createDefaultMetadataManager()).thenReturn(metadataManager);
    configurer.setBuilder(builder);
    AbstractMetadataProvider provider = mock(AbstractMetadataProvider.class);
    configurer.metadataProvider(provider);
    configurer.init(builder);
    configurer.configure(builder);
    verify(builder).setSharedObject(eq(MetadataManager.class), eq(metadataManager));
    ArgumentCaptor<List> providersCaptor = ArgumentCaptor.forClass(List.class);
    verify(provider).setParserPool(eq(parserPool));
    verify(metadataManager).setProviders((List<MetadataProvider>) providersCaptor.capture());
    verify(configurer, never()).createDefaultMetadataProvider(eq(idpConfiguration.getMetadataLocation()));
    verify(configurer, never()).createDefaultExtendedMetadataDelegate(any(ResourceBackedMetadataProvider.class), any());
    verify(metadataManagerProperties).getDefaultIdp();
    verify(metadataManagerProperties).getHostedSpName();
    verify(metadataManagerProperties).getRefreshCheckInterval();
    verify(extendedMetadataDelegateProperties).isForceMetadataRevocationCheck();
    verify(extendedMetadataDelegateProperties).isMetadataRequireSignature();
    verify(extendedMetadataDelegateProperties).isMetadataTrustCheck();
    verify(extendedMetadataDelegateProperties).isRequireValidMetadata();
    verify(extendedMetadataDelegateProperties).getMetadataTrustedKeys();
    List<MetadataProvider> providers = providersCaptor.getValue();
    assertThat(providers).hasSize(1);
    assertThat(providers.get(0)).isExactlyInstanceOf(ExtendedMetadataDelegate.class);
    assertThat(((ExtendedMetadataDelegate) providers.get(0)).getDelegate()).isEqualTo(provider);
}
 
Example #12
Source File: MetadataManagerConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void configure_defaults() throws Exception {
    MetadataManagerConfigurer configurer = spy(new MetadataManagerConfigurer());
    CachingMetadataManager metadataManager = mock(CachingMetadataManager.class);
    when(configurer.createDefaultMetadataManager()).thenReturn(metadataManager);
    ExtendedMetadataDelegate delegate = mock(ExtendedMetadataDelegate.class);
    doReturn(delegate).when(configurer).createDefaultExtendedMetadataDelegate(any(), any());
    configurer.setBuilder(builder);
    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(idpConfiguration.getMetadataLocation()));
    verify(configurer).createDefaultExtendedMetadataDelegate(any(ResourceBackedMetadataProvider.class), any());
    verify(metadataManagerProperties).getDefaultIdp();
    verify(metadataManagerProperties).getHostedSpName();
    verify(metadataManagerProperties).getRefreshCheckInterval();
    verify(extendedMetadataDelegateProperties).isForceMetadataRevocationCheck();
    verify(extendedMetadataDelegateProperties).isMetadataRequireSignature();
    verify(extendedMetadataDelegateProperties).isMetadataTrustCheck();
    verify(extendedMetadataDelegateProperties).isRequireValidMetadata();
    verify(extendedMetadataDelegateProperties).getMetadataTrustedKeys();
    List<MetadataProvider> providers = providersCaptor.getValue();
    assertThat(providers).hasSize(1);
    assertThat(providers.get(0)).isEqualTo(delegate);
    verify(metadataManager).setDefaultIDP(eq(metadataManagerProperties.getDefaultIdp()));
    verify(metadataManager).setHostedSPName(eq(metadataManagerProperties.getHostedSpName()));
    verify(metadataManager).setRefreshCheckInterval(eq(metadataManagerProperties.getRefreshCheckInterval()));
    verify(delegate).setForceMetadataRevocationCheck(eq(extendedMetadataDelegateProperties.isForceMetadataRevocationCheck()));
    verify(delegate).setMetadataRequireSignature(eq(extendedMetadataDelegateProperties.isMetadataRequireSignature()));
    verify(delegate).setMetadataTrustCheck(eq(extendedMetadataDelegateProperties.isMetadataTrustCheck()));
    verify(delegate).setMetadataTrustedKeys(eq(extendedMetadataDelegateProperties.getMetadataTrustedKeys()));
    verify(delegate).setRequireValidMetadata(eq(extendedMetadataDelegateProperties.isRequireValidMetadata()));
    verify(delegate).setMetadataFilter((MetadataFilter) isNull());
}
 
Example #13
Source File: MetadataManagerConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void configure_bean() throws Exception {
    MetadataManager metadataManager = mock(MetadataManager.class);
    when(builder.getSharedObject(MetadataManager.class)).thenReturn(metadataManager);
    MetadataManagerConfigurer configurer = new MetadataManagerConfigurer();
    configurer.init(builder);
    configurer.configure(builder);
    verifyZeroInteractions(metadataManagerProperties, extendedMetadata);
    verify(builder, never()).setSharedObject(eq(MetadataManager.class), any());
}
 
Example #14
Source File: MetadataManagerConfigurerTest.java    From spring-boot-security-saml with MIT License 5 votes vote down vote up
@Test
public void init() throws Exception {
    MetadataManagerConfigurer configurer = new MetadataManagerConfigurer();
    configurer.init(builder);
    verify(builder).getSharedObject(eq(MetadataManager.class));
    verify(builder, atLeastOnce()).getSharedObject(eq(SAMLSSOProperties.class));
    verify(builder).getSharedObject(eq(ResourceLoader.class));
    verify(properties).getMetadataManager();
    verify(properties).getExtendedDelegate();
}
 
Example #15
Source File: MetadataValidator.java    From spring-security-saml-java-sp with Apache License 2.0 4 votes vote down vote up
public MetadataValidator(MetadataManager manager) {
    this.manager = manager;
}
 
Example #16
Source File: MetadataManagerConfigurerTest.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
@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 #17
Source File: DSLWebSSOProfileECPImpl.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
/**
 * Metadata manager provides information about all available IDP and SP entities.
 *
 * @param metadata metadata manager
 */
@Override
@Autowired(required = false)
public void setMetadata(MetadataManager metadata) {
    super.setMetadata(metadata);
}
 
Example #18
Source File: DSLWebSSOProfileHoKImpl.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
/**
 * Metadata manager provides information about all available IDP and SP entities.
 *
 * @param metadata metadata manager
 */
@Override
@Autowired(required = false)
public void setMetadata(MetadataManager metadata) {
    super.setMetadata(metadata);
}
 
Example #19
Source File: DSLWebSSOProfileConsumerImpl.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
/**
 * Metadata manager provides information about all available IDP and SP entities.
 *
 * @param metadata metadata manager
 */
@Override
@Autowired(required = false)
public void setMetadata(MetadataManager metadata) {
    super.setMetadata(metadata);
}
 
Example #20
Source File: DSLSAMLContextProviderLB.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@Autowired(required = false)
public void setMetadata(MetadataManager metadata) {
    super.setMetadata(metadata);
}
 
Example #21
Source File: DSLWebSSOProfileImpl.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
/**
 * Metadata manager provides information about all available IDP and SP entities.
 *
 * @param metadata metadata manager
 */
@Override
@Autowired(required = false)
public void setMetadata(MetadataManager metadata) {
    super.setMetadata(metadata);
}
 
Example #22
Source File: DSLSAMLContextProviderImpl.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
/**
 * Metadata manager provides information about all available IDP and SP entities.
 *
 * @param metadata metadata manager
 */
@Override
@Autowired(required = false)
public void setMetadata(MetadataManager metadata) {
    super.setMetadata(metadata);
}
 
Example #23
Source File: DSLSingleLogoutProfileImpl.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
/**
 * Metadata manager provides information about all available IDP and SP entities.
 *
 * @param metadata metadata manager
 */
@Override
@Autowired(required = false)
public void setMetadata(MetadataManager metadata) {
    super.setMetadata(metadata);
}
 
Example #24
Source File: DSLWebSSOProfileConsumerHoKImpl.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
/**
 * Metadata manager provides information about all available IDP and SP entities.
 *
 * @param metadata metadata manager
 */
@Override
@Autowired(required = false)
public void setMetadata(MetadataManager metadata) {
    super.setMetadata(metadata);
}
 
Example #25
Source File: MetadataManagerConfigurer.java    From spring-boot-security-saml with MIT License 4 votes vote down vote up
public MetadataManagerConfigurer(MetadataManager metadataManager) {
    this.metadataManager = metadataManager;
}
 
Example #26
Source File: SAMLDslEntryPoint.java    From spring-security-saml-dsl with MIT License 2 votes vote down vote up
/**
 * Metadata manager, cannot be null, must be set.
 * It is set directly in the custom config, so can be optional here.
 * User could override it if desired.
 *
 * @param metadata manager
 */
@Autowired(required = false)
@Override
public void setMetadata(MetadataManager metadata) {
	super.setMetadata(metadata);
}