[java-plugin-shibd] branch main updated: Relocate some classes, WIP on token consumer response generation.

Scott Cantor cantor.2 at osu.edu
Tue Sep 17 20:28:43 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=f1077d4a333a9fab3a218ebd45701dff7df13de7

The following commit(s) were added to refs/heads/main by this push:
     new f1077d4  Relocate some classes, WIP on token consumer response generation.
f1077d4 is described below

commit f1077d4a333a9fab3a218ebd45701dff7df13de7
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Sep 17 16:28:40 2024 -0400

    Relocate some classes, WIP on token consumer response generation.
---
 .../src/main/java/net/shibboleth/sp/ddf/DDF.java   |  38 ++--
 .../RemotedHttpServletRequestResponseContext.java  |   5 +-
 .../sp/messaging/RemotedHttpServletResponse.java   |  12 +-
 .../AbstractTokenConsumerResponseAction.java       | 197 +++++++++++++++++++++
 .../shibboleth/sp/profile/ConsumerConstants.java   |  36 ++++
 .../impl/RemotedHttpServletRequestSupplier.java    |   1 +
 .../impl/RemotedlHttpServletResponseSupplier.java  |   1 +
 .../shibboleth/sp/profile/impl/DecodeMessage.java  |   2 +-
 .../shibboleth/sp/profile/impl/EncodeMessage.java  |   2 +-
 .../sp/profile/impl/MapResourceToStateToken.java   |  11 +-
 .../sp/profile/impl/SelectTokenConsumerFlow.java   |   2 +-
 11 files changed, 274 insertions(+), 33 deletions(-)

diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/ddf/DDF.java b/sp-server-api/src/main/java/net/shibboleth/sp/ddf/DDF.java
index fc51abd..3eeb160 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/ddf/DDF.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/ddf/DDF.java
@@ -18,6 +18,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -1348,7 +1349,7 @@ public class DDF implements Iterable<DDF> {
     @Nonnull public OutputStream serialize(@Nonnull final OutputStream os) throws IOException {
         if (!isnull()) {
             if (name != null) {
-                encode(os, name.getBytes("UTF8"));
+                encode(os, name.getBytes(StandardCharsets.UTF_8));
             } else {
                 os.write('.');
             }
@@ -1357,22 +1358,22 @@ public class DDF implements Iterable<DDF> {
             switch (type) {
                 case DDF_EMPTY:
                 case DDF_POINTER:
-                    os.write(Integer.toString(DDFType.DDF_EMPTY.getValue()).getBytes("UTF8"));
+                    os.write(Integer.toString(DDFType.DDF_EMPTY.getValue()).getBytes(StandardCharsets.UTF_8));
                     os.write('\n');
                     break;
 
                 case DDF_STRING:
-                    os.write(Integer.toString(type.getValue()).getBytes("UTF8"));
+                    os.write(Integer.toString(type.getValue()).getBytes(StandardCharsets.UTF_8));
                     if (value != null) {
                         os.write(' ');
                         assert value instanceof String;
-                        encode(os, ((String) value).getBytes("UTF-8"));
+                        encode(os, ((String) value).getBytes(StandardCharsets.UTF_8));
                     }
                     os.write('\n');
                     break;
 
                 case DDF_STRING_UNSAFE:
-                    os.write(Integer.toString(type.getValue()).getBytes("UTF8"));
+                    os.write(Integer.toString(type.getValue()).getBytes(StandardCharsets.UTF_8));
                     if (value != null) {
                         os.write(' ');
                         assert value instanceof byte[];
@@ -1382,26 +1383,26 @@ public class DDF implements Iterable<DDF> {
                     break;
 
                 case DDF_INT:
-                    os.write(Integer.toString(type.getValue()).getBytes("UTF8"));
+                    os.write(Integer.toString(type.getValue()).getBytes(StandardCharsets.UTF_8));
                     os.write(' ');
                     assert value instanceof Integer;
-                    os.write(Integer.toString((Integer) value).getBytes("UTF8"));
+                    os.write(Integer.toString((Integer) value).getBytes(StandardCharsets.UTF_8));
                     os.write('\n');
                     break;
 
                 case DDF_LONG:
-                    os.write(Integer.toString(type.getValue()).getBytes("UTF8"));
+                    os.write(Integer.toString(type.getValue()).getBytes(StandardCharsets.UTF_8));
                     os.write(' ');
                     assert value instanceof Long;
-                    os.write(Long.toString((Long) value).getBytes("UTF8"));
+                    os.write(Long.toString((Long) value).getBytes(StandardCharsets.UTF_8));
                     os.write('\n');
                     break;
 
                 case DDF_FLOAT:
-                    os.write(Integer.toString(type.getValue()).getBytes("UTF8"));
+                    os.write(Integer.toString(type.getValue()).getBytes(StandardCharsets.UTF_8));
                     os.write(' ');
                     assert value instanceof Double;
-                    os.write(Double.toString((Double) value).getBytes("UTF8"));
+                    os.write(Double.toString((Double) value).getBytes(StandardCharsets.UTF_8));
                     os.write('\n');
                     break;
 
@@ -1409,9 +1410,9 @@ public class DDF implements Iterable<DDF> {
                     assert value instanceof Map;
                     @SuppressWarnings("unchecked")
                     final Collection<DDF> members = ((Map<String,DDF>) value).values();
-                    os.write(Integer.toString(type.getValue()).getBytes("UTF8"));
+                    os.write(Integer.toString(type.getValue()).getBytes(StandardCharsets.UTF_8));
                     os.write(' ');
-                    os.write(Integer.toString(members.size()).getBytes("UTF8"));
+                    os.write(Integer.toString(members.size()).getBytes(StandardCharsets.UTF_8));
                     os.write('\n');
                     for (final DDF child : members) {
                         child.serialize(os);
@@ -1422,9 +1423,9 @@ public class DDF implements Iterable<DDF> {
                     assert value instanceof List;
                     @SuppressWarnings("unchecked")
                     final Collection<DDF> children = (List<DDF>) value;
-                    os.write(Integer.toString(type.getValue()).getBytes("UTF8"));
+                    os.write(Integer.toString(type.getValue()).getBytes(StandardCharsets.UTF_8));
                     os.write(' ');
-                    os.write(Integer.toString(children.size()).getBytes("UTF8"));
+                    os.write(Integer.toString(children.size()).getBytes(StandardCharsets.UTF_8));
                     os.write('\n');
                     for (final DDF child : children) {
                         child.serialize(os);
@@ -1482,7 +1483,7 @@ public class DDF implements Iterable<DDF> {
             // The name is stipulated to be UTF-8 safe so any high order ASCII characters are
             // assumed to be part of a multi-byte sequence.
             try {
-                obj.name(URLDecoder.decode(name, "UTF-8"));
+                obj.name(URLDecoder.decode(name, StandardCharsets.UTF_8));
             } catch (final IllegalArgumentException e) {
                 throw new IOException(e);
             }
@@ -1543,13 +1544,14 @@ public class DDF implements Iterable<DDF> {
                 try {
                     if (type == DDFType.DDF_STRING) {
                         // String values are handled as UTF-8.
-                        return obj.string(URLDecoder.decode(valueBuilder.toString(), "UTF-8"));
+                        return obj.string(URLDecoder.decode(valueBuilder.toString(), StandardCharsets.UTF_8));
                     }
                     
                     // Unsafe string values are processed as ISO-8859-1.
                     // They may be anything, but it will guarantee a single byte encoding.
                     return obj.unsafe_string(
-                            URLDecoder.decode(valueBuilder.toString(), "ISO-8859-1").getBytes("ISO-8859-1"));
+                            URLDecoder.decode(valueBuilder.toString(), StandardCharsets.ISO_8859_1).getBytes(
+                                    StandardCharsets.ISO_8859_1));
                     
                 } catch (final IllegalArgumentException e) {
                     throw new IOException(e);
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestResponseContext.java b/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequestResponseContext.java
similarity index 94%
rename from sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestResponseContext.java
rename to sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequestResponseContext.java
index 875df96..5730213 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestResponseContext.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletRequestResponseContext.java
@@ -12,14 +12,11 @@
  * limitations under the License.
  */
 
-package net.shibboleth.sp.messaging.impl;
+package net.shibboleth.sp.messaging;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import net.shibboleth.sp.messaging.RemotedHttpServletRequest;
-import net.shibboleth.sp.messaging.RemotedHttpServletResponse;
-
 /**
  * Class which holds and makes available the indirected HTTP servlet request and response via ThreadLocal storage.
  * 
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletResponse.java b/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletResponse.java
index bada40d..05e8d02 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletResponse.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/messaging/RemotedHttpServletResponse.java
@@ -17,6 +17,7 @@ package net.shibboleth.sp.messaging;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.time.Instant;
 import java.util.ArrayList;
@@ -238,12 +239,21 @@ public class RemotedHttpServletResponse implements HttpServletResponse {
 
     /** {@inheritDoc} */
     public void sendRedirect(final String location) throws IOException {
+        sendRedirect(location.getBytes(StandardCharsets.UTF_8));
+    }
+
+    /**
+     * Issues a redirect recongizing as Java does not that URLs are not in fact Unicode-safe.
+     * 
+     * @param location raw location bytes
+     */
+    public void sendRedirect(final byte[] location) {
         if (committed) {
             throw new IllegalStateException("Response already committed");
         }
 
         obj.getmember("response").remove();
-        obj.addmember("redirect").string(location);
+        obj.addmember("redirect").unsafe_string(location);
         committed = true;
         outputStream = null;
     }
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
new file mode 100644
index 0000000..893d2c0
--- /dev/null
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/AbstractTokenConsumerResponseAction.java
@@ -0,0 +1,197 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
+import org.opensaml.profile.action.EventIds;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
+
+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;
+import net.shibboleth.sp.ddf.DDF;
+import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
+import net.shibboleth.sp.messaging.RemotedHttpServletResponse;
+
+/**
+ * Base class for protocol-specific "token consumer" flow actions that prepare the
+ * response for the agent when completing processing.
+ * 
+ * <p>This class operates on the principle that most of the output of a consumer flow
+ * consists of an {@link AttributeContext} containing the data making up the results
+ * together with opaque data that accompanies the results in order to allow the agent
+ * to store and return any protocol-specific data needed for subsequent operations,
+ * primarily logout.</p>
+ * 
+ * <p>Subclasses are responsible for carrying out certain tasks that will be protocol-
+ * specific, such as accessing protocol state needed to recover the original resource.</p>
+ * 
+ * <p>The agent response will generally contain an HTTP response structure capturing a
+ * redirect to the recovered URL, the serialized attribute data, and the opaque session
+ * data.</p>
+ * 
+ * @event {@link EventIds#PROCEED_EVENT_ID}
+ */
+public abstract class AbstractTokenConsumerResponseAction extends AbstractApplicationAction {
+
+    /** Static byte array with query string separator. */
+    @Nonnull @NotEmpty public static byte[] QUERY_SEPERATOR = {'?'};
+    
+    /** Class logger. */
+    @Nonnull private Logger log = LoggerFactory.getLogger(AbstractTokenConsumerResponseAction.class);
+
+    /** Strategy used to locate {@link AttributeContext} with results. */
+    @Nonnull private Function<ProfileRequestContext,AttributeContext> attributeContextLookupStrategy;
+
+    /** Constructor. */
+    public AbstractTokenConsumerResponseAction() {
+        attributeContextLookupStrategy = new ChildContextLookup<>(AttributeContext.class);
+    }
+
+    /**
+     * Set the strategy used to locate the {@link AttributeContext} with the results.
+     * 
+     * @param strategy lookup strategy
+     */
+    public void setAttributeContextLookupStrategy(
+            @Nonnull final Function<ProfileRequestContext,AttributeContext> strategy) {
+        checkSetterPreconditions();
+        attributeContextLookupStrategy =
+                Constraint.isNotNull(strategy, "AttributeContext lookup strategy cannot be null");
+    }
+    
+    /** {@inheritDoc} */
+    @Override
+    protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+        if (!super.doPreExecute(profileRequestContext)) {
+            return false;
+        }
+        
+        final DDF input = ensureAgentRequestContext().getInput();
+        if (input == null) {
+            log.debug("{} Input message was absent", getLogPrefix());
+            return true;
+        }
+        
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
+        
+        final AgentRequestContext agentRequestContext = ensureAgentRequestContext();
+        
+        DDF output = agentRequestContext.getOutput();
+        if (output == null) {
+            output = new DDF(null).structure();
+            agentRequestContext.setOutput(output);
+        }
+        
+        DDF httpResponse = output.getmember(RemotedHttpServletResponse.STRUCTURE_NAME);
+        if (!httpResponse.isstruct() || agentRequestContext.getRemotedHttpServletResponse() == null) {
+            httpResponse = output.addmember(RemotedHttpServletResponse.STRUCTURE_NAME);
+            agentRequestContext.setRemotedHttpServletResponse(new RemotedHttpServletResponse(httpResponse));
+        }
+        
+        final byte[] resource = recoverState(profileRequestContext, agentRequestContext);
+        
+        final AttributeContext attributeContext = attributeContextLookupStrategy.apply(profileRequestContext);
+        if (attributeContext != null) {
+            final DDF attrlist = output.getmember(ConsumerConstants.SESSION_ATTRIBUTES).list();
+            attributeContext.getIdPAttributes().forEach((id, attr) -> {
+                final DDF obj = new DDF(id).list();
+                // TODO values
+                attrlist.add(obj);
+            });
+        } else {
+            log.debug("{} No AttributeContext found", getLogPrefix());
+        }
+        
+        final String sessionData = getSessionData(profileRequestContext);
+        if (sessionData != null) {
+            output.addmember(ConsumerConstants.SESSION_OPAQUE).string(sessionData);
+        }
+        
+        final RemotedHttpServletResponse remotedResponse = agentRequestContext.getRemotedHttpServletResponse();
+        assert remotedResponse != null;
+        remotedResponse.sendRedirect(resource);
+    }
+    
+    /**
+     * Access protocol state token and recover the original resource URL in raw form.
+     * 
+     * @param profileRequestContext profile request context
+     * @param agentRequestContext agent request context
+     * 
+     * @return original URL if available
+     */
+    @Nullable protected byte[] recoverState(@Nonnull final ProfileRequestContext profileRequestContext,
+            @Nonnull final AgentRequestContext agentRequestContext) {
+        
+        final String token = getStateToken(profileRequestContext);
+        if (token == null) {
+            log.debug("{} No state token found in protocol layer", getLogPrefix());
+            return null;
+        }
+        
+        // We do the wacky wrapping to accomodate cookie-backed state.
+        try {
+            RemotedHttpServletRequestResponseContext.loadCurrent(agentRequestContext.getRemotedHttpServletRequest(),
+                    agentRequestContext.getRemotedHttpServletResponse());
+            
+            try {
+                final byte[] url = ensureApplication().getStateTokenManager().recoverFromStateToken(
+                        ensureAgent(), ensureApplication(), token);
+                log.debug("{} Requested resource recovered from state token: {}", getLogPrefix(), url);
+                return url;
+            } catch (final IOException e) {
+                log.warn("{} Exception recovering requested resource from state token", getLogPrefix(), e);
+            }
+        } finally {
+            RemotedHttpServletRequestResponseContext.clearCurrent();
+        }
+        
+        return null;
+    }
+
+    /**
+     * Get the state token from the protocol response.
+     * 
+     * @param profileRequestContext profile request context
+     * 
+     * @return state token (prior to recovery)
+     */
+    @Nullable protected abstract String getStateToken(@Nonnull final ProfileRequestContext profileRequestContext);
+ 
+    /**
+     * Get the opaque session data that the agent should bind to any session it creates for later use.
+     * 
+     * @param profileRequestContext profile request context
+     * 
+     * @return opaque session data suitable for transport as Unicode data
+     */
+    @Nullable protected abstract String getSessionData(@Nonnull final ProfileRequestContext profileRequestContext);
+
+}
\ No newline at end of file
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/ConsumerConstants.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/ConsumerConstants.java
new file mode 100644
index 0000000..f3aa694
--- /dev/null
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/ConsumerConstants.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+
+/**
+ * Constants for token consumer operations.
+ */
+public final class ConsumerConstants {
+
+    /** Opaque session data member. */
+    @Nonnull @NotEmpty public static final String SESSION_OPAQUE = "session.opaque";
+
+    /** Session attributes data member. */
+    @Nonnull @NotEmpty public static final String SESSION_ATTRIBUTES = "session.attributes";
+
+    /** Private constructor. */
+    private ConsumerConstants() {
+        
+    }
+}
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestSupplier.java b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestSupplier.java
index 58e2612..6f8a48c 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestSupplier.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedHttpServletRequestSupplier.java
@@ -20,6 +20,7 @@ import javax.annotation.concurrent.NotThreadSafe;
 import jakarta.servlet.http.HttpServletRequest;
 import net.shibboleth.shared.primitive.NonnullSupplier;
 import net.shibboleth.sp.messaging.RemotedHttpServletRequest;
+import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
 
 /**
  * An implementation of {@link NonnullSupplier} which looks up the current thread-local
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedlHttpServletResponseSupplier.java b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedlHttpServletResponseSupplier.java
index 23874d1..08af455 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedlHttpServletResponseSupplier.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/messaging/impl/RemotedlHttpServletResponseSupplier.java
@@ -19,6 +19,7 @@ import javax.annotation.concurrent.NotThreadSafe;
 
 import jakarta.servlet.http.HttpServletResponse;
 import net.shibboleth.shared.primitive.NonnullSupplier;
+import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
 import net.shibboleth.sp.messaging.RemotedHttpServletResponse;
 
 /**
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DecodeMessage.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DecodeMessage.java
index 4af2e60..bf5c03e 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DecodeMessage.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DecodeMessage.java
@@ -21,7 +21,7 @@ import org.opensaml.profile.context.ProfileRequestContext;
 
 import net.shibboleth.sp.context.AgentRequestContext;
 import net.shibboleth.sp.messaging.RemotedHttpServletRequest;
-import net.shibboleth.sp.messaging.impl.RemotedHttpServletRequestResponseContext;
+import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
 
 /**
  * Subclass of OpenSAML {@link DecodeMessage} action that wraps the execute step to
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/EncodeMessage.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/EncodeMessage.java
index 2186a81..d1df271 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/EncodeMessage.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/EncodeMessage.java
@@ -21,8 +21,8 @@ import org.opensaml.profile.context.ProfileRequestContext;
 
 import net.shibboleth.sp.context.AgentRequestContext;
 import net.shibboleth.sp.ddf.DDF;
+import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
 import net.shibboleth.sp.messaging.RemotedHttpServletResponse;
-import net.shibboleth.sp.messaging.impl.RemotedHttpServletRequestResponseContext;
 
 /**
  * Subclass of OpenSAML {@link EncodeMessage} action that wraps the execute step to
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 e4f71da..45dc518 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
@@ -30,8 +30,8 @@ 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.messaging.impl.RemotedHttpServletRequestResponseContext;
 import net.shibboleth.sp.profile.AbstractApplicationAction;
 import net.shibboleth.sp.profile.InitiatorConstants;
 
@@ -59,9 +59,6 @@ public class MapResourceToStateToken extends AbstractApplicationAction {
     
     /** Whether to create the output objects into which the message will be encoded. */
     private boolean createOutputObjects;
-    
-    /** Cached request context. */
-    @NonnullBeforeExec private AgentRequestContext agentRequestContext;
 
     /** Agent input. */
     @NonnullBeforeExec private DDF input;
@@ -89,9 +86,7 @@ public class MapResourceToStateToken extends AbstractApplicationAction {
             return false;
         }
         
-        agentRequestContext = profileRequestContext.ensureSubcontext(AgentRequestContext.class);
-        
-        input = agentRequestContext.getInput();
+        input = ensureAgentRequestContext().getInput();
         if (input == null) {
             log.debug("{} Input message was absent", getLogPrefix());
             return false;
@@ -115,6 +110,8 @@ public class MapResourceToStateToken extends AbstractApplicationAction {
     @Override
     protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
         
+        final AgentRequestContext agentRequestContext = ensureAgentRequestContext();
+        
         if (createOutputObjects && agentRequestContext.getOutput() == null) {
             final DDF output = new DDF(null);
             agentRequestContext.setOutput(output);
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/SelectTokenConsumerFlow.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/SelectTokenConsumerFlow.java
index 4d88c81..fe1928c 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/SelectTokenConsumerFlow.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/SelectTokenConsumerFlow.java
@@ -30,7 +30,7 @@ import org.slf4j.Logger;
 import net.shibboleth.idp.authn.AuthnEventIds;
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.primitive.LoggerFactory;
-import net.shibboleth.sp.messaging.impl.RemotedHttpServletRequestResponseContext;
+import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
 import net.shibboleth.sp.profile.AbstractApplicationAction;
 import net.shibboleth.sp.profile.TokenConsumerFlowDescriptor;
 

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


More information about the commits mailing list