private ArtifactResolutionService resolveArtifactEndpoint(final SAML2Artifact artifact,
                                                              final RoleDescriptor peerRoleDescriptor)
        throws MessageDecodingException {

        val roleDescriptorCriterion = new RoleDescriptorCriterion(peerRoleDescriptor);

        val 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);

        val endpointCriterion =
            new EndpointCriterion<>(arsTemplate, false);

        val criteriaSet = new CriteriaSet(roleDescriptorCriterion, endpointCriterion);

        try {
            val 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");
        }
    }
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
pac4j-saml/src/main/java/org/pac4j/saml/transport/Pac4jHTTPArtifactDecoder.java