[java-opensaml] 08/16: Fix bug in artifact decoder, return payload of ArtifactResolve.
Brent Putman
putmanb at georgetown.edu
Sun Dec 17 00:08:18 EST 2017
This is an automated email from the git hooks/post-receive script.
putmanb pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=9053bf8254ccbe6dc957e74a0bf8dbb8591c3706
commit 9053bf8254ccbe6dc957e74a0bf8dbb8591c3706
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Sun Dec 10 15:53:45 2017 -0500
Fix bug in artifact decoder, return payload of ArtifactResolve.
---
.../binding/decoding/impl/HTTPArtifactDecoder.java | 28 +++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPArtifactDecoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPArtifactDecoder.java
index ccaf2d9..50a451f 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPArtifactDecoder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPArtifactDecoder.java
@@ -50,7 +50,9 @@ import org.opensaml.saml.saml2.binding.artifact.SAML2Artifact;
import org.opensaml.saml.saml2.binding.artifact.SAML2ArtifactBuilderFactory;
import org.opensaml.saml.saml2.core.Artifact;
import org.opensaml.saml.saml2.core.ArtifactResolve;
+import org.opensaml.saml.saml2.core.ArtifactResponse;
import org.opensaml.saml.saml2.core.Issuer;
+import org.opensaml.saml.saml2.core.StatusCode;
import org.opensaml.saml.saml2.metadata.ArtifactResolutionService;
import org.opensaml.saml.saml2.metadata.RoleDescriptor;
import org.opensaml.security.SecurityException;
@@ -378,11 +380,35 @@ public class HTTPArtifactDecoder extends BaseHttpServletRequestXMLMessageDecoder
try {
log.trace("Executing ArtifactResolve over SOAP 1.1 binding to endpoint: {}", ars.getLocation());
soapClient.send(ars.getLocation(), opContext);
- return opContext.getInboundMessageContext().getMessage();
+ SAMLObject response = opContext.getInboundMessageContext().getMessage();
+ if (response instanceof ArtifactResponse) {
+ return validateAndExtractResponseMessage((ArtifactResponse) response);
+ } else {
+ throw new MessageDecodingException("SOAP message payload was not an instance of ArtifactResponse: " + response.getClass().getName());
+ }
} catch (final SOAPException | SecurityException e) {
throw new MessageDecodingException("Error dereferencing artifact", e);
}
}
+
+ private SAMLObject validateAndExtractResponseMessage(ArtifactResponse artifactResponse) throws MessageDecodingException {
+ if (artifactResponse.getStatus() == null
+ || artifactResponse.getStatus().getStatusCode() == null
+ || artifactResponse.getStatus().getStatusCode().getValue() == null) {
+
+ log.warn("ArtifactResponse included no StatusCode, could not validate");
+
+ } else if (!StatusCode.SUCCESS.equals(artifactResponse.getStatus().getStatusCode().getValue())){
+ throw new MessageDecodingException("ArtifactResponse carried non-success StatusCode: "
+ + artifactResponse.getStatus().getStatusCode().getValue());
+ }
+
+ if (artifactResponse.getMessage() == null) {
+ throw new MessageDecodingException("ArtifactResponse carried an empty message payload");
+ }
+
+ return artifactResponse.getMessage();
+ }
/**
* @param artifact
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list