Search in sources :

Example 1 with CachingMetadataManager

use of org.springframework.security.saml.metadata.CachingMetadataManager in project hub-alert by blackducksoftware.

the class SamlManagerTest method init.

@BeforeEach
public void init() throws Exception {
    gson = new Gson();
    context = Mockito.mock(SAMLContext.class);
    parserPool = Mockito.mock(ParserPool.class);
    extendedMetadata = Mockito.mock(ExtendedMetadata.class);
    metadataManager = new CachingMetadataManager(Collections.emptyList());
    metadataManager.setKeyManager(new EmptyKeyManager());
    metadataGenerator = Mockito.mock(MetadataGenerator.class);
    currentConfiguration = Mockito.mock(ConfigurationModel.class);
    alertProperties = Mockito.mock(AlertProperties.class);
    Mockito.when(alertProperties.getAlertSecretsDir()).thenReturn("./testDB/run/secrets");
    filePersistenceUtil = new FilePersistenceUtil(alertProperties, gson);
}
Also used : ParserPool(org.opensaml.xml.parse.ParserPool) ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) Gson(com.google.gson.Gson) ExtendedMetadata(org.springframework.security.saml.metadata.ExtendedMetadata) EmptyKeyManager(org.springframework.security.saml.key.EmptyKeyManager) AlertProperties(com.synopsys.integration.alert.common.AlertProperties) CachingMetadataManager(org.springframework.security.saml.metadata.CachingMetadataManager) MetadataGenerator(org.springframework.security.saml.metadata.MetadataGenerator) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with CachingMetadataManager

use of org.springframework.security.saml.metadata.CachingMetadataManager in project open-kilda by telstra.

the class SecurityConfig method metadata.

@Bean
@Qualifier("metadata")
public CachingMetadataManager metadata(ExtendedMetadataDelegate extendedMetadataDelegate) throws MetadataProviderException, IOException {
    List<MetadataProvider> metadataProviderList = new ArrayList<>();
    List<SamlConfigEntity> samlConfigEntityList = samlRepository.findAll();
    if (samlConfigEntityList != null) {
        for (final SamlConfigEntity samlConfigEntity : samlConfigEntityList) {
            if (samlConfigEntity.getUrl() != null) {
                UrlMetadataProvider urlMetadataProvider = new UrlMetadataProvider(new Timer(true), new HttpClient(), samlConfigEntity.getUuid());
                urlMetadataProvider.setParserPool(ParserPoolHolder.getPool());
                ExtendedMetadataDelegate metadataDelegate = new ExtendedMetadataDelegate(urlMetadataProvider, extendedMetadata());
                metadataDelegate.setMetadataTrustCheck(false);
                metadataDelegate.setMetadataRequireSignature(false);
                metadataProviderList.add(metadataDelegate);
            } else {
                DbMetadataProvider metadataProvider = new DbMetadataProvider(new Timer(true), samlConfigEntity.getUuid());
                metadataProvider.setParserPool(ParserPoolHolder.getPool());
                ExtendedMetadataDelegate metadataDelegate = new ExtendedMetadataDelegate(metadataProvider, extendedMetadata());
                metadataDelegate.setMetadataTrustCheck(false);
                metadataDelegate.setMetadataRequireSignature(false);
                metadataProviderList.add(metadataDelegate);
            }
        }
    }
    return new CachingMetadataManager(metadataProviderList);
}
Also used : DbMetadataProvider(org.openkilda.saml.provider.DbMetadataProvider) Timer(java.util.Timer) UrlMetadataProvider(org.openkilda.saml.provider.UrlMetadataProvider) DbMetadataProvider(org.openkilda.saml.provider.DbMetadataProvider) MetadataProvider(org.opensaml.saml2.metadata.provider.MetadataProvider) UrlMetadataProvider(org.openkilda.saml.provider.UrlMetadataProvider) HttpClient(org.apache.commons.httpclient.HttpClient) ArrayList(java.util.ArrayList) ExtendedMetadataDelegate(org.springframework.security.saml.metadata.ExtendedMetadataDelegate) SamlConfigEntity(org.openkilda.saml.dao.entity.SamlConfigEntity) CachingMetadataManager(org.springframework.security.saml.metadata.CachingMetadataManager) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean)

Aggregations

CachingMetadataManager (org.springframework.security.saml.metadata.CachingMetadataManager)2 Gson (com.google.gson.Gson)1 AlertProperties (com.synopsys.integration.alert.common.AlertProperties)1 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)1 FilePersistenceUtil (com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil)1 ArrayList (java.util.ArrayList)1 Timer (java.util.Timer)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 SamlConfigEntity (org.openkilda.saml.dao.entity.SamlConfigEntity)1 DbMetadataProvider (org.openkilda.saml.provider.DbMetadataProvider)1 UrlMetadataProvider (org.openkilda.saml.provider.UrlMetadataProvider)1 MetadataProvider (org.opensaml.saml2.metadata.provider.MetadataProvider)1 ParserPool (org.opensaml.xml.parse.ParserPool)1 Qualifier (org.springframework.beans.factory.annotation.Qualifier)1 Bean (org.springframework.context.annotation.Bean)1 EmptyKeyManager (org.springframework.security.saml.key.EmptyKeyManager)1 ExtendedMetadata (org.springframework.security.saml.metadata.ExtendedMetadata)1 ExtendedMetadataDelegate (org.springframework.security.saml.metadata.ExtendedMetadataDelegate)1 MetadataGenerator (org.springframework.security.saml.metadata.MetadataGenerator)1