[java-opensaml] 01/06: MessageContext support for info about received endpoint of SAML message.
Brent Putman
putmanb at georgetown.edu
Fri Jan 24 23:06:06 EST 2020
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=cfcb09cbd81d1448768723d6cfdedb517e702876
commit cfcb09cbd81d1448768723d6cfdedb517e702876
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Wed Dec 11 23:02:24 2019 -0500
MessageContext support for info about received endpoint of SAML message.
---
.../saml/common/binding/SAMLBindingSupport.java | 7 ++
.../SAMLMessageReceivedEndpointContext.java | 86 ++++++++++++++++++++++
2 files changed, 93 insertions(+)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
index 5f7769b..2c52b71 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
@@ -31,6 +31,7 @@ import org.opensaml.messaging.MessageException;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.saml.common.SAMLObject;
import org.opensaml.saml.common.SignableSAMLObject;
+import org.opensaml.saml.common.messaging.context.SAMLMessageReceivedEndpointContext;
import org.opensaml.saml.common.messaging.context.SAMLBindingContext;
import org.opensaml.saml.common.messaging.context.SAMLEndpointContext;
import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
@@ -302,6 +303,12 @@ public final class SAMLBindingSupport {
throws MessageException {
Constraint.isNotNull(request, "HttpServletRequest cannot be null");
+ final SAMLMessageReceivedEndpointContext receivedEnpointContext =
+ messageContext.getSubcontext(SAMLMessageReceivedEndpointContext.class);
+ if (receivedEnpointContext != null) {
+ return receivedEnpointContext.getRequestURL();
+ }
+
return request.getRequestURL().toString();
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMessageReceivedEndpointContext.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMessageReceivedEndpointContext.java
new file mode 100644
index 0000000..5fc746d
--- /dev/null
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMessageReceivedEndpointContext.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opensaml.saml.common.messaging.context;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.servlet.http.HttpServletRequest;
+
+import org.opensaml.messaging.context.BaseContext;
+import org.opensaml.messaging.context.MessageContext;
+
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
+/**
+ * A context intended to be used as a subcontext of a {@link MessageContext} that carries
+ * some basic information about the SAML message.
+ *
+ * <p>
+ * This context is generally used to hold information about the endpoint at which a SAML message
+ * was received. In particular it is useful when the SAML message is being processed during
+ * a different HTTP request than the one in which it was actually received.
+ *
+ * </p>
+ */
+public class SAMLMessageReceivedEndpointContext extends BaseContext {
+
+ /** The request URL. */
+ private String requestURL;
+
+ /** Constructor. */
+ public SAMLMessageReceivedEndpointContext() {
+ super();
+ }
+
+ /**
+ * Constructor.
+ *
+ * <p>
+ * This is a convenient copy constructor for info from {@link HttpServletRequest}.
+ * The constructor does NOT store a reference to the request, it merely copies
+ * relevant information to the properties of this class.
+ * </p>
+ *
+ * @param request
+ */
+ public SAMLMessageReceivedEndpointContext(@Nonnull final HttpServletRequest request) {
+ super();
+ Constraint.isNotNull(request, "HttpServletRequest was null");
+ setRequestURL(request.getRequestURL().toString());
+ //TODO add and populate other fields?
+ }
+
+ /**
+ * Get the request URL.
+ *
+ * @return the request URL
+ */
+ @Nullable public String getRequestURL() {
+ return requestURL;
+ }
+
+ /**
+ * Set the request URL.
+ *
+ * @param url the request URL
+ */
+ void setRequestURL(@Nullable final String url) {
+ requestURL = url;
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list