This is an automated email from the ASF dual-hosted git repository.

lprimak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shiro.git


The following commit(s) were added to refs/heads/main by this push:
     new f566b7f4a enh: added new constructors to be able to set host and start 
timestamp (#2830)
f566b7f4a is described below

commit f566b7f4a315d3d0d75613107aed2de71a51691e
Author: Lenny Primak <[email protected]>
AuthorDate: Thu Jul 9 09:45:26 2026 -0500

    enh: added new constructors to be able to set host and start timestamp 
(#2830)
---
 .../java/org/apache/shiro/session/mgt/SimpleSession.java | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/shiro/session/mgt/SimpleSession.java 
b/core/src/main/java/org/apache/shiro/session/mgt/SimpleSession.java
index 71664758d..a76e4bf07 100644
--- a/core/src/main/java/org/apache/shiro/session/mgt/SimpleSession.java
+++ b/core/src/main/java/org/apache/shiro/session/mgt/SimpleSession.java
@@ -18,6 +18,7 @@
  */
 package org.apache.shiro.session.mgt;
 
+import lombok.NonNull;
 import org.apache.shiro.session.ExpiredSessionException;
 import org.apache.shiro.session.InvalidSessionException;
 import org.apache.shiro.session.StoppedSessionException;
@@ -102,9 +103,13 @@ public class SimpleSession implements ValidatingSession, 
Serializable {
     private transient volatile Map<Object, Object> attributes;
 
     public SimpleSession() {
+        this(new Date());
+    }
+
+    public SimpleSession(Date startTimestamp) {
         //TODO - remove concrete reference to DefaultSessionManager
         this.timeout = new 
AtomicLong(DefaultSessionManager.DEFAULT_GLOBAL_SESSION_TIMEOUT);
-        this.startTimestamp = new Date();
+        this.startTimestamp = startTimestamp;
         this.stopTimestamp = new AtomicReference<>();
         this.lastAccessTime = new AtomicReference<>(this.startTimestamp);
     }
@@ -114,6 +119,15 @@ public class SimpleSession implements ValidatingSession, 
Serializable {
         this.host = host;
     }
 
+    /**
+     * @param host null allowed
+     * @param startTimestamp null not allowed
+     */
+    public SimpleSession(String host, @NonNull Date startTimestamp) {
+        this(startTimestamp);
+        this.host = host;
+    }
+
     @Override
     public Serializable getId() {
         return this.id;

Reply via email to