[java-plugin-shibd] branch main updated: Add touch parameter and logic to session cache read operation.

Codeberg noreply at shibboleth.net
Wed Sep 16 19:42:49 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.

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

The following commit(s) were added to refs/heads/main by this push:
     new c3bdb81  Add touch parameter and logic to session cache read operation.
c3bdb81 is described below

commit c3bdb814a525bb3f77b6d23f73652fc57b55be14
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Wed Sep 16 15:42:39 2026 -0400

    Add touch parameter and logic to session cache read operation.
---
 .../shibboleth/sp/flows/SessionCacheFlowTest.java  |  2 ++
 .../sp/profile/impl/DoSessionCacheOperation.java   | 24 +++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/SessionCacheFlowTest.java b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/SessionCacheFlowTest.java
index 403b63b..3d52789 100644
--- a/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/SessionCacheFlowTest.java
+++ b/sp-conf-impl/src/test/java/net/shibboleth/sp/flows/SessionCacheFlowTest.java
@@ -191,6 +191,7 @@ public class SessionCacheFlowTest extends AbstractSPFlowTest {
         final DDF input = new DDF("session-cache").structure();
         input.addmember(DoSessionCacheOperation.OP).string("R");
         input.addmember(DoSessionCacheOperation.KEY).string("foo");
+        input.addmember(DoSessionCacheOperation.TOUCH).integer(1);
         setRequest("POST", input);
         
         final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
@@ -222,6 +223,7 @@ public class SessionCacheFlowTest extends AbstractSPFlowTest {
         input.addmember(DoSessionCacheOperation.KEY).string("foo");
         input.addmember(DoSessionCacheOperation.STORAGE_TIMEOUT).longinteger(900);
         input.addmember(DoSessionCacheOperation.TIMEOUT).integer(1);
+        input.addmember(DoSessionCacheOperation.TOUCH).integer(1);
         setRequest("POST", input);
         
         Thread.sleep(2000);
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DoSessionCacheOperation.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DoSessionCacheOperation.java
index e3df017..6955cf9 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DoSessionCacheOperation.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/DoSessionCacheOperation.java
@@ -95,6 +95,9 @@ public class DoSessionCacheOperation extends AbstractAgentAction {
 
     /** Member for session timeout. */
     @Nonnull @NotEmpty public static final String TIMEOUT = "timeout";
+
+    /** Member for touch indicator during reads. */
+    @Nonnull @NotEmpty public static final String TOUCH = "touch";
     
     /** Member for session version. */
     @Nonnull @NotEmpty public static final String VERSION = "ver";
@@ -291,6 +294,7 @@ public class DoSessionCacheOperation extends AbstractAgentAction {
         // "key" - session key
         // "storage_timeout" - the storage timeout in seconds
         // "timeout" - session timeout policy to apply
+        // "touch" - flag governing update to expiration
         
         // Output:
         // "session" - session structure
@@ -316,12 +320,14 @@ public class DoSessionCacheOperation extends AbstractAgentAction {
             return;
         }
         
+        // Recover last access time by backdating record expiration.
+        final Long storageTimeout = getStorageTimeout();
+        lastAccess -= (storageTimeout * 1000);
+        
         final Instant now = Instant.now();
         
         final Integer timeout = input.getmember(TIMEOUT).integer();
         if (timeout != null && timeout > 0) {
-            // Recover last access time by backdating record expiration.
-            lastAccess -= (getStorageTimeout() * 1000);
             if (Instant.ofEpochMilli(lastAccess).plusSeconds(timeout).isBefore(now)) {
                 log.info("{} Session record ({}) timed out, last use was {}, timeout policy was {}",
                         getLogPrefix(), key, Instant.ofEpochMilli(lastAccess), timeout);
@@ -330,6 +336,18 @@ public class DoSessionCacheOperation extends AbstractAgentAction {
                 return;
             }
         }
+
+        final Integer touch = input.getmember(TOUCH).integer();
+        if (touch != null && touch != 0) {
+            // Bump the expiration.
+            if (!storageService.updateExpiration(getStorageContext(), key, now.plusSeconds(storageTimeout).toEpochMilli())) {
+                // Record disappeared, so send back an empty response.
+                log.debug("{} Session record ({}) disappeared before update?", getLogPrefix(), key);
+                ActionSupport.buildEvent(profileRequestContext, MISSING_SESSION);
+            } else {
+                log.debug("{} Updated session record usage timestamp", getLogPrefix(), key);
+            }
+        }
         
         DDF sessionData;
         try (final ByteArrayInputStream source =
@@ -346,7 +364,7 @@ public class DoSessionCacheOperation extends AbstractAgentAction {
         }
 
         log.debug("{} Read and deserialized session record from storage ({})", getLogPrefix(), key);
-        
+
         sessionData.name(SESSION);
         output.add(sessionData);
     }    

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


More information about the commits mailing list