Search in sources :

Example 6 with Artifact

use of org.opensaml.saml.saml2.core.Artifact in project cas by apereo.

the class SamlIdPSaml1ArtifactResolutionProfileHandlerControllerTests method getArtifactResolve.

private ArtifactResolve getArtifactResolve() {
    var builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(ArtifactResolve.DEFAULT_ELEMENT_NAME);
    val request = (ArtifactResolve) builder.buildObject();
    builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
    val issuer = (Issuer) builder.buildObject();
    issuer.setValue(samlRegisteredService.getServiceId());
    request.setIssuer(issuer);
    builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Artifact.DEFAULT_ELEMENT_NAME);
    val artifact = (Artifact) builder.buildObject();
    artifact.setValue("https://cassp.example.org");
    request.setArtifact(artifact);
    return request;
}
Also used : lombok.val(lombok.val) ArtifactResolve(org.opensaml.saml.saml2.core.ArtifactResolve) SAMLObjectBuilder(org.opensaml.saml.common.SAMLObjectBuilder) Issuer(org.opensaml.saml.saml2.core.Issuer) Artifact(org.opensaml.saml.saml2.core.Artifact)

Example 7 with Artifact

use of org.opensaml.saml.saml2.core.Artifact in project pac4j by pac4j.

the class Pac4jHTTPArtifactDecoder method resolveArtifactEndpoint.

/**
 * Resolve the artifact resolution endpoint of the peer who issued the artifact.
 *
 * @param artifact           the artifact
 * @param peerRoleDescriptor the peer RoleDescriptor
 * @return the peer artifact resolution service endpoint
 * @throws MessageDecodingException if there is a fatal error resolving the endpoint,
 *                                  or the endpoint could not be resolved
 */
@Nonnull
private ArtifactResolutionService resolveArtifactEndpoint(@Nonnull final SAML2Artifact artifact, @Nonnull final RoleDescriptor peerRoleDescriptor) throws MessageDecodingException {
    final var roleDescriptorCriterion = new RoleDescriptorCriterion(peerRoleDescriptor);
    final var arsTemplate = (ArtifactResolutionService) XMLObjectSupport.buildXMLObject(ArtifactResolutionService.DEFAULT_ELEMENT_NAME);
    arsTemplate.setBinding(SAMLConstants.SAML2_SOAP11_BINDING_URI);
    if (artifact instanceof SAMLSourceLocationArtifact) {
        arsTemplate.setLocation(((SAMLSourceLocationArtifact) artifact).getSourceLocation());
    }
    final Integer endpointIndex = SAMLBindingSupport.convertSAML2ArtifactEndpointIndex(artifact.getEndpointIndex());
    arsTemplate.setIndex(endpointIndex);
    final var endpointCriterion = new EndpointCriterion<ArtifactResolutionService>(arsTemplate, false);
    final var criteriaSet = new CriteriaSet(roleDescriptorCriterion, endpointCriterion);
    try {
        final var ars = artifactEndpointResolver.resolveSingle(criteriaSet);
        if (ars != null) {
            return ars;
        } else {
            throw new MessageDecodingException("Unable to resolve ArtifactResolutionService endpoint");
        }
    } catch (final ResolverException e) {
        throw new MessageDecodingException("Unable to resolve ArtifactResolutionService endpoint");
    }
}
Also used : MessageDecodingException(org.opensaml.messaging.decoder.MessageDecodingException) ResolverException(net.shibboleth.utilities.java.support.resolver.ResolverException) RoleDescriptorCriterion(org.opensaml.saml.criterion.RoleDescriptorCriterion) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) ArtifactResolutionService(org.opensaml.saml.saml2.metadata.ArtifactResolutionService) EndpointCriterion(org.opensaml.saml.criterion.EndpointCriterion) SAMLSourceLocationArtifact(org.opensaml.saml.common.binding.artifact.SAMLSourceLocationArtifact) Nonnull(javax.annotation.Nonnull)

Aggregations

SamlArtifactTicket (org.apereo.cas.ticket.artifact.SamlArtifactTicket)4 lombok.val (lombok.val)3 ArtifactResolve (org.opensaml.saml.saml2.core.ArtifactResolve)3 Nonnull (javax.annotation.Nonnull)2 UnauthorizedServiceException (org.apereo.cas.services.UnauthorizedServiceException)2 MessageDecodingException (org.opensaml.messaging.decoder.MessageDecodingException)2 SAMLObject (org.opensaml.saml.common.SAMLObject)2 ArtifactResponse (org.opensaml.saml.saml2.core.ArtifactResponse)2 ArtifactResponseBuilder (org.opensaml.saml.saml2.core.impl.ArtifactResponseBuilder)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 CriteriaSet (net.shibboleth.utilities.java.support.resolver.CriteriaSet)1 ResolverException (net.shibboleth.utilities.java.support.resolver.ResolverException)1 Service (org.apereo.cas.authentication.principal.Service)1 WebApplicationService (org.apereo.cas.authentication.principal.WebApplicationService)1 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)1 SamlRegisteredServiceServiceProviderMetadataFacade (org.apereo.cas.support.saml.services.idp.metadata.SamlRegisteredServiceServiceProviderMetadataFacade)1 InvalidTicketException (org.apereo.cas.ticket.InvalidTicketException)1 SamlArtifactTicketFactory (org.apereo.cas.ticket.artifact.SamlArtifactTicketFactory)1 Assertion (org.jasig.cas.client.validation.Assertion)1 MessageException (org.opensaml.messaging.MessageException)1