[java-opensaml] branch main updated: Move basic ECP decoding and PAOS encoding into OpenSAML.
Codeberg
noreply at shibboleth.net
Tue Nov 17 20:12:16 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-opensaml.
View the commit online:
https://codeberg.org/Shibboleth/java-opensaml/commit/5861d9bc868979e38d97c6a3f026649310424b3c
The following commit(s) were added to refs/heads/main by this push:
new 5861d9bc8 Move basic ECP decoding and PAOS encoding into OpenSAML.
5861d9bc8 is described below
commit 5861d9bc868979e38d97c6a3f026649310424b3c
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Nov 17 15:11:53 2026 -0500
Move basic ECP decoding and PAOS encoding into OpenSAML.
---
.../opensaml/saml/common/xml/SAMLConstants.java | 7 +
.../binding/decoding/impl/HTTPECPDecoder.java | 166 +++++++++++++++++++++
.../binding/encoding/impl/HTTPPAOSEncoder.java | 45 ++++++
3 files changed, 218 insertions(+)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLConstants.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLConstants.java
index a5fed74e4..4aee78053 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLConstants.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/xml/SAMLConstants.java
@@ -75,6 +75,13 @@ public final class SAMLConstants {
/** Liberty PAOS QName prefix. */
@Nonnull @NotEmpty public static final String PAOS_PREFIX = "paos";
+ /**
+ * PAOS media type for ECP client requests.
+ *
+ * @since 5.3.0
+ */
+ @Nonnull @NotEmpty public static final String PAOS_MEDIA_TYPE = "application/vnd.paos+xml";
+
// ****************************
// SAML 1.X
// ****************************
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPECPDecoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPECPDecoder.java
new file mode 100644
index 000000000..45d1f04db
--- /dev/null
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/decoding/impl/HTTPECPDecoder.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed 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.saml2.binding.decoding.impl;
+
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.messaging.decoder.MessageDecodingException;
+import org.opensaml.messaging.handler.MessageHandler;
+import org.opensaml.saml.common.SAMLObject;
+import org.opensaml.saml.common.binding.BindingDescriptor;
+import org.opensaml.saml.common.binding.SAMLBindingSupport;
+import org.opensaml.saml.common.binding.decoding.SAMLMessageDecoder;
+import org.opensaml.saml.common.binding.impl.SAMLSOAPDecoderBodyHandler;
+import org.opensaml.saml.common.messaging.context.SAMLBindingContext;
+import org.opensaml.saml.common.xml.SAMLConstants;
+import org.opensaml.saml.saml2.ecp.RelayState;
+import org.opensaml.soap.messaging.context.SOAP11Context;
+import org.opensaml.soap.soap11.Envelope;
+import org.opensaml.soap.soap11.Header;
+import org.slf4j.Logger;
+
+import jakarta.servlet.http.HttpServletRequest;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.primitive.LoggerFactory;
+
+/**
+ * SAML 2.0 ECP/PAOS Decoder.
+ *
+ * @since 5.3.0
+ */
+public class HTTPECPDecoder extends org.opensaml.soap.soap11.decoder.http.impl.HTTPSOAP11Decoder
+ implements SAMLMessageDecoder {
+
+ /** Class logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(HTTPECPDecoder.class);
+
+ /** Optional {@link BindingDescriptor} to inject into {@link SAMLBindingContext} created. */
+ @Nullable private BindingDescriptor bindingDescriptor;
+
+ /** Constructor. */
+ public HTTPECPDecoder() {
+ setProtocolMessageLoggerSubCategory("SAML");
+ }
+
+ /** {@inheritDoc} */
+ @Nonnull @NotEmpty public String getBindingURI() {
+ return SAMLConstants.SAML2_PAOS_BINDING_URI;
+ }
+
+ /**
+ * Get an optional {@link BindingDescriptor} to inject into {@link SAMLBindingContext} created.
+ *
+ * @return binding descriptor
+ */
+ @Nullable public BindingDescriptor getBindingDescriptor() {
+ return bindingDescriptor;
+ }
+
+ /**
+ * Set an optional {@link BindingDescriptor} to inject into {@link SAMLBindingContext} created.
+ *
+ * @param descriptor a binding descriptor
+ */
+ public void setBindingDescriptor(@Nullable final BindingDescriptor descriptor) {
+ bindingDescriptor = descriptor;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+
+ // Need to set this before calling base class.
+ if (getBodyHandler() == null) {
+ final MessageHandler handler = new SAMLSOAPDecoderBodyHandler();
+ handler.initialize();
+ setBodyHandler(handler);
+ }
+
+ super.doInitialize();
+ }
+
+ /** {@inheritDoc} */
+ protected void doDecode() throws MessageDecodingException {
+ super.doDecode();
+
+ final MessageContext msgCtx = getMessageContext();
+ assert msgCtx != null;
+
+ populateBindingContext(msgCtx);
+
+ processSOAPHeaders(msgCtx);
+
+ final Object samlMessage = msgCtx.getMessage();
+ if (samlMessage instanceof SAMLObject) {
+ log.debug("Decoded SOAP message which included SAML message of type {}",
+ ((SAMLObject) samlMessage).getElementQName());
+ } else {
+ throw new MessageDecodingException("Decoded SOAP message did not contain SAMLObject");
+ }
+ }
+
+ /**
+ * Populate the context which carries information specific to this binding.
+ *
+ * @param messageContext the current message context
+ */
+ protected void populateBindingContext(@Nonnull final MessageContext messageContext) {
+ final SAMLBindingContext bindingContext = messageContext.ensureSubcontext(SAMLBindingContext.class);
+ bindingContext.setBindingUri(getBindingURI());
+ bindingContext.setBindingDescriptor(bindingDescriptor);
+ bindingContext.setHasBindingSignature(false);
+ bindingContext.setIntendedDestinationEndpointURIRequired(true);
+ }
+
+ /**
+ * Process ECP/PAOS headers.
+ *
+ * @param messageContext message context
+ */
+ protected void processSOAPHeaders(@Nonnull final MessageContext messageContext) {
+ final SOAP11Context soapContext = messageContext.ensureSubcontext(SOAP11Context.class);
+ final Envelope env = soapContext.getEnvelope();
+ final Header header = env != null ? env.getHeader() : null;
+ if (header != null) {
+ final List<XMLObject> relayState = header.getUnknownXMLObjects(RelayState.DEFAULT_ELEMENT_NAME);
+ if (relayState != null && relayState.size() > 0) {
+ SAMLBindingSupport.setRelayState(messageContext, ((RelayState) relayState.get(0)).getValue());
+ }
+
+ // We're ignoring the PAOS Response header if it exists, as the correlation at the SAML layer is
+ // applied later.
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void validateHttpRequest(@Nonnull final HttpServletRequest request) throws MessageDecodingException {
+
+ // Replace usual SOAP type check.
+ if (!SAMLConstants.PAOS_MEDIA_TYPE.equals(request.getContentType())) {
+ log.warn("Saw unsupported request Content-Type: {}", request.getContentType());
+ throw new MessageDecodingException(
+ String.format("Content-Type '%s' was not a supported media type", request.getContentType()));
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPPAOSEncoder.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPPAOSEncoder.java
new file mode 100644
index 000000000..2ef344860
--- /dev/null
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/binding/encoding/impl/HTTPPAOSEncoder.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed 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.saml2.binding.encoding.impl;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.saml.common.binding.encoding.SAMLMessageEncoder;
+import org.opensaml.saml.common.xml.SAMLConstants;
+
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+
+/**
+ * SAML 2.0 PAOS Encoder.
+ *
+ * <p>This is just a very thin extension of the vanilla SOAP encoder.</p>
+ *
+ * @since 5.3.0
+ */
+public class HTTPPAOSEncoder extends HTTPSOAP11Encoder
+ implements SAMLMessageEncoder {
+
+ /** Constructor. */
+ public HTTPPAOSEncoder() {
+ setProtocolMessageLoggerSubCategory("SAML");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ @Nonnull @NotEmpty public String getBindingURI() {
+ return SAMLConstants.SAML2_PAOS_BINDING_URI;
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list