public SAMLObject resolveArtifact(SAMLMessageContext context, String artifactId, String endpointURI) throws MessageDecodingException {
try {
// Decode artifact.
SAML2ArtifactType0004 decodedArtifact = new SAML2ArtifactType0004Builder().buildArtifact(Base64.decode(artifactId));
// Endpoint index.
int endpointIndex = parseEndpointIndex(decodedArtifact.getEndpointIndex());
// Locate sender using the artifact sourceID
EntityDescriptor idpEntityDescriptor = metadata.getEntityDescriptor(decodedArtifact.getSourceID());
if (idpEntityDescriptor == null) {
throw new MetadataProviderException("Cannot localize sender entity by SHA-1 hash from the artifact");
}