[java-shib-shared] branch main updated: Add a Duration-based setter for max-age.

Scott Cantor cantor.2 at osu.edu
Wed May 31 19:00:10 UTC 2023


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

scantor pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=1959e2b53053bb1d404fcda290b23652fa3cf7da

The following commit(s) were added to refs/heads/main by this push:
     new 1959e2b5 Add a Duration-based setter for max-age.
1959e2b5 is described below

commit 1959e2b53053bb1d404fcda290b23652fa3cf7da
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed May 31 15:00:08 2023 -0400

    Add a Duration-based setter for max-age.
---
 .../java/net/shibboleth/shared/net/CookieManager.java  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/shib-networking/src/main/java/net/shibboleth/shared/net/CookieManager.java b/shib-networking/src/main/java/net/shibboleth/shared/net/CookieManager.java
index 65c9963f..aab9dd7c 100644
--- a/shib-networking/src/main/java/net/shibboleth/shared/net/CookieManager.java
+++ b/shib-networking/src/main/java/net/shibboleth/shared/net/CookieManager.java
@@ -17,6 +17,8 @@
 
 package net.shibboleth.shared.net;
 
+import java.time.Duration;
+
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
@@ -170,6 +172,22 @@ public final class CookieManager extends AbstractInitializableComponent {
 
         maxAge = age;
     }
+    
+    /**
+     * Maximum age expressed as a {@link Duration}.
+     * 
+     * @param age max age of cookie
+     * 
+     * @since 9.0.0
+     */
+    public void setMaxAge(@Nonnull final Duration age) {
+        checkSetterPreconditions();
+        
+        maxAge = (int) Constraint.isNotNull(age, "Age cannot be null").getSeconds();
+        if (maxAge < 0) {
+            maxAge = -1;
+        }
+    }
 
     /** {@inheritDoc} */
     protected void doInitialize() throws ComponentInitializationException {

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


More information about the commits mailing list