Search in sources :

Example 1 with ExtendedMetadataDelegate

use of org.springframework.security.saml.metadata.ExtendedMetadataDelegate 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);
    }
}
Also used : MetadataProvider(org.opensaml.saml2.metadata.provider.MetadataProvider) UrlMetadataProvider(org.openkilda.saml.provider.UrlMetadataProvider) DbMetadataProvider(org.openkilda.saml.provider.DbMetadataProvider) ExtendedMetadataDelegate(org.springframework.security.saml.metadata.ExtendedMetadataDelegate) ExtendedMetadata(org.springframework.security.saml.metadata.ExtendedMetadata) MetadataProviderException(org.opensaml.saml2.metadata.provider.MetadataProviderException)

Example 2 with ExtendedMetadataDelegate

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

the class SamlMetadataManager method updateProviderToMetadataManager.

/**
 * Updates the provider in metadata manager.
 * @param uuid the provider id
 * @param type the provider type
 */
public void updateProviderToMetadataManager(String uuid, String type) {
    List<ExtendedMetadataDelegate> providers = metadataManager.getAvailableProviders();
    String metadataEntityId = null;
    for (final ExtendedMetadataDelegate provider : providers) {
        MetadataProvider metadataProvider = provider.getDelegate();
        if (metadataProvider instanceof DbMetadataProvider) {
            DbMetadataProvider dbprovider = (DbMetadataProvider) provider.getDelegate();
            metadataEntityId = dbprovider.getMetaDataEntityId();
        } else if (metadataProvider instanceof UrlMetadataProvider) {
            UrlMetadataProvider urlprovider = (UrlMetadataProvider) provider.getDelegate();
            metadataEntityId = urlprovider.getMetaDataEntityId();
        }
        if (uuid.equals(metadataEntityId)) {
            metadataManager.removeMetadataProvider(provider);
            break;
        }
    }
    try {
        loadProviderMetadata(uuid, type);
    } catch (MetadataProviderException e) {
        LOGGER.error("Error occurred while updating provider in metadata manager" + e);
    }
}
Also used : DbMetadataProvider(org.openkilda.saml.provider.DbMetadataProvider) MetadataProvider(org.opensaml.saml2.metadata.provider.MetadataProvider) UrlMetadataProvider(org.openkilda.saml.provider.UrlMetadataProvider) DbMetadataProvider(org.openkilda.saml.provider.DbMetadataProvider) UrlMetadataProvider(org.openkilda.saml.provider.UrlMetadataProvider) ExtendedMetadataDelegate(org.springframework.security.saml.metadata.ExtendedMetadataDelegate) MetadataProviderException(org.opensaml.saml2.metadata.provider.MetadataProviderException)

Example 3 with ExtendedMetadataDelegate

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

the class SecurityConfig method ssoCircleExtendedMetadataProvider.

@Bean
@Qualifier("idp-ssocircle")
public ExtendedMetadataDelegate ssoCircleExtendedMetadataProvider() throws MetadataProviderException {
    DbMetadataProvider provider = new DbMetadataProvider();
    ExtendedMetadataDelegate extendedMetadataDelegate = new ExtendedMetadataDelegate(provider, extendedMetadata());
    extendedMetadataDelegate.setMetadataTrustCheck(false);
    extendedMetadataDelegate.setMetadataRequireSignature(false);
    return extendedMetadataDelegate;
}
Also used : DbMetadataProvider(org.openkilda.saml.provider.DbMetadataProvider) ExtendedMetadataDelegate(org.springframework.security.saml.metadata.ExtendedMetadataDelegate) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean)

Example 4 with ExtendedMetadataDelegate

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

Example 5 with ExtendedMetadataDelegate

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

the class AuthenticationFieldModelTestAction method performSAMLTest.

private void performSAMLTest(FieldUtility registeredFieldValues) throws IntegrationException {
    List<AlertFieldStatus> errors = new ArrayList<>();
    Optional<String> registeredEntityId = registeredFieldValues.getString(AuthenticationDescriptor.KEY_SAML_ENTITY_ID);
    if (registeredEntityId.isEmpty()) {
        errors.add(AlertFieldStatus.error(AuthenticationDescriptor.KEY_SAML_ENTITY_ID, "Entity ID missing."));
    }
    logger.info("Testing SAML Metadata URL...");
    try {
        Optional<ExtendedMetadataDelegate> provider = samlManager.createHttpProvider(registeredFieldValues.getStringOrEmpty(AuthenticationDescriptor.KEY_SAML_METADATA_URL));
        if (provider.isPresent()) {
            ExtendedMetadataDelegate extendedMetadataDelegate = provider.get();
            extendedMetadataDelegate.initialize();
        }
    } catch (Exception ex) {
        logger.error("Testing SAML Metadata URL error: ", ex);
        errors.add(AlertFieldStatus.error(AuthenticationDescriptor.KEY_SAML_METADATA_URL, ex.getMessage()));
    }
    logger.info("Testing SAML Metadata File...");
    try {
        Optional<ExtendedMetadataDelegate> provider = samlManager.createFileProvider();
        if (provider.isPresent()) {
            ExtendedMetadataDelegate extendedMetadataDelegate = provider.get();
            extendedMetadataDelegate.initialize();
        }
    } catch (Exception ex) {
        logger.error("Testing SAML Metadata File error: ", ex);
        errors.add(AlertFieldStatus.error(AuthenticationDescriptor.KEY_SAML_METADATA_FILE, ex.getMessage()));
    }
    samlManager.initializeConfiguration();
    if (!errors.isEmpty()) {
        throw new AlertFieldException(errors);
    }
}
Also used : ArrayList(java.util.ArrayList) ExtendedMetadataDelegate(org.springframework.security.saml.metadata.ExtendedMetadataDelegate) AlertFieldStatus(com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus) AlertFieldException(com.synopsys.integration.alert.common.exception.AlertFieldException) AlertFieldException(com.synopsys.integration.alert.common.exception.AlertFieldException) IntegrationException(com.synopsys.integration.exception.IntegrationException)

Aggregations

ExtendedMetadataDelegate (org.springframework.security.saml.metadata.ExtendedMetadataDelegate)6 DbMetadataProvider (org.openkilda.saml.provider.DbMetadataProvider)4 UrlMetadataProvider (org.openkilda.saml.provider.UrlMetadataProvider)3 MetadataProvider (org.opensaml.saml2.metadata.provider.MetadataProvider)3 ArrayList (java.util.ArrayList)2 MetadataProviderException (org.opensaml.saml2.metadata.provider.MetadataProviderException)2 Qualifier (org.springframework.beans.factory.annotation.Qualifier)2 Bean (org.springframework.context.annotation.Bean)2 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)1 AlertFieldException (com.synopsys.integration.alert.common.exception.AlertFieldException)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 Timer (java.util.Timer)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 SamlConfigEntity (org.openkilda.saml.dao.entity.SamlConfigEntity)1 CachingMetadataManager (org.springframework.security.saml.metadata.CachingMetadataManager)1 ExtendedMetadata (org.springframework.security.saml.metadata.ExtendedMetadata)1