[java-plugin-shibd] branch dev/StateMgmtWIP updated: Add errorFatal flag to recover state data action
Codeberg
noreply at shibboleth.net
Fri May 1 13:59:15 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/9ce2e68330d42e406349c998881d5d9738a75cfa
The following commit(s) were added to refs/heads/dev/StateMgmtWIP by this push:
new 9ce2e68 Add errorFatal flag to recover state data action
9ce2e68 is described below
commit 9ce2e68330d42e406349c998881d5d9738a75cfa
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri May 1 14:55:03 2026 +0100
Add errorFatal flag to recover state data action
- Useful to fail early in the OIDC case where stata data is required
---
.../sp/profile/impl/RecoverStateData.java | 42 +++++++++++++++++++---
1 file changed, 37 insertions(+), 5 deletions(-)
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/RecoverStateData.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/RecoverStateData.java
index 0a629df..0f3cefa 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/RecoverStateData.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/RecoverStateData.java
@@ -42,12 +42,15 @@ import net.shibboleth.sp.state.StateData;
/**
* Action that maps a state token into a {@link StateData} (or subclass) object.
*
- * <p>The state token comes from a pluggable function but its absence will not result
- * in failure.</p>
+ * <p>The state token comes from a pluggable function.</p>
*
* <p>The token and the recovered object will be set into a {@link StateDataContext}
* created by a pluggable strategy.</p>
*
+ * <p>Errors resulting from the absence of a state token or a failure to recover associated state
+ * may be ignored or result in an {@link EventIds#IO_ERROR} event. For example, if the protocol supports
+ * unsolicited requests, a failure to retrieve prior state may be expected and should be ignored.</p>
+ *
* @event {@link EventIds#PROCEED_EVENT_ID}
* @event {@link EventIds#INVALID_PROFILE_CTX}
* @event {@link EventIds#IO_ERROR}
@@ -57,7 +60,7 @@ import net.shibboleth.sp.state.StateData;
public class RecoverStateData extends AbstractApplicationAction {
/** Class logger. */
- @Nonnull private Logger log = LoggerFactory.getLogger(RecoverStateData.class);
+ @Nonnull private final Logger log = LoggerFactory.getLogger(RecoverStateData.class);
/** Strategy used to create the {@link StateDataContext} to populate. */
@Nonnull private Function<ProfileRequestContext,StateDataContext> stateDataContextCreationStrategy;
@@ -65,6 +68,9 @@ public class RecoverStateData extends AbstractApplicationAction {
/** Lookup strategy for state token. */
@NonnullAfterInit private Function<ProfileRequestContext,String> stateTokenLookupStrategy;
+ /** Whether any failure to recover previously stored state should result in a fatal event. */
+ private boolean errorFatal;
+
/** Specific class to be recovered. */
@Nonnull private Class<? extends StateData> stateDataClass;
@@ -75,6 +81,7 @@ public class RecoverStateData extends AbstractApplicationAction {
public RecoverStateData() {
stateDataContextCreationStrategy = new ChildContextLookup<>(StateDataContext.class, true);
stateDataClass = StateData.class;
+ errorFatal = false;
}
/**
@@ -99,6 +106,19 @@ public class RecoverStateData extends AbstractApplicationAction {
stateTokenLookupStrategy = Constraint.isNotNull(strategy, "State token lookup strategy cannot be null");
}
+ /**
+ * Sets whether any failure to recover previously stored state should result in a fatal event.
+ *
+ * <p>Defaults to false.</p>
+ *
+ * @param flag flag to set
+ */
+ public void setErrorFatal(final boolean flag) {
+ checkSetterPreconditions();
+
+ errorFatal = flag;
+ }
+
/**
* Sets the type of {@link StateData} subclass to recover from the state token.
*
@@ -128,8 +148,14 @@ public class RecoverStateData extends AbstractApplicationAction {
stateToken = stateTokenLookupStrategy.apply(profileRequestContext);
if (stateToken == null) {
- log.debug("{} No state token returned from lookup strategy, nothing to do", getLogPrefix());
- return false;
+ if (!errorFatal) {
+ log.debug("{} No state token returned from lookup strategy, nothing to do", getLogPrefix());
+ return false;
+ } else {
+ log.warn("{} No state token returned from lookup strategy, fatal error", getLogPrefix());
+ ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
+ return false;
+ }
}
return true;
@@ -165,9 +191,15 @@ public class RecoverStateData extends AbstractApplicationAction {
log.debug("{} State data recovered from token: {}", getLogPrefix(), stateToken);
} else {
log.warn("{} Unable to recover data from state token", getLogPrefix());
+ if (errorFatal) {
+ ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
+ }
}
} catch (final IOException e) {
log.warn("{} Exception recovering data from state token", getLogPrefix(), e);
+ if (errorFatal) {
+ ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
+ }
} finally {
RemotedHttpServletRequestResponseContext.clearCurrent();
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list