[java-plugin-shibd] branch dev/StateMgmtWIP updated: Remove stale code and unused constants.
Codeberg
noreply at shibboleth.net
Tue Apr 28 17:53:52 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/1aac859169ec951916780f341e23813a7e734ee0
The following commit(s) were added to refs/heads/dev/StateMgmtWIP by this push:
new 1aac859 Remove stale code and unused constants.
1aac859 is described below
commit 1aac859169ec951916780f341e23813a7e734ee0
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Apr 28 13:53:44 2026 -0400
Remove stale code and unused constants.
---
.../sp/context/TokenConsumerContext.java | 55 -------
.../shibboleth/sp/profile/ConsumerConstants.java | 3 -
.../net/shibboleth/sp/profile/SPConstants.java | 3 +
.../MessageCorrelationIDLookupFunction.java | 33 ----
.../sp/profile/impl/ProcessCorrelationCookie.java | 176 ---------------------
.../profile/impl/ProcessCorrelationCookieTest.java | 135 ----------------
6 files changed, 3 insertions(+), 402 deletions(-)
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/context/TokenConsumerContext.java b/sp-server-api/src/main/java/net/shibboleth/sp/context/TokenConsumerContext.java
deleted file mode 100644
index 2b09eff..0000000
--- a/sp-server-api/src/main/java/net/shibboleth/sp/context/TokenConsumerContext.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.context;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.opensaml.messaging.context.BaseContext;
-
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.primitive.StringSupport;
-
-/**
- * Dedicated context for a token consumer operation's state.
- */
-public class TokenConsumerContext extends BaseContext {
-
- /** A message ID to use for correlating responses against. */
- @Nullable @NotEmpty private String messageCorrelationID;
-
- /**
- * Gets the message ID to correlate responses against.
- *
- * @return original request message ID
- */
- @Nullable @NotEmpty public String getMessageCorrelationID() {
- return messageCorrelationID;
- }
-
- /**
- * Sets the message ID to correlate responses against.
- *
- * @param id original request message ID
- *
- * @return this context
- */
- @Nonnull public TokenConsumerContext setMessageCorrelationID(@Nullable @NotEmpty String id) {
- messageCorrelationID = StringSupport.trimOrNull(id);
-
- return this;
- }
-
-}
\ 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
index 5ee9ff4..3725f85 100644
--- 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
@@ -35,9 +35,6 @@ public final class ConsumerConstants {
/** Session attributes data member. */
@Nonnull @NotEmpty public static final String SESSION_ATTRIBUTES = "session.attributes";
- /** Passive indicator output parameter name. */
- @Nonnull @NotEmpty public static final String PASSIVE = "passive";
-
/** Private constructor. */
private ConsumerConstants() {
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/SPConstants.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/SPConstants.java
index 30b7ccf..b0101bb 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/profile/SPConstants.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/profile/SPConstants.java
@@ -35,6 +35,9 @@ public final class SPConstants {
/** Event parameter. */
@Nonnull @NotEmpty public static final String EVENT = "event";
+ /** Original Event parameter. */
+ @Nonnull @NotEmpty public static final String ORIGINAL_EVENT = "original_event";
+
/** Transaction ID parameter. */
@Nonnull @NotEmpty public static final String TXID = "txid";
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/profile/context/navigate/MessageCorrelationIDLookupFunction.java b/sp-server-api/src/main/java/net/shibboleth/sp/profile/context/navigate/MessageCorrelationIDLookupFunction.java
deleted file mode 100644
index 1aacff1..0000000
--- a/sp-server-api/src/main/java/net/shibboleth/sp/profile/context/navigate/MessageCorrelationIDLookupFunction.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.context.navigate;
-
-import javax.annotation.Nullable;
-
-import org.opensaml.messaging.context.navigate.ContextDataLookupFunction;
-
-import net.shibboleth.sp.context.TokenConsumerContext;
-
-/**
- * Lookup strategy for accessing message correlation ID in {@link TokenConsumerContext}.
- */
-public class MessageCorrelationIDLookupFunction implements ContextDataLookupFunction<TokenConsumerContext,String> {
-
- /** {@inheritDoc} */
- @Nullable public String apply(@Nullable final TokenConsumerContext input) {
- return input != null ? input.getMessageCorrelationID() : null;
- }
-
-}
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ProcessCorrelationCookie.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ProcessCorrelationCookie.java
deleted file mode 100644
index 7b63d65..0000000
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/ProcessCorrelationCookie.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 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 java.util.function.Function;
-
-import javax.annotation.Nonnull;
-
-import org.opensaml.profile.action.EventIds;
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.slf4j.Logger;
-
-import com.google.common.escape.Escaper;
-import com.google.common.net.UrlEscapers;
-
-import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.logic.Constraint;
-import net.shibboleth.shared.net.CookieManager;
-import net.shibboleth.shared.net.URISupport;
-import net.shibboleth.shared.primitive.LoggerFactory;
-import net.shibboleth.shared.primitive.StringSupport;
-import net.shibboleth.sp.context.AgentRequestContext;
-import net.shibboleth.sp.context.TokenConsumerContext;
-import net.shibboleth.sp.messaging.RemotedHttpServletRequestResponseContext;
-import net.shibboleth.sp.profile.AbstractApplicationAction;
-
-/**
- * Action that processes a previously issued correlation cookie submitted with the request and
- * extracts the passive status and message ID for use by subsequent validation steps.
- *
- * <p>The information captured is stored in a {@link TokenConsumerContext} child of the
- * {@link AgentRequestContext}.</p>
- *
- * <p>The absence of state or the cookie are not treated as an error or fatal at this stage
- * due to the existence of unsolicited responses.</p>
- *
- * @event {@link EventIds#PROCEED_EVENT_ID}
- * @event {@link EventIds#INVALID_MESSAGE}
- *
- * @deprecated
- */
- at Deprecated
-public class ProcessCorrelationCookie extends AbstractApplicationAction {
-
- /** Class logger. */
- @Nonnull private Logger log = LoggerFactory.getLogger(ProcessCorrelationCookie.class);
-
- /** Cookie manager. */
- @NonnullAfterInit private CookieManager cookieManager;
-
- /** Cookie prefix. */
- @Nonnull private String cookiePrefix;
-
- /** Lookup strategy for state token value. */
- @NonnullAfterInit private Function<ProfileRequestContext,String> stateTokenLookupStrategy;
-
- /** State token accompanying request. */
- @NonnullBeforeExec private String stateToken;
-
- /** Constructor. */
- public ProcessCorrelationCookie() {
- cookiePrefix = "shibsp_req_";
- }
-
- /**
- * Sets the {@link CookieManager} to use.
- *
- * @param manager cookie manager instance
- */
- public void setCookieManager(@Nonnull final CookieManager manager) {
- checkSetterPreconditions();
-
- cookieManager = Constraint.isNotNull(manager, "CookieManager cannot be null");
- }
-
- /**
- * Sets the cookie prefix.
- *
- * <p>Defaults to {@link IssueCorrelationCookie#DEFAULT_COOKIE_PREFIX}.</p>
- *
- * @param prefix cookie prefix
- */
- public void setCookiePrefix(@Nonnull @NotEmpty final String prefix) {
- checkSetterPreconditions();
-
- cookiePrefix = Constraint.isNotNull(StringSupport.trimOrNull(prefix), "Cookie prefix cannot be null or empty");
- }
-
- /**
- * Sets the lookup strategy for obtaining the request message's ID.
- *
- * @param strategy lookup strategy
- */
- public void setStateTokenLookupStrategy(@Nonnull final Function<ProfileRequestContext,String> strategy) {
- checkSetterPreconditions();
-
- stateTokenLookupStrategy = Constraint.isNotNull(strategy, "Request ID lookup strategy cannot be null");
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (cookieManager == null) {
- throw new ComponentInitializationException("CookieManager cannot be null");
- } else if (stateTokenLookupStrategy == null) {
- throw new ComponentInitializationException("State token lookup strategy cannot be null");
- }
- }
-
- /** {@inheritDoc} */
- @Override
- protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
- if (!super.doPreExecute(profileRequestContext)) {
- return false;
- }
-
- stateToken = stateTokenLookupStrategy.apply(profileRequestContext);
- if (stateToken == null) {
- log.debug("{} No state token found in request, skipping correlation cookie processing", getLogPrefix());
- return false;
- }
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override
- protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
-
- ensureOutputObjects();
- final AgentRequestContext agentRequestContext = ensureAgentRequestContext();
-
- // We do the crazy stuff to accomodate the cookies being read and unset.
- try {
- RemotedHttpServletRequestResponseContext.loadCurrent(agentRequestContext.getRemotedHttpServletRequest(),
- agentRequestContext.getRemotedHttpServletResponse());
-
- final Escaper escaper = UrlEscapers.urlFormParameterEscaper();
- final String cookieName = cookiePrefix + escaper.escape(stateToken);
-
- final String value = cookieManager.getCookieValue(cookieName, null);
- if (value == null) {
- log.debug("{} No correlation cookie found for state token '{}'", getLogPrefix(), stateToken);
- return;
- }
-
- cookieManager.unsetCookie(cookieName);
-
- final String decoded = URISupport.doURLDecode(value);
-
- log.debug("{} Extracted request ID '{}' for state token '{}'", getLogPrefix(), decoded, stateToken);
-
- agentRequestContext.ensureSubcontext(TokenConsumerContext.class).setMessageCorrelationID(decoded);
- } finally {
- RemotedHttpServletRequestResponseContext.clearCurrent();
- }
- }
-
-}
\ No newline at end of file
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/ProcessCorrelationCookieTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/ProcessCorrelationCookieTest.java
deleted file mode 100644
index f6e9c0f..0000000
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/ProcessCorrelationCookieTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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 java.util.function.Function;
-
-import javax.annotation.Nonnull;
-
-import org.opensaml.profile.context.ProfileRequestContext;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.webflow.execution.Event;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import com.google.common.escape.Escaper;
-import com.google.common.net.UrlEscapers;
-
-import jakarta.servlet.http.Cookie;
-import net.shibboleth.idp.profile.testing.ActionTestingSupport;
-import net.shibboleth.shared.annotation.constraint.NotEmpty;
-import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.net.CookieManager;
-import net.shibboleth.shared.net.CookieManager.SameSiteValue;
-import net.shibboleth.shared.primitive.NonnullSupplier;
-import net.shibboleth.sp.context.TokenConsumerContext;
-import net.shibboleth.sp.ddf.DDF;
-
-/**
- * Unit test for {@link ProcessCorrelationCookie} action.
- */
- at SuppressWarnings("javadoc")
-public class ProcessCorrelationCookieTest extends BaseApplicationActionTest {
-
- @Nonnull @NotEmpty private final static String TEST_STATE = "foo";
- @Nonnull @NotEmpty private final static String TEST_ID = "123456789";
-
- private String state;
-
- private DDF input;
- private MockHttpServletRequest request;
- private MockHttpServletResponse response;
-
- private CookieManager cookieManager;
- private ProcessCorrelationCookie action;
-
- /**
- * Set up test.
- *
- * @throws ComponentInitializationException
- */
- @BeforeMethod
- public void setUp() throws ComponentInitializationException {
- super.beforeMethod();
-
- request = new MockHttpServletRequest();
- response = new MockHttpServletResponse();
-
- cookieManager = new CookieManager();
- cookieManager.setHttpServletRequestSupplier(NonnullSupplier.of(request));
- cookieManager.setHttpServletResponseSupplier(NonnullSupplier.of(response));
- cookieManager.setCookieLimit(10);
- cookieManager.setSameSite(SameSiteValue.None);
- cookieManager.setMaxAge(-1);
- cookieManager.initialize();
-
- action = new ProcessCorrelationCookie();
- action.setCookieManager(cookieManager);
- action.setStateTokenLookupStrategy(new Function<>() {
- public String apply(ProfileRequestContext t) {
- return state;
- }
- });
- action.initialize();
- }
-
- /**
- * Tear down test.
- */
- @AfterMethod
- public void tearDown() {
- action.destroy();
- cookieManager.destroy();
- }
-
- @DataProvider
- Object[][] correlationData() {
- return new Object[][] {
- new Object[] {false, null, null},
- new Object[] {false, TEST_STATE, null},
- new Object[] {true, null, null},
- new Object[] {true, TEST_STATE, TEST_ID},
- };
- }
-
- @Test(dataProvider="correlationData")
- public void testAction(final Boolean createCookie, final String token, final String id) {
- state = token;
-
- if (createCookie && token != null) {
- final Escaper escaper = UrlEscapers.urlFormParameterEscaper();
- final Cookie cookie = new Cookie("shibsp_req_" + escaper.escape(token), id);
- request.setCookies(cookie);
- }
-
- final Event event = action.execute(src);
- ActionTestingSupport.assertProceedEvent(event);
-
- Assert.assertEquals(response.getCookies().length, createCookie && token != null ? 1 : 0);
-
- final TokenConsumerContext tcc = arc.getSubcontext(TokenConsumerContext.class);
- if (id != null) {
- assert tcc != null;
- Assert.assertEquals(tcc.getMessageCorrelationID(), id);
- } else {
- Assert.assertNull(tcc);
- }
- }
-
-}
\ 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