Search in sources :

Example 1 with RestSamlMetadataProperties

use of org.apereo.cas.configuration.model.support.saml.idp.metadata.RestSamlMetadataProperties in project cas by apereo.

the class RestSamlRegisteredServiceMetadataResolver method resolve.

@Override
public Collection<MetadataResolver> resolve(final SamlRegisteredService service) {
    try {
        final RestSamlMetadataProperties rest = samlIdPProperties.getMetadata().getRest();
        final HttpResponse response = HttpUtils.execute(rest.getUrl(), rest.getMethod(), rest.getBasicAuthUsername(), rest.getBasicAuthPassword(), CollectionUtils.wrap("entityId", service.getServiceId()), CollectionUtils.wrap("Content-Type", MediaType.APPLICATION_XML_VALUE));
        if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            final SamlMetadataDocument doc = MAPPER.readValue(response.getEntity().getContent(), SamlMetadataDocument.class);
            final MetadataResolver resolver = buildMetadataResolverFrom(service, doc);
            return CollectionUtils.wrapList(resolver);
        }
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return null;
}
Also used : RestSamlMetadataProperties(org.apereo.cas.configuration.model.support.saml.idp.metadata.RestSamlMetadataProperties) HttpResponse(org.apache.http.HttpResponse) SamlMetadataDocument(org.apereo.cas.support.saml.services.idp.metadata.SamlMetadataDocument) MetadataResolver(org.opensaml.saml.metadata.resolver.MetadataResolver) BaseSamlRegisteredServiceMetadataResolver(org.apereo.cas.support.saml.services.idp.metadata.cache.resolver.BaseSamlRegisteredServiceMetadataResolver)

Aggregations

HttpResponse (org.apache.http.HttpResponse)1 RestSamlMetadataProperties (org.apereo.cas.configuration.model.support.saml.idp.metadata.RestSamlMetadataProperties)1 SamlMetadataDocument (org.apereo.cas.support.saml.services.idp.metadata.SamlMetadataDocument)1 BaseSamlRegisteredServiceMetadataResolver (org.apereo.cas.support.saml.services.idp.metadata.cache.resolver.BaseSamlRegisteredServiceMetadataResolver)1 MetadataResolver (org.opensaml.saml.metadata.resolver.MetadataResolver)1