[java-plugin-shibd] branch dev/StateMgmtWIP updated: Various cleanup, bug fixing, adjusting cookie prefixes.

Codeberg noreply at shibboleth.net
Tue Apr 28 15:17:39 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch dev/StateMgmtWIP
in repository java-plugin-shibd.

View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd/commit/bbd6d319ff65317a7935bedf9bbbd449f7adb661

The following commit(s) were added to refs/heads/dev/StateMgmtWIP by this push:
     new bbd6d31  Various cleanup, bug fixing, adjusting cookie prefixes.
bbd6d31 is described below

commit bbd6d319ff65317a7935bedf9bbbd449f7adb661
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Apr 28 11:17:15 2026 -0400

    Various cleanup, bug fixing, adjusting cookie prefixes.
---
 .../idp/flows/sp/initiator/initiator-beans.xml     |  5 +--
 .../sp/logout-initiator/logout-initiator-beans.xml |  6 ----
 .../sp/logout-initiator/logout-initiator-flow.xml  |  1 -
 .../flows/sp/logout/initiator/initiator-beans.xml  | 11 ------
 .../shibboleth/idp/module/conf/sp/sp.properties    |  7 ++--
 .../net/shibboleth/sp/conf/agents-system.xml       |  4 +--
 .../sp/flows/LogoutInitiatorFlowTest.java          | 19 ----------
 .../sp/profile/PreserveStateDataAction.java        |  1 +
 .../shibboleth/sp/state/AbstractStateManager.java  | 12 ++++---
 .../sp/profile/impl/PreservePostData.java          | 22 +++++++++---
 .../sp/state/impl/CookieStateManager.java          | 40 +++++++++++++++-------
 .../sp/state/impl/StorageServiceStateManager.java  | 10 +++---
 .../sp/profile/impl/PreservePostDataTest.java      |  8 ++---
 .../sp/state/impl/CookieStateManagerTest.java      |  6 ++--
 .../state/impl/StorageServiceStateManagerTest.java |  6 ++--
 15 files changed, 72 insertions(+), 86 deletions(-)

diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/initiator/initiator-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/initiator/initiator-beans.xml
index 85815b8..b2c3f71 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/initiator/initiator-beans.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/initiator/initiator-beans.xml
@@ -7,15 +7,12 @@
                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
     default-init-method="initialize" default-destroy-method="destroy">
 
-    <bean id="shibboleth.sp.profileId" class="java.lang.String" c:_0="http://shibboleth.net/ns/profiles/sp/session-initiator" />
-    <bean id="shibboleth.sp.loggingId" class="java.lang.String" c:_0="%{sp.service.logging.initiator:SPAgent.SessionInitiator}" />
-
     <bean id="PreservePostData"
         class="net.shibboleth.sp.profile.impl.PreservePostData" scope="prototype"
         p:errorFatal="%{sp.postData.errorsFatal:false}"
         p:lifetime="%{sp.postData.lifetime:PT15M}"
         p:storageService-ref="#{'%{sp.postData.StorageService:shibboleth.StorageService}'.trim()}"
         p:cookieManager-ref="shibboleth.sp.RemotedCookieManager"
-        p:cookiePrefix="#{'%{sp.postData.cookiePrefix:__Host-shibsp_post_}'.trim()}" />
+        p:cookiePrefix="#{'%{sp.postData.cookiePrefix:__Host-shibsp_post}'.trim()}" />
     
 </beans>
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout-initiator/logout-initiator-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout-initiator/logout-initiator-beans.xml
index f197e34..330ceac 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout-initiator/logout-initiator-beans.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout-initiator/logout-initiator-beans.xml
@@ -10,10 +10,4 @@
     <bean id="shibboleth.sp.profileId" class="java.lang.String" c:_0="http://shibboleth.net/ns/profiles/sp/session-initiator" />
     <bean id="shibboleth.sp.loggingId" class="java.lang.String" c:_0="%{sp.service.logging.initiator:SPAgent.SessionInitiator}" />
 
-    <bean id="MapResourceToStateToken" 
-        class="net.shibboleth.sp.profile.impl.MapResourceToStateToken" scope="prototype"
-        p:createOutputObjects="true"
-        p:targetRequired="false"
-        p:errorFatal="%{sp.stateToken.errorsFatal:false}" />
-        
 </beans>
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout-initiator/logout-initiator-flow.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout-initiator/logout-initiator-flow.xml
index b9da789..3cfff81 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout-initiator/logout-initiator-flow.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout-initiator/logout-initiator-flow.xml
@@ -16,7 +16,6 @@
         <on-entry>
             <evaluate expression="new net.shibboleth.shared.collection.ReflectionSafeIterator(opensamlProfileRequestContext.ensureSubcontext(T(net.shibboleth.sp.context.AgentRequestContext)).getApplication().getLogoutInitiators(opensamlProfileRequestContext).iterator())" result="flowScope.LogoutInitiatorIterator" />
         </on-entry>
-        <evaluate expression="MapResourceToStateToken" />
         <evaluate expression="'proceed'" />
         
         <!-- Branch to child flow for actual work. -->
diff --git a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout/initiator/initiator-beans.xml b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout/initiator/initiator-beans.xml
index 85815b8..8aae2de 100644
--- a/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout/initiator/initiator-beans.xml
+++ b/sp-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/sp/logout/initiator/initiator-beans.xml
@@ -6,16 +6,5 @@
                            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
     default-init-method="initialize" default-destroy-method="destroy">
-
-    <bean id="shibboleth.sp.profileId" class="java.lang.String" c:_0="http://shibboleth.net/ns/profiles/sp/session-initiator" />
-    <bean id="shibboleth.sp.loggingId" class="java.lang.String" c:_0="%{sp.service.logging.initiator:SPAgent.SessionInitiator}" />
-
-    <bean id="PreservePostData"
-        class="net.shibboleth.sp.profile.impl.PreservePostData" scope="prototype"
-        p:errorFatal="%{sp.postData.errorsFatal:false}"
-        p:lifetime="%{sp.postData.lifetime:PT15M}"
-        p:storageService-ref="#{'%{sp.postData.StorageService:shibboleth.StorageService}'.trim()}"
-        p:cookieManager-ref="shibboleth.sp.RemotedCookieManager"
-        p:cookiePrefix="#{'%{sp.postData.cookiePrefix:__Host-shibsp_post_}'.trim()}" />
     
 </beans>
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
index cf09a9f..377f5e8 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
@@ -30,7 +30,7 @@ sp.service.agents.checkInterval = PT5M
 # Controls storage back-end for storage-based state tokens
 #sp.stateToken.StorageService = shibboleth.StorageService
 # Cookie prefix when using cookie-backed state
-#sp.stateToken.cookiePrefix = __Host-shibsp_state_
+#sp.stateToken.cookiePrefix = __Host-shibsp_state
 # Lifetime to preserve state before discarding
 #sp.stateToken.lifetime = PT30M
 # Whether to seal/encrypt data stored by state manager
@@ -38,14 +38,11 @@ sp.service.agents.checkInterval = PT5M
 # Whether to check for replay of state tokens
 #sp.stateToken.checkReplay = false
 
-# Request/response correlation control
-#sp.correlation.cookiePrefix = __Host-shibsp_req_
-
 # POST data preservation controls
 #sp.postData.preservation = false
 #sp.postData.limit = 1048576
 #sp.postData.lifetime = PT5M
-#sp.postData.cookiePrefix = __Host-shibsp_post_
+#sp.postData.cookiePrefix = __Host-shibsp_post
 #sp.postData.StorageService = shibboleth.StorageService
 #sp.postData.errorsFatal = false
 
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
index 5669657..590e1ed 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
@@ -84,12 +84,12 @@
     <bean id="shibboleth.sp.StorageAndCookieStateManager" parent="shibboleth.sp.StorageOnlyStateManager"
         class="net.shibboleth.sp.state.impl.StorageServiceStateManager" lazy-init="true"
         p:cookieManager-ref="shibboleth.sp.RemotedCookieManager"
-        p:cookiePrefix="#{'%{sp.stateToken.cookiePrefix:__Host-shibsp_state_}'.trim()}" />
+        p:cookiePrefix="#{'%{sp.stateToken.cookiePrefix:__Host-shibsp_state}'.trim()}" />
 
     <bean id="shibboleth.sp.CookieStateManager" parent="shibboleth.sp.StateManager"
         class="net.shibboleth.sp.state.impl.CookieStateManager" lazy-init="true"
         p:cookieManager-ref="shibboleth.sp.RemotedCookieManager"
-        p:cookiePrefix="#{'%{sp.stateToken.cookiePrefix:__Host-shibsp_state_}'.trim()}" />
+        p:cookiePrefix="#{'%{sp.stateToken.cookiePrefix:__Host-shibsp_state}'.trim()}" />
 
     <!-- More traditional beans akin to IdP service. -->
 
diff --git a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/LogoutInitiatorFlowTest.java b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/LogoutInitiatorFlowTest.java
index a01df5c..5ca64af 100644
--- a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/LogoutInitiatorFlowTest.java
+++ b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/LogoutInitiatorFlowTest.java
@@ -92,23 +92,4 @@ public class LogoutInitiatorFlowTest extends AbstractSPFlowTest {
         assertOutputMessageEvent(result, AuthnEventIds.NO_POTENTIAL_FLOW);
     }
 
-    
-    /**
-     * Test flow with no initiator subflows installed.
-     * @throws IOException 
-     */
-    @Test
-    public void testNoFlowsNoTarget() throws IOException {
-        setDefaultAuth();
-        
-        final DDF input = new DDF(null).structure();
-        input.addmember(SPConstants.APPLICATION).string(APPLICATION_ID);
-        setRequest("POST", input);
-
-        final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
-        assertFlowExecutionResult(result, FLOW_ID);
-        assertFlowExecutionOutcome(result.getOutcome());
-        assertOutputMessageEvent(result, AuthnEventIds.NO_POTENTIAL_FLOW);
-    }
-
 }
\ No newline at end of file
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/PreserveStateDataAction.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/PreserveStateDataAction.java
index d0fcd0c..076d558 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/profile/PreserveStateDataAction.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/PreserveStateDataAction.java
@@ -138,6 +138,7 @@ public class PreserveStateDataAction extends AbstractApplicationAction {
                 final String token = ensureApplication().getStateManager().preserveToStateToken(
                         ensureAgent(), ensureApplication(), data);
                 stateDataContext.setStateToken(token);
+                processToken(profileRequestContext, token);
                 log.debug("{} State data preserved to token: {}", getLogPrefix(), token);
             } catch (final IOException e) {
                 log.warn("{} Exception preserving state data", getLogPrefix(), e);
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/state/AbstractStateManager.java b/sp-server-api/src/main/java/net/shibboleth/sp/state/AbstractStateManager.java
index 4cba0e6..3cac4ab 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/state/AbstractStateManager.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/state/AbstractStateManager.java
@@ -214,9 +214,9 @@ public abstract class AbstractStateManager extends AbstractIdentifiableInitializ
             if (localDataSealer != null) {
                 log.debug("State data will be sealed before preservation");
                 return doPreserve(agent, application, localDataSealer.wrap(serializedState,
-                        Instant.now().plus(expiration)));
+                        Instant.now().plus(expiration)), true);
             } else {
-                return doPreserve(agent, application, serializedState);
+                return doPreserve(agent, application, serializedState, false);
             }
         } catch (final JsonProcessingException | DataSealerException e) {
             throw new IOException("Error preserving state", e);
@@ -238,7 +238,7 @@ public abstract class AbstractStateManager extends AbstractIdentifiableInitializ
             }
         }
         
-        String data = doRecover(agent, application, token);
+        String data = doRecover(agent, application, token, dataSealer != null);
         if (data == null) {
             return null;
         }
@@ -281,13 +281,14 @@ public abstract class AbstractStateManager extends AbstractIdentifiableInitializ
      * @param agent agent owning the state
      * @param application application owning the state
      * @param data data to preserve
+     * @param sealed whether the data was sealed (and thus base64-encoded)
      * 
      * @return the state token
      * 
      * @throws IOException if an error occurs
      */
     @Nonnull protected abstract String doPreserve(@Nonnull final Agent agent, @Nonnull final Application application,
-            @Nonnull final String data) throws IOException;
+            @Nonnull final String data, final boolean sealed) throws IOException;
 
     /**
      * Subclasses implement this method to recover the stored data in whatever way is necessary and return
@@ -301,13 +302,14 @@ public abstract class AbstractStateManager extends AbstractIdentifiableInitializ
      * @param agent agent owning the state
      * @param application application owning the state
      * @param stateToken the state token to map from/clear
+     * @param sealed whether the data was sealed (and thus base64-encoded)
      * 
      * @return the recovered data, or null if unable to recover without underlying cause
      * 
      * @throws IOException if an error occurs
      */
     @Nullable protected abstract String doRecover(@Nonnull final Agent agent, @Nonnull final Application application,
-            @Nonnull @NotEmpty final String stateToken) throws IOException;
+            @Nonnull @NotEmpty final String stateToken, final boolean sealed) throws IOException;
     
     /**
      * Generate a state token.
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PreservePostData.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PreservePostData.java
index 5a523d1..097a12f 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PreservePostData.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/PreservePostData.java
@@ -71,7 +71,7 @@ import net.shibboleth.sp.profile.SPConstants;
 public class PreservePostData extends AbstractApplicationAction {
     
     /** Default cookie prefix. */
-    @Nonnull @NotEmpty static public String DEFAULT_COOKIE_PREFIX = "_shibsp_post_";
+    @Nonnull @NotEmpty static public String DEFAULT_COOKIE_PREFIX = "_shibsp_post";
     
     /** Class logger. */
     @Nonnull private Logger log = LoggerFactory.getLogger(PreservePostData.class);
@@ -295,8 +295,7 @@ public class PreservePostData extends AbstractApplicationAction {
             }
 
             // Save off cookie. Name is decorated with state token prefix, value is the storage key.
-            final Escaper escaper = UrlEscapers.urlFormParameterEscaper();
-            cookieManager.addCookie(cookiePrefix + escaper.escape(stateToken), escaper.escape(key));
+            cookieManager.addCookie(getCookieName(stateToken), UrlEscapers.urlFormParameterEscaper().escape(key));
             
         } catch (final IOException e) {
             log.error("{} Error creating storage record for POST data", getLogPrefix(), e);
@@ -375,7 +374,7 @@ public class PreservePostData extends AbstractApplicationAction {
                     agentRequestContext.getRemotedHttpServletResponse());
          
             // Check for cookie to get storage key.
-            final String key = cookieManager.getCookieValue(cookiePrefix + previousStateToken, null);
+            final String key = cookieManager.getCookieValue(getCookieName(previousStateToken), null);
             if (key == null) {
                 log.debug("{} No recovery cookie for state token {}, skipping POST recovery", getLogPrefix(),
                         previousStateToken);
@@ -383,7 +382,7 @@ public class PreservePostData extends AbstractApplicationAction {
             }
             
             // Unset the cookie.
-            cookieManager.unsetCookie(cookiePrefix + previousStateToken);
+            cookieManager.unsetCookie(getCookieName(previousStateToken));
             
             // Try and read/delete the storage record.
             
@@ -410,4 +409,17 @@ public class PreservePostData extends AbstractApplicationAction {
         return null;
     }
     
+    /**
+     * Computes the cookie name based on the configured prefix and state token.
+     * 
+     * <p>Package private access for unit tests.</p>
+     * 
+     * @param stateToken the state token
+     * 
+     * @return the cookie name
+     */
+    @Nonnull String getCookieName(@Nonnull final String stateToken) {
+        return cookiePrefix + '_' + UrlEscapers.urlFormParameterEscaper().escape(stateToken);
+    }
+    
 }
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/state/impl/CookieStateManager.java b/sp-server-impl/src/main/java/net/shibboleth/sp/state/impl/CookieStateManager.java
index 5753412..3735c75 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/state/impl/CookieStateManager.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/state/impl/CookieStateManager.java
@@ -25,6 +25,8 @@ import javax.annotation.Nullable;
 
 import org.slf4j.Logger;
 
+import com.google.common.net.UrlEscapers;
+
 import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.codec.Base64Support;
@@ -112,7 +114,7 @@ public class CookieStateManager extends AbstractStateManager {
     /** {@inheritDoc} */
     @Override
     @Nonnull protected String doPreserve(@Nonnull final Agent agent, @Nonnull final Application application,
-            @Nonnull final String data) throws IOException {
+            @Nonnull final String data, final boolean sealed) throws IOException {
         
         cookieManager.purgeStaleCookies(cookiePrefix);
         
@@ -121,11 +123,17 @@ public class CookieStateManager extends AbstractStateManager {
         
         final String key = Long.toString(ts.toEpochMilli()) + '_' + generateToken();
         final String name = getCookieName(application, key);
-        try {
-            cookieManager.addCookie(name, Base64Support.encodeURLSafe(data.getBytes(StandardCharsets.UTF_8)),
+        
+        if (sealed) {
+            cookieManager.addCookie(name, UrlEscapers.urlFormParameterEscaper().escape(data),
                     (int) getExpiration().toSeconds());
-        } catch (final EncodingException e) {
-            throw new IOException(e);
+        } else {
+            try {
+                cookieManager.addCookie(name, Base64Support.encodeURLSafe(data.getBytes(StandardCharsets.UTF_8)),
+                        (int) getExpiration().toSeconds());
+            } catch (final EncodingException e) {
+                throw new IOException(e);
+            }
         }
 
         log.trace("Created state token mapping from '{}' to value '{}'", name, data);
@@ -136,20 +144,26 @@ public class CookieStateManager extends AbstractStateManager {
     /** {@inheritDoc} */
     @Override
     @Nullable protected String doRecover(@Nonnull final Agent agent, @Nonnull final Application application,
-            @Nonnull @NotEmpty final String stateToken) throws IOException {
+            @Nonnull @NotEmpty final String stateToken, final boolean sealed) throws IOException {
         
         final String cookieName = getCookieName(application, stateToken);
         final String cookieValue = cookieManager.getCookieValue(cookieName, null);
 
         if (cookieValue != null) {
             cookieManager.unsetCookie(cookieName);
-            try {
-                final String decoded = new String(Base64Support.decodeURLSafe(cookieValue), StandardCharsets.UTF_8);
-                log.trace("Recovered state token mapping from '{}' to value '{}'", stateToken, decoded);
-                return decoded;
-            } catch (final DecodingException e) {
-                throw new IOException(e);
+
+            final String decoded;
+            if (sealed) {
+                decoded = UrlEscapers.urlFormParameterEscaper().escape(cookieValue);
+            } else {
+                try {
+                    decoded = new String(Base64Support.decodeURLSafe(cookieValue), StandardCharsets.UTF_8);
+                    return decoded;
+                } catch (final DecodingException e) {
+                    throw new IOException(e);
+                }
             }
+            log.trace("Recovered state token mapping from '{}' to value '{}'", stateToken, decoded);
         }
 
         log.warn("No cookie found matching state token: '{}'", stateToken);
@@ -171,7 +185,7 @@ public class CookieStateManager extends AbstractStateManager {
         
         final StringBuilder builder = new StringBuilder(cookiePrefix);
         builder.append('_')
-            .append(application.getId())
+            .append(application.getApplicationId())
             .append('_')
             .append(uniquePortion);
         
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/state/impl/StorageServiceStateManager.java b/sp-server-impl/src/main/java/net/shibboleth/sp/state/impl/StorageServiceStateManager.java
index 59858f7..96ba264 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/state/impl/StorageServiceStateManager.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/state/impl/StorageServiceStateManager.java
@@ -121,7 +121,7 @@ public class StorageServiceStateManager extends AbstractStateManager {
     /** {@inheritDoc} */
     @Override
     @Nonnull protected String doPreserve(@Nonnull final Agent agent, @Nonnull final Application application,
-            @Nonnull final String data) throws IOException {
+            @Nonnull final String data, final boolean sealed) throws IOException {
         
         final String context = getContext(agent, application);
         final String key = generateToken();
@@ -130,7 +130,7 @@ public class StorageServiceStateManager extends AbstractStateManager {
         
         String encoded;
         try {
-            encoded = getDataSealer() != null ? data : Base64Support.encode(data.getBytes(StandardCharsets.UTF_8), false);
+            encoded = sealed ? data : Base64Support.encode(data.getBytes(StandardCharsets.UTF_8), false);
         } catch (final EncodingException e) {
             throw new IOException(e);
         }
@@ -164,7 +164,7 @@ public class StorageServiceStateManager extends AbstractStateManager {
     /** {@inheritDoc} */
     @Override
     @Nullable protected String doRecover(@Nonnull final Agent agent, @Nonnull final Application application,
-            @Nonnull @NotEmpty final String stateToken) throws IOException {
+            @Nonnull @NotEmpty final String stateToken, final boolean sealed) throws IOException {
         
         final String key;
         final String context = getContext(agent, application);
@@ -194,7 +194,7 @@ public class StorageServiceStateManager extends AbstractStateManager {
                 log.warn("Unable to delete state record ('{}', '{}') from storage", context, key, e);
             }
             try {
-                final String decoded = getDataSealer() != null ? record.getValue() :
+                final String decoded = sealed ? record.getValue() :
                     new String(Base64Support.decode(record.getValue()), StandardCharsets.UTF_8);
                 log.trace("Recovered state record ('{}', '{}') with value '{}'", context, key, decoded);
                 return decoded;
@@ -236,7 +236,7 @@ public class StorageServiceStateManager extends AbstractStateManager {
         
         final StringBuilder builder = new StringBuilder(cookiePrefix);
         builder.append('_')
-            .append(application.getId())
+            .append(application.getApplicationId())
             .append('_')
             .append(uniquePortion);
         
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/PreservePostDataTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/PreservePostDataTest.java
index 32fb36c..a9fb9cf 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/PreservePostDataTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/PreservePostDataTest.java
@@ -170,7 +170,7 @@ public class PreservePostDataTest extends BaseApplicationActionTest {
         ActionTestingSupport.assertProceedEvent(event);
         Assert.assertEquals(response.getCookies().length, 1);
         
-        final Cookie cookie = response.getCookie(PreservePostData.DEFAULT_COOKIE_PREFIX + TEST_STATE);
+        final Cookie cookie = response.getCookie(action.getCookieName(TEST_STATE));
         assert cookie != null;
         Assert.assertEquals(cookie.getMaxAge(), -1);
         Assert.assertEquals(cookie.getAttribute("SameSite"), SameSiteValue.None.getValue());
@@ -188,7 +188,7 @@ public class PreservePostDataTest extends BaseApplicationActionTest {
 
         final List<Cookie> cookies = new ArrayList<>(12);
         for (int i = 0; i < 12; ++i) {
-            cookies.add(new Cookie(PreservePostData.DEFAULT_COOKIE_PREFIX + i, "foo" + i));
+            cookies.add(new Cookie(PreservePostData.DEFAULT_COOKIE_PREFIX + '_' + i, "foo" + i));
             Thread.sleep(250);
         }
         request.setCookies(cookies.toArray(new Cookie[12]));
@@ -207,7 +207,7 @@ public class PreservePostDataTest extends BaseApplicationActionTest {
         // First run with inline state to preserve data.
         testSuccess();
         
-        Cookie cookie = response.getCookie(PreservePostData.DEFAULT_COOKIE_PREFIX + TEST_STATE);
+        Cookie cookie = response.getCookie(action.getCookieName(TEST_STATE));
         assert cookie != null;
         Assert.assertEquals(cookie.getMaxAge(), -1);
         
@@ -228,7 +228,7 @@ public class PreservePostDataTest extends BaseApplicationActionTest {
         ActionTestingSupport.assertProceedEvent(event);
         Assert.assertEquals(response.getCookies().length, 2);
         
-        cookie = response.getCookie(PreservePostData.DEFAULT_COOKIE_PREFIX + TEST_STATE + "2");
+        cookie = response.getCookie(action.getCookieName(TEST_STATE + "2"));
         assert cookie != null;
         Assert.assertEquals(cookie.getMaxAge(), -1);
         Assert.assertEquals(cookie.getAttribute("SameSite"), SameSiteValue.None.getValue());
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/state/impl/CookieStateManagerTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/state/impl/CookieStateManagerTest.java
index 8689881..0cfa75c 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/state/impl/CookieStateManagerTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/state/impl/CookieStateManagerTest.java
@@ -162,7 +162,7 @@ public class CookieStateManagerTest extends BaseApplicationActionTest {
         // Check that old token is unset.
         final Cookie[] cookies = response.getCookies();
         Assert.assertEquals(cookies.length, 1);
-        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "test" + '_' + token);
+        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "default" + '_' + token);
         Assert.assertEquals(cookies[0].getValue(), null);
         Assert.assertEquals(cookies[0].getMaxAge(), 0);
         Assert.assertEquals(cookies[0].getAttribute("SameSite"), SameSiteValue.None.getValue());
@@ -188,7 +188,7 @@ public class CookieStateManagerTest extends BaseApplicationActionTest {
         // Check that old token is unset.
         final Cookie[] cookies = response.getCookies();
         Assert.assertEquals(cookies.length, 1);
-        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "test" + '_' + token);
+        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "default" + '_' + token);
         Assert.assertEquals(cookies[0].getValue(), null);
         Assert.assertEquals(cookies[0].getMaxAge(), 0);
         Assert.assertEquals(cookies[0].getAttribute("SameSite"), SameSiteValue.None.getValue());
@@ -214,7 +214,7 @@ public class CookieStateManagerTest extends BaseApplicationActionTest {
         // Check that old token is unset.
         final Cookie[] cookies = response.getCookies();
         Assert.assertEquals(cookies.length, 1);
-        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "test" + '_' + token);
+        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "default" + '_' + token);
         Assert.assertEquals(cookies[0].getValue(), null);
         Assert.assertEquals(cookies[0].getMaxAge(), 0);
         Assert.assertEquals(cookies[0].getAttribute("SameSite"), SameSiteValue.None.getValue());
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/state/impl/StorageServiceStateManagerTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/state/impl/StorageServiceStateManagerTest.java
index 366747e..b3d6e51 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/state/impl/StorageServiceStateManagerTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/state/impl/StorageServiceStateManagerTest.java
@@ -181,7 +181,7 @@ public class StorageServiceStateManagerTest extends BaseApplicationActionTest {
         // Check that old token is unset.
         final Cookie[] cookies = response.getCookies();
         Assert.assertEquals(cookies.length, 1);
-        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "test" + '_' + token);
+        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "default" + '_' + token);
         Assert.assertEquals(cookies[0].getValue(), null);
         Assert.assertEquals(cookies[0].getMaxAge(), 0);
         Assert.assertEquals(cookies[0].getAttribute("SameSite"), SameSiteValue.None.getValue());
@@ -209,7 +209,7 @@ public class StorageServiceStateManagerTest extends BaseApplicationActionTest {
         // Check that old token is unset.
         final Cookie[] cookies = response.getCookies();
         Assert.assertEquals(cookies.length, 1);
-        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "test" + '_' + token);
+        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "default" + '_' + token);
         Assert.assertEquals(cookies[0].getValue(), null);
         Assert.assertEquals(cookies[0].getMaxAge(), 0);
         Assert.assertEquals(cookies[0].getAttribute("SameSite"), SameSiteValue.None.getValue());
@@ -237,7 +237,7 @@ public class StorageServiceStateManagerTest extends BaseApplicationActionTest {
         // Check that old token is unset.
         final Cookie[] cookies = response.getCookies();
         Assert.assertEquals(cookies.length, 1);
-        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "test" + '_' + token);
+        Assert.assertEquals(cookies[0].getName(), CookieStateManager.DEFAULT_PREFIX + '_' + "default" + '_' + token);
         Assert.assertEquals(cookies[0].getValue(), null);
         Assert.assertEquals(cookies[0].getMaxAge(), 0);
         Assert.assertEquals(cookies[0].getAttribute("SameSite"), SameSiteValue.None.getValue());

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


More information about the commits mailing list