[java-plugin-shibd-oidc] branch main updated: Code cleanup and Javadoc improvements

Codeberg noreply at shibboleth.net
Mon Apr 13 09:25:00 UTC 2026


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

codeberg pushed a commit to branch main
in repository java-plugin-shibd-oidc.

View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd-oidc/commit/16c9f90fb07eb243de7509b81a82894dd131a396

The following commit(s) were added to refs/heads/main by this push:
     new 16c9f90  Code cleanup and Javadoc improvements
16c9f90 is described below

commit 16c9f90fb07eb243de7509b81a82894dd131a396
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Mon Apr 13 10:24:50 2026 +0100

    Code cleanup and Javadoc improvements
---
 .../sp/oidc/profile/impl/IssueStateCookie.java       |  2 +-
 .../oidc/profile/impl/MapStateValueToStateToken.java | 20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/sp-oidc-impl/src/main/java/net/shibboleth/sp/oidc/profile/impl/IssueStateCookie.java b/sp-oidc-impl/src/main/java/net/shibboleth/sp/oidc/profile/impl/IssueStateCookie.java
index 309848b..d718fda 100644
--- a/sp-oidc-impl/src/main/java/net/shibboleth/sp/oidc/profile/impl/IssueStateCookie.java
+++ b/sp-oidc-impl/src/main/java/net/shibboleth/sp/oidc/profile/impl/IssueStateCookie.java
@@ -134,7 +134,7 @@ public class IssueStateCookie extends AbstractApplicationAction {
         if (cookieManager == null) {
             throw new ComponentInitializationException("CookieManager cannot be null");
         } else if (stateValueLookupStrategy == null) {
-            throw new ComponentInitializationException("Request ID lookup strategy cannot be null");
+            throw new ComponentInitializationException("State value lookup strategy cannot be null");
         }
     }    
 
diff --git a/sp-oidc-impl/src/main/java/net/shibboleth/sp/oidc/profile/impl/MapStateValueToStateToken.java b/sp-oidc-impl/src/main/java/net/shibboleth/sp/oidc/profile/impl/MapStateValueToStateToken.java
index 167d50e..b862d24 100644
--- a/sp-oidc-impl/src/main/java/net/shibboleth/sp/oidc/profile/impl/MapStateValueToStateToken.java
+++ b/sp-oidc-impl/src/main/java/net/shibboleth/sp/oidc/profile/impl/MapStateValueToStateToken.java
@@ -39,11 +39,13 @@ import net.shibboleth.sp.profile.StateTokenManager;
  * 
  * An action that extracts a state value from the {@link ProfileRequestContext} using a configured lookup strategy 
  * and maps that value into an application-managed state token. The resulting token is then stored via a configured
- * consumer for later use: such as placement into an OAuth 2.0 "state" parameter or other correlation mechanism.
+ * consumer for later use: such as placement into an OAuth 2.0 "state" parameter or other state preserving or 
+ * correlation mechanism.
  * 
  * <p>The action delegates the actual token creation and storage to the application's 
  * {@link StateTokenManager}.</p>
  * 
+ * <p>Errors may be ignored or result in an {@link EventIds#IO_ERROR} event.</p> 
  * 
  * @event {@link EventIds#IO_ERROR}
  */
@@ -52,7 +54,7 @@ public class MapStateValueToStateToken extends AbstractApplicationAction {
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(MapStateValueToStateToken.class);
 
-    /** Whether an error constructing a state token is fatal. */
+    /** Whether an error constructing a state token is fatal. Default is true.*/
     private boolean errorFatal;
     
     /** Lookup strategy for the contents of the state token. */
@@ -61,6 +63,13 @@ public class MapStateValueToStateToken extends AbstractApplicationAction {
     /** A consumer that adds the state token to the profile request context.*/
     @NonnullAfterInit private BiConsumer<ProfileRequestContext, String> stateTokenConsumer;
     
+    /**
+     * Constructor.
+     */
+    public MapStateValueToStateToken() {
+        errorFatal = true;
+    }
+    
     /** {@inheritDoc} */
     @Override
     protected void doInitialize() throws ComponentInitializationException {
@@ -78,7 +87,7 @@ public class MapStateValueToStateToken extends AbstractApplicationAction {
     /**
      * Sets whether an error computing a state token should result in a fatal event.
      * 
-     * <p>Defaults to false.</p>
+     * <p>Defaults to true.</p>
      * 
      * @param flag flag to set
      */
@@ -126,7 +135,6 @@ public class MapStateValueToStateToken extends AbstractApplicationAction {
             try {
                 final String stateValue = stateValueLookupStrategy.apply(profileRequestContext);
                 if (stateValue != null) {
-                    //TODO UTF-8?
                     final byte[] stateValueBytes = stateValue.getBytes(StandardCharsets.UTF_8);
                     // b64 encode is handled by the state manager
                     assert stateValueBytes != null;
@@ -138,6 +146,10 @@ public class MapStateValueToStateToken extends AbstractApplicationAction {
                     log.debug("{} State preserved to state token: {}", getLogPrefix(), token);
                 } else{
                     log.debug("{} State value was null, state not preserved", getLogPrefix());
+                    if (errorFatal) {
+                        ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
+                        return;
+                    }
                 }
             } catch (final IOException | RuntimeException e) {
                 log.warn("{} Exception preserving state to token", getLogPrefix(), e);

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


More information about the commits mailing list