[java-plugin-shibd] branch main updated: Alterations to session initiator flow and related material.

Scott Cantor cantor.2 at osu.edu
Mon Feb 10 15:10:16 UTC 2025


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=e01be2b0d6495531b606d4d0411c4ad4df92b2bc

The following commit(s) were added to refs/heads/main by this push:
     new e01be2b  Alterations to session initiator flow and related material.
e01be2b is described below

commit e01be2b0d6495531b606d4d0411c4ad4df92b2bc
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Feb 10 10:10:09 2025 -0500

    Alterations to session initiator flow and related material.
---
 .../session-initiator/session-initiator-flow.xml   |  2 +-
 .../shibboleth/sp/context/AgentRequestContext.java | 29 +++++++++++
 .../sp/messaging/RemotedHttpServletRequest.java    |  6 +--
 .../AbstractTokenConsumerResponseAction.java       |  2 +-
 .../shibboleth/sp/profile/InitiatorConstants.java  | 10 ++--
 .../{InitiatorConstants.java => SPConstants.java}  | 17 +++----
 .../sp/profile/impl/MapResourceToStateToken.java   | 56 +++++++---------------
 .../sp/profile/impl/PrepareAgentErrorResponse.java | 10 +++-
 .../impl/ValidateSessionInitiatorRequest.java      | 14 ++++--
 .../profile/impl/MapResourceToStateTokenTest.java  | 45 +++++++----------
 10 files changed, 96 insertions(+), 95 deletions(-)

diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/session-initiator/session-initiator-flow.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/session-initiator/session-initiator-flow.xml
index bd2022c..9c8ea82 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/session-initiator/session-initiator-flow.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/session-initiator/session-initiator-flow.xml
@@ -14,7 +14,7 @@
     <!-- Resume flow operation after set up by parent. -->
     <action-state id="DoApplicationOperation">
         <on-entry>
-            <evaluate expression="opensamlProfileRequestContext.ensureSubcontext(T(net.shibboleth.sp.context.AgentRequestContext)).getApplication().getSessionInitiators(opensamlProfileRequestContext).iterator()" result="flowScope.SessionInitiatorIterator" />
+            <evaluate expression="new net.shibboleth.shared.collection.ReflectionSafeIterator(opensamlProfileRequestContext.ensureSubcontext(T(net.shibboleth.sp.context.AgentRequestContext)).getApplication().getSessionInitiators(opensamlProfileRequestContext).iterator())" result="flowScope.SessionInitiatorIterator" />
         </on-entry>
         <evaluate expression="MapResourceToStateToken" />
         <evaluate expression="'proceed'" />
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/context/AgentRequestContext.java b/sp-server-api/src/main/java/net/shibboleth/sp/context/AgentRequestContext.java
index d8fcc80..dcdf3a0 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/context/AgentRequestContext.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/context/AgentRequestContext.java
@@ -40,6 +40,9 @@ public class AgentRequestContext extends BaseContext {
     /** Application for which the request was made. */
     @Nullable private Application application;
     
+    /** Tracking of resource/target URL for agent error handling purposes. */
+    @Nullable private byte[] targetURL;
+    
     /** Input message. */
     @Nullable private DDF input;
 
@@ -93,6 +96,32 @@ public class AgentRequestContext extends BaseContext {
         application = app;
         return this;
     }
+    
+    /**
+     * Get the target/resource URL associated with an agent request.
+     * 
+     * <p>This is primarily set for error handling purposes in cases where
+     * a resource has been converted into a state token and the agent wouldn't
+     * have access to it in the event of a problem.</p>
+     * 
+     * @return target URL
+     */
+    @Nullable public byte[] getTargetURL() {
+        return targetURL;
+    }
+    
+    /**
+     * Sets the target/resource URL associated with an agent request.
+     * 
+     * @param url url to set
+     * 
+     * @return this context
+     */
+    @Nonnull public AgentRequestContext setTargetURL(@Nullable final byte[] url) {
+        targetURL = url;
+        
+        return this;
+    }
 
     /**
      * Get the input message from the agent.
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequest.java b/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequest.java
index 0d85e70..3a45746 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequest.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequest.java
@@ -19,7 +19,6 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
@@ -66,7 +65,6 @@ import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.net.URISupport;
 import net.shibboleth.sp.ddf.DDF;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
 
@@ -235,7 +233,7 @@ public class RemotedHttpServletRequest implements HttpServletRequest {
                 final byte[] body = obj.getmember("body").unsafe_string();
                 if (body != null) {
                     final List<Pair<String,String>> qparams =
-                            URISupport.parseQueryString(new String(body, Charsets.UTF_8));
+                            URISupport.parseQueryString(new String(body, StandardCharsets.UTF_8));
                     for (final Pair<String,String> p : qparams) {
                         multimap.put(p.getFirst(), p.getSecond());
                     }
@@ -294,7 +292,7 @@ public class RemotedHttpServletRequest implements HttpServletRequest {
         return new BufferedReader(
                 new InputStreamReader(
                         new ByteArrayInputStream(
-                                obj.getmember(BODY).unsafe_string()), Charsets.UTF_8));
+                                obj.getmember(BODY).unsafe_string()), StandardCharsets.UTF_8));
     }
 
     /** {@inheritDoc} */
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractTokenConsumerResponseAction.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractTokenConsumerResponseAction.java
index c21112b..a3c05e9 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractTokenConsumerResponseAction.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractTokenConsumerResponseAction.java
@@ -32,7 +32,6 @@ import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.attribute.ScopedStringAttributeValue;
 import net.shibboleth.idp.attribute.StringAttributeValue;
 import net.shibboleth.idp.attribute.context.AttributeContext;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.primitive.LoggerFactory;
 import net.shibboleth.sp.context.AgentRequestContext;
@@ -184,6 +183,7 @@ public abstract class AbstractTokenConsumerResponseAction extends AbstractApplic
                 final byte[] url = ensureApplication().getStateTokenManager().recoverFromStateToken(
                         ensureAgent(), ensureApplication(), token);
                 log.debug("{} Requested resource recovered from state token: {}", getLogPrefix(), url);
+                ensureAgentRequestContext().setTargetURL(url);
                 return url;
             } catch (final IOException e) {
                 log.warn("{} Exception recovering requested resource from state token", getLogPrefix(), e);
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/InitiatorConstants.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/InitiatorConstants.java
index 2385923..a3d4f76 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/profile/InitiatorConstants.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/InitiatorConstants.java
@@ -26,13 +26,13 @@ public final class InitiatorConstants {
     /** Authority input parameter. */
     @Nonnull @NotEmpty public static final String AUTHORITY = "authority";
 
-    /** Target input parameter. */
-    @Nonnull @NotEmpty public static final String TARGET = "target";
+    /** Legacy entityID input parameter. */
+    @Nonnull @NotEmpty public static final String ENTITY_ID = "entityID";
 
-    /** State input parameter. */
-    @Nonnull @NotEmpty public static final String STATE = "state";
+    /** Handler input parameter. */
+    @Nonnull @NotEmpty public static final String HANDLER = "handler";
 
-    /** Response URL input parameter. */
+    /** Response URL input structure. */
     @Nonnull @NotEmpty public static final String RESPONSE_URL = "response_url";
 
     /** Private constructor. */
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/InitiatorConstants.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/SPConstants.java
similarity index 67%
copy from sp-server-api/src/main/java/net/shibboleth/sp/profile/InitiatorConstants.java
copy to sp-server-api/src/main/java/net/shibboleth/sp/profile/SPConstants.java
index 2385923..223713e 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/profile/InitiatorConstants.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/SPConstants.java
@@ -19,24 +19,21 @@ import javax.annotation.Nonnull;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 
 /**
- * Constants for session initiator operations.
+ * Constants for SP agent operations.
  */
-public final class InitiatorConstants {
+public final class SPConstants {
 
-    /** Authority input parameter. */
-    @Nonnull @NotEmpty public static final String AUTHORITY = "authority";
-
-    /** Target input parameter. */
+    /** Target parameter. */
     @Nonnull @NotEmpty public static final String TARGET = "target";
 
-    /** State input parameter. */
+    /** State parameter. */
     @Nonnull @NotEmpty public static final String STATE = "state";
 
-    /** Response URL input parameter. */
-    @Nonnull @NotEmpty public static final String RESPONSE_URL = "response_url";
+    /** Event parameter. */
+    @Nonnull @NotEmpty public static final String EVENT = "event";
 
     /** Private constructor. */
-    private InitiatorConstants() {
+    private SPConstants() {
         
     }
 }
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/MapResourceToStateToken.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/MapResourceToStateToken.java
index 45dc518..d5e1dbb 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/MapResourceToStateToken.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/MapResourceToStateToken.java
@@ -22,30 +22,22 @@ import org.opensaml.profile.action.EventIds;
 import org.opensaml.profile.context.ProfileRequestContext;
 import org.slf4j.Logger;
 
-import com.google.common.primitives.Bytes;
-
 import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.primitive.LoggerFactory;
 import net.shibboleth.sp.context.AgentRequestContext;
 import net.shibboleth.sp.ddf.DDF;
-import net.shibboleth.sp.messaging.RemotedHttpServletRequest;
 import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
 import net.shibboleth.sp.messaging.RemotedHttpServletResponse;
 import net.shibboleth.sp.profile.AbstractApplicationAction;
-import net.shibboleth.sp.profile.InitiatorConstants;
+import net.shibboleth.sp.profile.SPConstants;
 
 /**
- * Action that maps a requested resource URL into a state token to be consumed
- * by protocol request generation logic.
- * 
- * <p>The existence of a {@link InitiatorConstants#STATE} input parameter will cause
- * the action to be skipped, as will the absence of a {@link RemotedHttpServletRequest#STRUCTURE_NAME}
- * member with at least a {@link RemotedHttpServletRequest#REQUEST_URL} member.</p>
+ * Action that maps a target/resource URL into a state token.
  * 
- * <p>Otherwise the raw bytes of the {@link RemotedHttpServletRequest#REQUEST_URL} and
- * {@link RemotedHttpServletRequest#QUERY_STRING} members will be used to construct the
- * resource URL to build a state token for.</p>
+ * <p>The existence of a {@link SPConstants#STATE} member will cause the action
+ * to be skipped, as will the absence of a {@link SPConstants#TARGET} member to
+ * translate.</p>
  * 
  * @event {@link EventIds#PROCEED_EVENT_ID}
  */
@@ -64,7 +56,7 @@ public class MapResourceToStateToken extends AbstractApplicationAction {
     @NonnullBeforeExec private DDF input;
 
     /** Remoted request structure. */
-    @NonnullBeforeExec private DDF httpRequest;
+    @NonnullBeforeExec private byte[] target;
 
     /**
      * Sets whether to create the output {@link DDF} and {@link RemotedHttpServletResponse}.
@@ -92,17 +84,18 @@ public class MapResourceToStateToken extends AbstractApplicationAction {
             return false;
         }
         
-        if (input.getmember(InitiatorConstants.STATE).isstring()) {
-            log.debug("{} Input message already contains {} parameter", getLogPrefix(), InitiatorConstants.STATE);
+        if (input.getmember(SPConstants.STATE).isstring()) {
+            log.debug("{} Input message already contains {} parameter", getLogPrefix(), SPConstants.STATE);
             return false;
         }
         
-        httpRequest = input.getmember(RemotedHttpServletRequest.STRUCTURE_NAME);
-        if (!httpRequest.isstruct()) {
-            log.debug("{} Input message did not contain remoted HTTP request", getLogPrefix());
+        target = input.getmember(SPConstants.TARGET).unsafe_string();
+        if (target == null) {
+            log.debug("{} Input message did not contain {} member", getLogPrefix(), SPConstants.TARGET);
             return false;
         }
         
+        ensureAgentRequestContext().setTargetURL(target);
         return true;
     }
 
@@ -119,23 +112,6 @@ public class MapResourceToStateToken extends AbstractApplicationAction {
                     output.structure().addmember(RemotedHttpServletResponse.STRUCTURE_NAME)));
         }
 
-        // We have to preserve the full URL, so we don't get to just approximate it and assume
-        // a particular String encoding. So this requires operating on the underlying byte arrays from
-        // the agent, to preserve them exactly.
-        
-        byte[] requestURL = httpRequest.getmember(RemotedHttpServletRequest.REQUEST_URL).unsafe_string();
-        if (requestURL == null || requestURL.length == 0) {
-            log.warn("{} Remoted HTTP request did not contain request URL", getLogPrefix());
-            return;
-        }
-        
-        // Java method to get URL doesn't include query!?!
-        final byte[] query = httpRequest.getmember(RemotedHttpServletRequest.QUERY_STRING).unsafe_string();
-        if (query != null && query.length > 0) {
-            requestURL = Bytes.concat(requestURL, QUERY_SEPERATOR, query);
-            assert requestURL != null;
-        }
-        
         // We do the crazy stuff to accomodate cookie-backed state management.
         try {
             RemotedHttpServletRequestResponseContext.loadCurrent(agentRequestContext.getRemotedHttpServletRequest(),
@@ -143,11 +119,11 @@ public class MapResourceToStateToken extends AbstractApplicationAction {
             
             try {
                 final String token = ensureApplication().getStateTokenManager().preserveToStateToken(
-                        ensureAgent(), ensureApplication(), requestURL);
-                input.addmember(InitiatorConstants.STATE).string(token);
-                log.debug("{} Requested resource preserved to state token: {}", getLogPrefix(), token);
+                        ensureAgent(), ensureApplication(), target);
+                input.addmember(SPConstants.STATE).string(token);
+                log.debug("{} Target resource preserved to state token: {}", getLogPrefix(), token);
             } catch (final IOException e) {
-                log.warn("{} Exception preserving requested resource to state token", getLogPrefix(), e);
+                log.warn("{} Exception preserving target resource to state token", getLogPrefix(), e);
             }
         } finally {
             RemotedHttpServletRequestResponseContext.clearCurrent();
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PrepareAgentErrorResponse.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PrepareAgentErrorResponse.java
index 726674b..e06499d 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PrepareAgentErrorResponse.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PrepareAgentErrorResponse.java
@@ -28,6 +28,7 @@ import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.sp.context.AgentRequestContext;
 import net.shibboleth.sp.ddf.DDF;
 import net.shibboleth.sp.profile.AbstractAgentRequestAction;
+import net.shibboleth.sp.profile.SPConstants;
 
 /**
  * A profile action to encode the current event (typically an error) into an agent response in a
@@ -75,9 +76,14 @@ public class PrepareAgentErrorResponse extends AbstractAgentRequestAction {
         final Object event = eventCtx != null ? eventCtx.getEvent() : null;
         if (event != null) {
             final String eventString = event.toString();
-            output.addmember("event").string(eventString);
+            output.addmember(SPConstants.EVENT).string(eventString);
         } else {
-            output.addmember("event").string(EventIds.MESSAGE_PROC_ERROR);
+            output.addmember(SPConstants.EVENT).string(EventIds.MESSAGE_PROC_ERROR);
+        }
+        
+        final byte[] target = ensureAgentRequestContext().getTargetURL();
+        if (target != null) {
+            output.addmember(SPConstants.TARGET).unsafe_string(target);
         }
     }
 
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ValidateSessionInitiatorRequest.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ValidateSessionInitiatorRequest.java
index 03d92f2..df978be 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ValidateSessionInitiatorRequest.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ValidateSessionInitiatorRequest.java
@@ -41,8 +41,8 @@ import net.shibboleth.shared.logic.Constraint;
  * <p>The authority ID is potentially supplied by the agent in the request, or may be defaulted
  * based on the {@link Application}.</p>
  * 
- * <p>In rare cases (mainly SAML ECP), it is not strictly required that the ID be known in advance,
- * so this is confgurable to allow session initiator flows to indicate via wiring how to handle
+ * <p>Since it is not always required that the ID be known in advance (e.g., discovery flows, ECP),
+ * this is confgurable to allow session initiator flows to indicate via wiring how to handle
  * this case.</p>
  * 
  * <p>The input message is also validated to ensure any other required inputs are available.</p>
@@ -114,19 +114,23 @@ public class ValidateSessionInitiatorRequest extends AbstractApplicationAction {
             return false;
         }
         
-        if (!input.getmember(InitiatorConstants.RESPONSE_URL).isstring()) {
+        if (!input.getmember(InitiatorConstants.RESPONSE_URL).isstring() &&
+                !input.getmember(InitiatorConstants.RESPONSE_URL).islist()) {
             ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
-            log.error("{} Missing required input: {}", getLogPrefix(), InitiatorConstants.RESPONSE_URL);
+            log.error("{} Missing or invalid required input: {}", getLogPrefix(), InitiatorConstants.RESPONSE_URL);
             return false;
         }
 
         relyingPartyId = input.getmember(InitiatorConstants.AUTHORITY).string();
+        if (relyingPartyId == null) {
+            relyingPartyId = input.getmember(InitiatorConstants.ENTITY_ID).string();
+        }
         if (relyingPartyId == null) {
             log.debug("{} Request did not specify authority to use, falling back to Application default",
                     getLogPrefix());
             relyingPartyId = ensureApplication().getAuthenticatingAuthority(profileRequestContext);
         }
-        
+                
         if (relyingPartyId == null && requireRelyingPartyId) {
             ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
             log.error("{} Authenticating authority unknown", getLogPrefix());
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/MapResourceToStateTokenTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/MapResourceToStateTokenTest.java
index 62d0861..7b297cc 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/MapResourceToStateTokenTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/MapResourceToStateTokenTest.java
@@ -15,6 +15,7 @@
 package net.shibboleth.sp.profile.impl;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.time.Duration;
 
 import javax.annotation.Nonnull;
@@ -28,8 +29,6 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import com.google.common.primitives.Bytes;
-
 import net.shibboleth.idp.profile.testing.ActionTestingSupport;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.codec.Base64Support;
@@ -40,8 +39,7 @@ import net.shibboleth.sp.ddf.DDF;
 import net.shibboleth.sp.impl.CookieStateTokenManager;
 import net.shibboleth.sp.impl.PassthroughStateTokenManager;
 import net.shibboleth.sp.impl.StorageServiceStateTokenManager;
-import net.shibboleth.sp.messaging.RemotedHttpServletRequest;
-import net.shibboleth.sp.profile.InitiatorConstants;
+import net.shibboleth.sp.profile.SPConstants;
 
 /**
  * Unit test for {@link MapResourceToStateToken} action.
@@ -53,7 +51,7 @@ public class MapResourceToStateTokenTest extends BaseAgplicationActionTest {
     @Nonnull @NotEmpty private final static String TEST_URL = "https://sp.example.org/cgi-bin/test.cgi";
 
     /** Test query string. */
-    @Nonnull @NotEmpty private final static String TEST_QUERY = "foo=bar%20baz&frobnitz=zorkmid";
+    @Nonnull @NotEmpty private final static String TEST_QUERY = TEST_URL + "?foo=bar%20baz&frobnitz=zorkmid";
 
     private MapResourceToStateToken action;
         
@@ -79,26 +77,26 @@ public class MapResourceToStateTokenTest extends BaseAgplicationActionTest {
     }
 
     @Test
-    public void testNoRequest() {
+    public void testNoTarget() {
         final DDF input = new DDF(null).structure();
         arc.setInput(input);
         
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
         
-        Assert.assertNull(input.getmember(InitiatorConstants.STATE).string());
+        Assert.assertNull(input.getmember(SPConstants.STATE).string());
     }
 
     @Test
     public void testStateExists() {
         final DDF input = new DDF(null).structure();
-        input.addmember(InitiatorConstants.STATE).string("foo");
+        input.addmember(SPConstants.STATE).string("foo");
         arc.setInput(input);
         
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
         
-        Assert.assertEquals(input.getmember(InitiatorConstants.STATE).string(), "foo");
+        Assert.assertEquals(input.getmember(SPConstants.STATE).string(), "foo");
     }
 
     @Test
@@ -112,14 +110,13 @@ public class MapResourceToStateTokenTest extends BaseAgplicationActionTest {
         application.initialize();
         
         final DDF input = new DDF(null).structure();
-        final DDF httpreq = input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME);
-        httpreq.addmember(RemotedHttpServletRequest.REQUEST_URL).unsafe_string(TEST_URL.getBytes());
+        input.addmember(SPConstants.TARGET).unsafe_string(TEST_URL.getBytes(StandardCharsets.UTF_8));
         arc.setInput(input);
 
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
         
-        final String token = input.getmember(InitiatorConstants.STATE).string();
+        final String token = input.getmember(SPConstants.STATE).string();
         assert token != null;
         
         Assert.assertEquals(Base64Support.decodeURLSafe(token), TEST_URL.getBytes());
@@ -136,20 +133,16 @@ public class MapResourceToStateTokenTest extends BaseAgplicationActionTest {
         application.initialize();
         
         final DDF input = new DDF(null).structure();
-        final DDF httpreq = input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME);
-        httpreq.addmember(RemotedHttpServletRequest.REQUEST_URL).unsafe_string(TEST_URL.getBytes());
-        httpreq.addmember(RemotedHttpServletRequest.QUERY_STRING).unsafe_string(TEST_QUERY.getBytes());
+        input.addmember(SPConstants.TARGET).unsafe_string(TEST_QUERY.getBytes());
         arc.setInput(input);
 
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
         
-        final String token = input.getmember(InitiatorConstants.STATE).string();
+        final String token = input.getmember(SPConstants.STATE).string();
         assert token != null;
         
-        Assert.assertEquals(
-                Base64Support.decodeURLSafe(token),
-                Bytes.concat(TEST_URL.getBytes(), MapResourceToStateToken.QUERY_SEPERATOR, TEST_QUERY.getBytes()));
+        Assert.assertEquals(Base64Support.decodeURLSafe(token), TEST_QUERY.getBytes(StandardCharsets.UTF_8));
     }
 
     @Test
@@ -169,18 +162,17 @@ public class MapResourceToStateTokenTest extends BaseAgplicationActionTest {
         application.initialize();
         
         final DDF input = new DDF(null).structure();
-        final DDF httpreq = input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME);
-        httpreq.addmember(RemotedHttpServletRequest.REQUEST_URL).unsafe_string(TEST_URL.getBytes());
+        input.addmember(SPConstants.TARGET).unsafe_string(TEST_URL.getBytes(StandardCharsets.UTF_8));
         arc.setInput(input);
 
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
         
-        final String token = input.getmember(InitiatorConstants.STATE).string();
+        final String token = input.getmember(SPConstants.STATE).string();
         assert token != null;
         
         final byte[] value = manager.recoverFromStateToken(agent, application, token);
-        Assert.assertEquals(value, TEST_URL.getBytes());
+        Assert.assertEquals(value, TEST_URL.getBytes(StandardCharsets.UTF_8));
     }
     
     @Test
@@ -199,20 +191,19 @@ public class MapResourceToStateTokenTest extends BaseAgplicationActionTest {
         application.initialize();
         
         final DDF input = new DDF(null).structure();
-        final DDF httpreq = input.addmember(RemotedHttpServletRequest.STRUCTURE_NAME);
-        httpreq.addmember(RemotedHttpServletRequest.REQUEST_URL).unsafe_string(TEST_URL.getBytes());
+        input.addmember(SPConstants.TARGET).unsafe_string(TEST_URL.getBytes(StandardCharsets.UTF_8));
         arc.setInput(input);
 
         final Event event = action.execute(src);
         ActionTestingSupport.assertProceedEvent(event);
         
-        final String token = input.getmember(InitiatorConstants.STATE).string();
+        final String token = input.getmember(SPConstants.STATE).string();
         assert token != null;
         
         request.setCookies(response.getCookies());
         
         final byte[] value = manager.recoverFromStateToken(agent, application, token);
-        Assert.assertEquals(value, TEST_URL.getBytes());
+        Assert.assertEquals(value, TEST_URL.getBytes(StandardCharsets.UTF_8));
     }
 
 }
\ 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