[java-opensaml] 01/02: OSJ-175: Adjust SAML artifact APIs to use new artifact interfaces
Brent Putman
putmanb at georgetown.edu
Thu Apr 18 01:49:11 EDT 2019
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=890549722c67d9738030464e1ff6ea1a7641f69c
commit 890549722c67d9738030464e1ff6ea1a7641f69c
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Wed Apr 17 21:34:00 2019 -0400
OSJ-175: Adjust SAML artifact APIs to use new artifact interfaces
---
.../common/binding/artifact/AbstractSAMLArtifact.java | 4 ++--
.../saml1/binding/artifact/SAML1ArtifactBuilder.java | 2 +-
.../binding/artifact/SAML1ArtifactBuilderFactory.java | 4 ++--
.../saml2/binding/artifact/SAML2ArtifactBuilder.java | 2 +-
.../binding/artifact/SAML2ArtifactBuilderFactory.java | 4 ++--
.../binding/encoding/impl/HTTPArtifactEncoder.java | 9 +++++----
.../binding/encoding/impl/HTTPArtifactEncoder.java | 18 ++++++++++--------
7 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/artifact/AbstractSAMLArtifact.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/artifact/AbstractSAMLArtifact.java
index 8f12dcb..b4fdeec 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/artifact/AbstractSAMLArtifact.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/artifact/AbstractSAMLArtifact.java
@@ -105,8 +105,8 @@ public abstract class AbstractSAMLArtifact implements SAMLArtifact {
return true;
}
- if (o instanceof AbstractSAMLArtifact) {
- final AbstractSAMLArtifact otherArtifact = (AbstractSAMLArtifact) o;
+ if (o instanceof SAMLArtifact) {
+ final SAMLArtifact otherArtifact = (SAMLArtifact) o;
return Arrays.equals(getArtifactBytes(), otherArtifact.getArtifactBytes());
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactBuilder.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactBuilder.java
index c059364..6f01c9e 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactBuilder.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactBuilder.java
@@ -33,7 +33,7 @@ import org.opensaml.saml.saml1.core.Assertion;
*
* @param <ArtifactType> type of artifact built by this builder
*/
-public interface SAML1ArtifactBuilder<ArtifactType extends AbstractSAML1Artifact> {
+public interface SAML1ArtifactBuilder<ArtifactType extends SAML1Artifact> {
/**
* Builds an artifact, for the given assertion, destined for the outbound message recipient.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactBuilderFactory.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactBuilderFactory.java
index 7ab4bc4..713288c 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactBuilderFactory.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/artifact/SAML1ArtifactBuilderFactory.java
@@ -64,7 +64,7 @@ public class SAML1ArtifactBuilderFactory {
*
* @return constructed artifact
*/
- public AbstractSAML1Artifact buildArtifact(final String base64Artifact){
+ public SAML1Artifact buildArtifact(final String base64Artifact){
return buildArtifact(Base64Support.decode(base64Artifact));
}
@@ -75,7 +75,7 @@ public class SAML1ArtifactBuilderFactory {
*
* @return constructed artifact
*/
- public AbstractSAML1Artifact buildArtifact(final byte[] artifact) {
+ public SAML1Artifact buildArtifact(final byte[] artifact) {
if(artifact == null){
return null;
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactBuilder.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactBuilder.java
index 871fc8e..91127d9 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactBuilder.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactBuilder.java
@@ -32,7 +32,7 @@ import org.opensaml.saml.common.SAMLObject;
*
* @param <ArtifactType> type of artifact built by this builder
*/
-public interface SAML2ArtifactBuilder<ArtifactType extends AbstractSAML2Artifact> {
+public interface SAML2ArtifactBuilder<ArtifactType extends SAML2Artifact> {
/**
* Builds an artifact, for the given assertion, destined for the outbound message recipient.
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactBuilderFactory.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactBuilderFactory.java
index f5cef4e..54eadf4 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactBuilderFactory.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/artifact/SAML2ArtifactBuilderFactory.java
@@ -63,7 +63,7 @@ public class SAML2ArtifactBuilderFactory {
*
* @return constructed artifact
*/
- public AbstractSAML2Artifact buildArtifact(final String base64Artifact){
+ public SAML2Artifact buildArtifact(final String base64Artifact){
return buildArtifact(Base64Support.decode(base64Artifact));
}
@@ -74,7 +74,7 @@ public class SAML2ArtifactBuilderFactory {
*
* @return constructed artifact
*/
- public AbstractSAML2Artifact buildArtifact(final byte[] artifact) {
+ public SAML2Artifact buildArtifact(final byte[] artifact) {
if(artifact == null){
return null;
}
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/binding/encoding/impl/HTTPArtifactEncoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/binding/encoding/impl/HTTPArtifactEncoder.java
index 58cab5c..fa1fcb3 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/binding/encoding/impl/HTTPArtifactEncoder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml1/binding/encoding/impl/HTTPArtifactEncoder.java
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.codec.Base64Support;
import net.shibboleth.utilities.java.support.collection.Pair;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
@@ -43,7 +44,7 @@ import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
import org.opensaml.saml.common.messaging.context.SAMLSelfEntityContext;
import org.opensaml.saml.common.xml.SAMLConstants;
import org.opensaml.saml.config.SAMLConfigurationSupport;
-import org.opensaml.saml.saml1.binding.artifact.AbstractSAML1Artifact;
+import org.opensaml.saml.saml1.binding.artifact.SAML1Artifact;
import org.opensaml.saml.saml1.binding.artifact.SAML1ArtifactBuilder;
import org.opensaml.saml.saml1.binding.artifact.SAML1ArtifactType0001;
import org.opensaml.saml.saml1.core.Assertion;
@@ -161,19 +162,19 @@ public class HTTPArtifactEncoder extends BaseSAML1MessageEncoder {
}
final Response samlResponse = (Response) outboundMessage;
for (final Assertion assertion : samlResponse.getAssertions()) {
- final AbstractSAML1Artifact artifact = artifactBuilder.buildArtifact(messageContext, assertion);
+ final SAML1Artifact artifact = artifactBuilder.buildArtifact(messageContext, assertion);
if (artifact == null) {
log.error("Unable to build artifact for message to relying party {}", requester);
throw new MessageEncodingException("Unable to build artifact for message to relying party");
}
+ final String artifactString = Base64Support.encode(artifact.getArtifactBytes(), Base64Support.UNCHUNKED);
try {
- artifactMap.put(artifact.base64Encode(), requester, issuer, assertion);
+ artifactMap.put(artifactString, requester, issuer, assertion);
} catch (final IOException e) {
log.error("Unable to store assertion mapping for artifact", e);
throw new MessageEncodingException("Unable to store assertion mapping for artifact", e);
}
- final String artifactString = artifact.base64Encode();
queryParams.add(new Pair<>("SAMLart", artifactString));
}
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPArtifactEncoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPArtifactEncoder.java
index b334aa3..aa5ea2e 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPArtifactEncoder.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPArtifactEncoder.java
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.codec.Base64Support;
import net.shibboleth.utilities.java.support.codec.HTMLEncoder;
import net.shibboleth.utilities.java.support.collection.Pair;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -42,14 +43,13 @@ import org.opensaml.messaging.context.MessageContext;
import org.opensaml.messaging.encoder.MessageEncodingException;
import org.opensaml.saml.common.SAMLObject;
import org.opensaml.saml.common.binding.SAMLBindingSupport;
-import org.opensaml.saml.common.binding.artifact.AbstractSAMLArtifact;
import org.opensaml.saml.common.binding.artifact.SAMLArtifactMap;
import org.opensaml.saml.common.messaging.context.SAMLArtifactContext;
import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
import org.opensaml.saml.common.messaging.context.SAMLSelfEntityContext;
import org.opensaml.saml.common.xml.SAMLConstants;
import org.opensaml.saml.config.SAMLConfigurationSupport;
-import org.opensaml.saml.saml2.binding.artifact.AbstractSAML2Artifact;
+import org.opensaml.saml.saml2.binding.artifact.SAML2Artifact;
import org.opensaml.saml.saml2.binding.artifact.SAML2ArtifactBuilder;
import org.opensaml.saml.saml2.binding.artifact.SAML2ArtifactType0004;
import org.slf4j.Logger;
@@ -239,7 +239,8 @@ public class HTTPArtifactEncoder extends BaseSAML2MessageEncoder {
final String encodedEndpointURL = HTMLEncoder.encodeForHTMLAttribute(endpointURL);
log.debug("Setting action parameter to: '{}', encoded as '{}'", endpointURL, encodedEndpointURL);
context.put("action", encodedEndpointURL);
- context.put("SAMLArt", buildArtifact(messageContext).base64Encode());
+ context.put("SAMLArt",
+ Base64Support.encode(buildArtifact(messageContext).getArtifactBytes(), Base64Support.UNCHUNKED));
context.put("binding", getBindingURI());
final String relayState = SAMLBindingSupport.getRelayState(messageContext);
@@ -283,12 +284,13 @@ public class HTTPArtifactEncoder extends BaseSAML2MessageEncoder {
final List<Pair<String, String>> queryParams = urlBuilder.getQueryParams();
queryParams.clear();
- final AbstractSAMLArtifact artifact = buildArtifact(messageContext);
+ final SAML2Artifact artifact = buildArtifact(messageContext);
if (artifact == null) {
log.error("Unable to build artifact for message to relying party");
throw new MessageEncodingException("Unable to build artifact for message to relying party");
}
- queryParams.add(new Pair<>("SAMLart", artifact.base64Encode()));
+ queryParams.add(new Pair<>("SAMLart",
+ Base64Support.encode(artifact.getArtifactBytes(), Base64Support.UNCHUNKED)));
final String relayState = SAMLBindingSupport.getRelayState(messageContext);
if (SAMLBindingSupport.checkRelayState(relayState)) {
@@ -312,7 +314,7 @@ public class HTTPArtifactEncoder extends BaseSAML2MessageEncoder {
*
* @throws MessageEncodingException thrown if the artifact can not be created
*/
- @Nonnull protected AbstractSAML2Artifact buildArtifact(@Nonnull final MessageContext<SAMLObject> messageContext)
+ @Nonnull protected SAML2Artifact buildArtifact(@Nonnull final MessageContext<SAMLObject> messageContext)
throws MessageEncodingException {
final String requester = getInboundMessageIssuer(messageContext);
@@ -332,12 +334,12 @@ public class HTTPArtifactEncoder extends BaseSAML2MessageEncoder {
storeSAMLArtifactType(messageContext, defaultArtifactType);
}
- final AbstractSAML2Artifact artifact = artifactBuilder.buildArtifact(messageContext);
+ final SAML2Artifact artifact = artifactBuilder.buildArtifact(messageContext);
if (artifact == null) {
log.error("Unable to build artifact for message to relying party");
throw new MessageEncodingException("Unable to build artifact for message to relying party");
}
- final String encodedArtifact = artifact.base64Encode();
+ final String encodedArtifact = Base64Support.encode(artifact.getArtifactBytes(), Base64Support.UNCHUNKED);
try {
artifactMap.put(encodedArtifact, requester, issuer, messageContext.getMessage());
} catch (final IOException e) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list