[java-plugin-shibd] branch main updated: DDF message decoder.
Scott Cantor
cantor.2 at osu.edu
Thu May 23 19:56:12 UTC 2024
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-plugin-shibd.
View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd.git;a=commit;h=0f2d5d8153abc62fcd346d824954ff563021acb0
The following commit(s) were added to refs/heads/main by this push:
new 0f2d5d8 DDF message decoder.
0f2d5d8 is described below
commit 0f2d5d8153abc62fcd346d824954ff563021acb0
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu May 23 15:56:09 2024 -0400
DDF message decoder.
---
.../idp/flows/sp/abstract/sp-abstract-beans.xml | 9 +++
.../sp/messaging/impl/DDFMessageDecoder.java | 66 ++++++++++++++++++++++
.../shibboleth/sp/messaging/impl/package-info.java | 21 +++++++
3 files changed, 96 insertions(+)
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-beans.xml
index bf5d804..c881815 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-beans.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-beans.xml
@@ -62,6 +62,15 @@
<bean id="DefaultCleanupHook"
class="net.shibboleth.idp.authn.impl.ValidateCredentials.UsernamePasswordCleanupHook" />
+ <bean id="DecodeMessage" class="org.opensaml.profile.action.impl.DecodeMessage" scope="prototype"
+ p:messageType="net.shibboleth.sp.ddf.DDF">
+ <constructor-arg>
+ <bean class="net.shibboleth.sp.messaging.impl.DDFMessageDecoder" scope="prototype"
+ p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" />
+ </constructor-arg>
+ </bean>
+
+
<!-- ======== Beans for agent authentication ======== -->
<util:list id="DefaultAgentValidators">
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/DDFMessageDecoder.java b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/DDFMessageDecoder.java
new file mode 100644
index 0000000..342f023
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/DDFMessageDecoder.java
@@ -0,0 +1,66 @@
+/*
+ * 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 net.shibboleth.sp.messaging.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.messaging.decoder.MessageDecoder;
+import org.opensaml.messaging.decoder.MessageDecodingException;
+import org.opensaml.messaging.decoder.servlet.AbstractHttpServletRequestMessageDecoder;
+
+import jakarta.servlet.http.HttpServletRequest;
+import net.shibboleth.sp.ddf.DDF;
+
+/**
+ * {@link MessageDecoder} to process DDF request bodies in supported formats.
+ *
+ * <p>The MIME type in the request is used to deermine what form of parsing and deserialization
+ * to use.</p>
+ *
+ * <p>The only supported type at present is a custom type representing a record-oriented
+ * syntax.</p>
+ */
+public class DDFMessageDecoder extends AbstractHttpServletRequestMessageDecoder {
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doDecode() throws MessageDecodingException {
+
+ final HttpServletRequest request = getHttpServletRequest();
+ if (!"POST".equalsIgnoreCase(request.getMethod())) {
+ throw new MessageDecodingException("This message decoder only supports the HTTP POST method");
+ }
+
+ final String contentType = request.getContentType();
+ if (contentType == null) {
+ throw new MessageDecodingException("Content-Type header not present in request");
+ } else if (!contentType.equals("text/plain")) {
+ throw new MessageDecodingException("Content-Type was unsupported");
+ }
+
+ try (final InputStream in = getHttpServletRequest().getInputStream()) {
+ assert in != null;
+ final DDF msg = DDF.deserialize(in);
+ final MessageContext messageContext = new MessageContext();
+ messageContext.setMessage(msg);
+ setMessageContext(messageContext);
+ } catch (final IOException e) {
+ throw new MessageDecodingException("Unable to obtain input stream from HttpServletRequest", e);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/package-info.java b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/package-info.java
new file mode 100644
index 0000000..7615b53
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Classes implementing messaging interfaces for SP remoting.
+ */
+ at NonnullElements
+package net.shibboleth.sp.messaging.impl;
+
+import net.shibboleth.shared.annotation.constraint.NonnullElements;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list