use of org.springframework.security.saml.metadata.ExtendedMetadata 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);
}
use of org.springframework.security.saml.metadata.ExtendedMetadata 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();
}
use of org.springframework.security.saml.metadata.ExtendedMetadata in project open-kilda by telstra.
the class SamlMetadataManager method addProviderToMetadataManager.
/**
* adds the provider to metadata manager.
*
* @param metadataProvider the metadataProvider.
*/
private void addProviderToMetadataManager(MetadataProvider metadataProvider) {
List<MetadataProvider> providers = metadataManager.getProviders();
ExtendedMetadata extMeta = new ExtendedMetadata();
extMeta.setIdpDiscoveryEnabled(false);
extMeta.setSignMetadata(false);
ExtendedMetadataDelegate delegate = new ExtendedMetadataDelegate(metadataProvider, extMeta);
delegate.setMetadataTrustCheck(false);
delegate.setMetadataRequireSignature(false);
try {
delegate.initialize();
providers.add(delegate);
metadataManager.setProviders(providers);
metadataManager.refreshMetadata();
} catch (MetadataProviderException e) {
LOGGER.error("Error occurred while adding provider to metadata manager" + e);
}
}
use of org.springframework.security.saml.metadata.ExtendedMetadata in project hub-alert by blackducksoftware.
the class AuthenticationHandler method extendedMetadata.
@Bean
public ExtendedMetadata extendedMetadata() {
ExtendedMetadata extendedMetadata = new ExtendedMetadata();
extendedMetadata.setIdpDiscoveryEnabled(false);
extendedMetadata.setSignMetadata(false);
extendedMetadata.setEcpEnabled(true);
extendedMetadata.setRequireLogoutRequestSigned(false);
return extendedMetadata;
}
use of org.springframework.security.saml.metadata.ExtendedMetadata 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();
}
Aggregations