[java-plugin-shibd] branch main updated: Work on message decoding stages.

Scott Cantor cantor.2 at osu.edu
Tue May 28 14:08:41 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=16ffab60caf3525712da2f21f6954564e0df31bf

The following commit(s) were added to refs/heads/main by this push:
     new 16ffab6  Work on message decoding stages.
16ffab6 is described below

commit 16ffab60caf3525712da2f21f6954564e0df31bf
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue May 28 10:08:36 2024 -0400

    Work on message decoding stages.
---
 .../idp/flows/sp/abstract/sp-abstract-beans.xml    |  2 +
 .../idp/flows/sp/abstract/sp-abstract-flow.xml     | 39 +++++++++++++++-
 .../sp/messaging/impl/DDFMessageDecoder.java       |  2 +-
 .../messaging/impl}/RemotedHttpServletRequest.java |  3 +-
 .../impl}/RemotedHttpServletResponse.java          |  3 +-
 .../shibboleth/sp/messaging/impl/package-info.java |  2 +-
 .../impl/InitializeOutboundMessageContext.java     | 54 ++++++++++++++++++++++
 .../{messaging => profile}/impl/package-info.java  |  4 +-
 .../impl}/RemotedHttpServletRequestTest.java       |  4 +-
 .../impl}/RemotedHttpServletResponseTest.java      |  4 +-
 10 files changed, 108 insertions(+), 9 deletions(-)

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 c881815..ca93b24 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
@@ -70,6 +70,8 @@
         </constructor-arg>
     </bean>
 
+    <bean id="InitializeOutboundMessageContext"
+        class="net.shibboleth.sp.profile.impl.InitializeOutboundMessageContext" scope="prototype" />
 
     <!-- ======== Beans for agent authentication ======== -->
 
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-flow.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-flow.xml
index 59f678b..11dbaf4 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-flow.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/abstract/sp-abstract-flow.xml
@@ -28,9 +28,46 @@
     
     <action-state id="DecodeMessage">
         <evaluate expression="DecodeMessage" />
+        <evaluate expression="InitializeOutboundMessageContext" />
         <evaluate expression="'proceed'" />
 
-        <transition on="proceed" to="TBD" />
+        <transition on="proceed" to="DoOperation" />
+    </action-state>
+
+    <!--
+    The meat will be inserted here by defining DoOperation and transitioning
+    from there to work activity and eventually to the final stages below.
+    -->
+
+    <!-- Post Processing / Encode -->
+
+    <!--
+    These actions handle errors by routing to the catch-all end-state, because
+    it's assumed that any error here is unrecoverable.
+    -->
+
+    <!-- Pick back up with outbound side. -->
+
+    <action-state id="HandleOutboundMessage">
+        <evaluate expression="EncodeMessage" />
+        <evaluate expression="RecordResponseComplete" />
+        <evaluate expression="'proceed'" />
+        
+        <transition to="end" />
+        
+        <exception-handler bean="RethrowingFlowExecutionExceptionHandler"/>
+    </action-state>
+
+    <action-state id="HandleError">
+        <on-entry>
+            <evaluate expression="opensamlProfileRequestContext.ensureSubcontext(T(net.shibboleth.idp.profile.context.SpringRequestContext)).setRequestContext(flowRequestContext)" />
+            <evaluate expression="LogEvent" />
+        </on-entry>
+        <evaluate expression="'proceed'" />
+        
+        <transition on="proceed" to="HandleOutboundMessage" />
+        
+        <exception-handler bean="RethrowingFlowExecutionExceptionHandler"/>
     </action-state>
 
     <!-- Passthrough state if an exception is thrown. -->
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
index 342f023..b4a4d7a 100644
--- 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
@@ -52,7 +52,7 @@ public class DDFMessageDecoder extends AbstractHttpServletRequestMessageDecoder
             throw new MessageDecodingException("Content-Type was unsupported");
         }
 
-        try (final InputStream in = getHttpServletRequest().getInputStream()) {
+        try (final InputStream in = request.getInputStream()) {
             assert in != null;
             final DDF msg = DDF.deserialize(in);
             final MessageContext messageContext = new MessageContext();
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/ddf/RemotedHttpServletRequest.java b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequest.java
similarity index 99%
rename from sp-server-api/src/main/java/net/shibboleth/sp/ddf/RemotedHttpServletRequest.java
rename to sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequest.java
index eb628fb..8e0a92c 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/ddf/RemotedHttpServletRequest.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequest.java
@@ -12,7 +12,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.sp.ddf;
+package net.shibboleth.sp.messaging.impl;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -62,6 +62,7 @@ import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.collection.Pair;
 import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.net.URISupport;
+import net.shibboleth.sp.ddf.DDF;
 
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/ddf/RemotedHttpServletResponse.java b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletResponse.java
similarity index 99%
rename from sp-server-api/src/main/java/net/shibboleth/sp/ddf/RemotedHttpServletResponse.java
rename to sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletResponse.java
index 6bbf95a..39672c0 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/ddf/RemotedHttpServletResponse.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletResponse.java
@@ -12,7 +12,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.sp.ddf;
+package net.shibboleth.sp.messaging.impl;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -37,6 +37,7 @@ import jakarta.servlet.http.HttpServletResponse;
 import net.shibboleth.shared.annotation.constraint.NonnullElements;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.sp.ddf.DDF;
 
 
 /**
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
index 7615b53..a6b7d01 100644
--- 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
@@ -13,7 +13,7 @@
  */
 
 /**
- * Classes implementing messaging interfaces for SP remoting.
+ * Classes implementing messaging interfaces and handlers for SP remoting.
  */
 @NonnullElements
 package net.shibboleth.sp.messaging.impl;
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/InitializeOutboundMessageContext.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/InitializeOutboundMessageContext.java
new file mode 100644
index 0000000..fd815d9
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/InitializeOutboundMessageContext.java
@@ -0,0 +1,54 @@
+/*
+ * 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.profile.impl;
+
+import javax.annotation.Nonnull;
+
+import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.profile.action.EventIds;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
+
+import net.shibboleth.idp.profile.AbstractProfileAction;
+import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.sp.ddf.DDF;
+
+/**
+ * Action that adds an outbound {@link MessageContext} and an empty {@link DDF} message to a
+ * {@link ProfileRequestContext}.
+ * 
+ * @event {@link EventIds#PROCEED_EVENT_ID}
+ * @post <pre>ProfileRequestContext.ensureOutboundMessageContext().getMessage() instanceof DDF</pre>
+ */
+public class InitializeOutboundMessageContext extends AbstractProfileAction {
+
+    /** Class logger. */
+    @Nonnull private final Logger log = LoggerFactory.getLogger(InitializeOutboundMessageContext.class);
+
+    /** Constructor. */
+    public InitializeOutboundMessageContext() {
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+
+        final MessageContext msgCtx = new MessageContext();
+        msgCtx.setMessage(new DDF());
+        profileRequestContext.setOutboundMessageContext(msgCtx);
+
+        log.debug("{} Initialized outbound message context", getLogPrefix());
+    }
+
+}
\ 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/profile/impl/package-info.java
similarity index 86%
copy from sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/package-info.java
copy to sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/package-info.java
index 7615b53..87cf3ad 100644
--- 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/profile/impl/package-info.java
@@ -13,9 +13,9 @@
  */
 
 /**
- * Classes implementing messaging interfaces for SP remoting.
+ * Classes implementing profile actions for SP remoting.
  */
 @NonnullElements
-package net.shibboleth.sp.messaging.impl;
+package net.shibboleth.sp.profile.impl;
 
 import net.shibboleth.shared.annotation.constraint.NonnullElements;
diff --git a/sp-server-api/src/test/java/net/shibboleth/sp/ddf/RemotedHttpServletRequestTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestTest.java
similarity index 97%
rename from sp-server-api/src/test/java/net/shibboleth/sp/ddf/RemotedHttpServletRequestTest.java
rename to sp-server-impl/src/test/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestTest.java
index 2fd13b0..3559fa9 100644
--- a/sp-server-api/src/test/java/net/shibboleth/sp/ddf/RemotedHttpServletRequestTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestTest.java
@@ -12,7 +12,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.sp.ddf;
+package net.shibboleth.sp.messaging.impl;
 
 import static org.testng.Assert.*;
 
@@ -20,6 +20,8 @@ import java.io.IOException;
 import java.util.List;
 
 import jakarta.servlet.http.Cookie;
+import net.shibboleth.sp.ddf.DDF;
+import net.shibboleth.sp.messaging.impl.RemotedHttpServletRequest;
 
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
diff --git a/sp-server-api/src/test/java/net/shibboleth/sp/ddf/RemotedHttpServletResponseTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletResponseTest.java
similarity index 97%
rename from sp-server-api/src/test/java/net/shibboleth/sp/ddf/RemotedHttpServletResponseTest.java
rename to sp-server-impl/src/test/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletResponseTest.java
index c3ac481..79dc3eb 100644
--- a/sp-server-api/src/test/java/net/shibboleth/sp/ddf/RemotedHttpServletResponseTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletResponseTest.java
@@ -12,7 +12,7 @@
  * limitations under the License.
  */
 
-package net.shibboleth.sp.ddf;
+package net.shibboleth.sp.messaging.impl;
 
 import static org.testng.Assert.*;
 
@@ -23,6 +23,8 @@ import java.time.Instant;
 import java.util.Set;
 
 import jakarta.servlet.http.Cookie;
+import net.shibboleth.sp.ddf.DDF;
+import net.shibboleth.sp.messaging.impl.RemotedHttpServletResponse;
 
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list