Search in sources :

Example 1 with MetadataGenerator

use of org.springframework.security.saml.metadata.MetadataGenerator 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 MetadataGenerator

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

the class SAMLStartupComponentTest method testInitialize.

@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.eq(AuthenticationDescriptor.KEY_SAML_METADATA_URL))).thenReturn("metadataURL");
    Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.eq(AuthenticationDescriptor.KEY_SAML_ENTITY_ID))).thenReturn("entityId");
    Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.eq(AuthenticationDescriptor.KEY_SAML_ENTITY_BASE_URL))).thenReturn("baseURL");
    SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context);
    SAMLStartupComponent startupComponent = new SAMLStartupComponent(samlManager);
    startupComponent.initializeComponent();
    Mockito.verify(context).disableSAML();
}
Also used : ParserPool(org.opensaml.xml.parse.ParserPool) ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) MetadataManager(org.springframework.security.saml.metadata.MetadataManager) FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) SAMLContext(com.synopsys.integration.alert.component.authentication.security.saml.SAMLContext) ExtendedMetadata(org.springframework.security.saml.metadata.ExtendedMetadata) SAMLManager(com.synopsys.integration.alert.component.authentication.security.saml.SAMLManager) MetadataGenerator(org.springframework.security.saml.metadata.MetadataGenerator) Test(org.junit.jupiter.api.Test)

Example 3 with MetadataGenerator

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

the class SecurityConfig method metadataGenerator.

@Bean
public MetadataGenerator metadataGenerator() {
    MetadataGenerator metadataGenerator = new MetadataGenerator();
    metadataGenerator.setEntityId("openkilda");
    metadataGenerator.setExtendedMetadata(extendedMetadata());
    metadataGenerator.setIncludeDiscoveryExtension(false);
    metadataGenerator.setKeyManager(keyManager());
    return metadataGenerator;
}
Also used : MetadataGenerator(org.springframework.security.saml.metadata.MetadataGenerator) Bean(org.springframework.context.annotation.Bean)

Example 4 with MetadataGenerator

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

the class SAMLStartupComponentTest method testInitializeException.

@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 AlertConfigurationException("Test exception"));
    SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context);
    SAMLStartupComponent startupComponent = new SAMLStartupComponent(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();
}
Also used : ParserPool(org.opensaml.xml.parse.ParserPool) MetadataManager(org.springframework.security.saml.metadata.MetadataManager) FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) SAMLContext(com.synopsys.integration.alert.component.authentication.security.saml.SAMLContext) ExtendedMetadata(org.springframework.security.saml.metadata.ExtendedMetadata) SAMLManager(com.synopsys.integration.alert.component.authentication.security.saml.SAMLManager) MetadataGenerator(org.springframework.security.saml.metadata.MetadataGenerator) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException) Test(org.junit.jupiter.api.Test)

Aggregations

MetadataGenerator (org.springframework.security.saml.metadata.MetadataGenerator)4 FilePersistenceUtil (com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil)3 ParserPool (org.opensaml.xml.parse.ParserPool)3 ExtendedMetadata (org.springframework.security.saml.metadata.ExtendedMetadata)3 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)2 SAMLContext (com.synopsys.integration.alert.component.authentication.security.saml.SAMLContext)2 SAMLManager (com.synopsys.integration.alert.component.authentication.security.saml.SAMLManager)2 Test (org.junit.jupiter.api.Test)2 MetadataManager (org.springframework.security.saml.metadata.MetadataManager)2 Gson (com.google.gson.Gson)1 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)1 AlertProperties (com.synopsys.integration.alert.common.AlertProperties)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Bean (org.springframework.context.annotation.Bean)1 EmptyKeyManager (org.springframework.security.saml.key.EmptyKeyManager)1 CachingMetadataManager (org.springframework.security.saml.metadata.CachingMetadataManager)1