[java-shib-shared] 02/12: Add getters and additional features to CookieManager for subclassing.

Scott Cantor cantor.2 at osu.edu
Wed Jan 31 14:15:49 UTC 2024


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

scantor pushed a commit to branch dev/thymeleaf
in repository java-shib-shared.

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

commit 49f68ec215109aa74561d6d3380b1fe41dbaf22d
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Dec 13 13:18:39 2023 -0500

    Add getters and additional features to CookieManager for subclassing.
---
 .../net/shibboleth/shared/net/CookieManager.java   | 42 ++++++++++++++++++++--
 1 file changed, 39 insertions(+), 3 deletions(-)

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 7d4da3f4..0d451377 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
@@ -68,7 +68,18 @@ public class CookieManager extends AbstractInitializableComponent {
     }
 
     /**
-     * Set the cookie path to use for session tracking.
+     * Get the cookie path to use.
+     * 
+     * @return cookie path
+     * 
+     * @since 9.1.0
+     */
+    @Nullable public String getCookiePath() {
+        return cookiePath;
+    }
+    
+    /**
+     * Set the cookie path to use.
      * 
      * <p>Defaults to the servlet context path.</p>
      * 
@@ -81,7 +92,18 @@ public class CookieManager extends AbstractInitializableComponent {
     }
 
     /**
-     * Set the cookie domain to use for session tracking.
+     * Get the cookie domain to use.
+     * 
+     * @return cookie domain
+     * 
+     * @since 9.1.0
+     */
+    @Nullable public String getCookieDomain() {
+        return cookieDomain;
+    }
+    
+    /**
+     * Set the cookie domain to use.
      * 
      * @param domain the cookie domain to use, or null for the default
      */
@@ -213,6 +235,20 @@ public class CookieManager extends AbstractInitializableComponent {
      * @param value value of cookie
      */
     public void addCookie(@Nonnull @NotEmpty final String name, @Nonnull @NotEmpty final String value) {
+        addCookie(name, value, maxAge);
+    }
+    
+    /**
+     * Add a cookie with the specified name and value.
+     * 
+     * @param name  name of cookie
+     * @param value value of cookie
+     * @param overrideMaxAge max-age value to use
+     * 
+     * @since 9.1.0
+     */
+    protected void addCookie(@Nonnull @NotEmpty final String name, @Nonnull @NotEmpty final String value,
+            final int overrideMaxAge) {
         checkComponentActive();
         
         final Cookie cookie = new Cookie(name, value);
@@ -222,7 +258,7 @@ public class CookieManager extends AbstractInitializableComponent {
         }
         cookie.setSecure(secure);
         cookie.setHttpOnly(httpOnly);
-        cookie.setMaxAge(maxAge);
+        cookie.setMaxAge(overrideMaxAge);
         
         getHttpServletResponse().addCookie(cookie);
     }

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


More information about the commits mailing list