You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bd...@apache.org on 2018/05/02 16:45:10 UTC
[1/3] shiro git commit: SHIRO-637: Refresh cached session in HTTP
request when its state changes
Repository: shiro
Updated Branches:
refs/heads/master 9dfed7d2e -> f782eb108
SHIRO-637: Refresh cached session in HTTP request when its state changes
Project: http://git-wip-us.apache.org/repos/asf/shiro/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/2105c1b6
Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/2105c1b6
Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/2105c1b6
Branch: refs/heads/master
Commit: 2105c1b6a89d41f546ab24eea69e5db6186001df
Parents: f326fd3
Author: kp <ph...@sprecher-automation.com>
Authored: Tue Oct 24 11:11:20 2017 +0200
Committer: kp <ph...@sprecher-automation.com>
Committed: Tue Oct 24 11:11:20 2017 +0200
----------------------------------------------------------------------
.../apache/shiro/web/servlet/ShiroHttpServletRequest.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/shiro/blob/2105c1b6/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java
----------------------------------------------------------------------
diff --git a/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java b/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java
index 6b71250..072f2af 100644
--- a/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java
+++ b/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java
@@ -151,16 +151,17 @@ public class ShiroHttpServletRequest extends HttpServletRequestWrapper {
}
}
} else {
- if (this.session == null) {
-
- boolean existing = getSubject().getSession(false) != null;
-
+ boolean existing = getSubject().getSession(false) != null;
+
+ if (this.session == null || !existing) {
Session shiroSession = getSubject().getSession(create);
if (shiroSession != null) {
this.session = new ShiroHttpSession(shiroSession, this, this.servletContext);
if (!existing) {
setAttribute(REFERENCED_SESSION_IS_NEW, Boolean.TRUE);
}
+ } else if (this.session != null) {
+ this.session = null;
}
}
httpSession = this.session;
[3/3] shiro git commit: Merge branch 'pr-72'
Posted by bd...@apache.org.
Merge branch 'pr-72'
Fixes: #72
Fixes: SHIRO-637
Project: http://git-wip-us.apache.org/repos/asf/shiro/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/f782eb10
Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/f782eb10
Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/f782eb10
Branch: refs/heads/master
Commit: f782eb1084df73eff3e2ac0f9780cb4a4f429041
Parents: 9dfed7d 154d5e2
Author: Brian Demers <bd...@apache.org>
Authored: Wed May 2 11:50:19 2018 -0400
Committer: Brian Demers <bd...@apache.org>
Committed: Wed May 2 11:50:19 2018 -0400
----------------------------------------------------------------------
.../web/servlet/ShiroHttpServletRequest.java | 9 ++-
.../servlet/ShiroHttpServletRequestTest.java | 78 ++++++++++++++++++++
2 files changed, 83 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
[2/3] shiro git commit: Added unit test
Posted by bd...@apache.org.
Added unit test
Project: http://git-wip-us.apache.org/repos/asf/shiro/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/154d5e2d
Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/154d5e2d
Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/154d5e2d
Branch: refs/heads/master
Commit: 154d5e2d11c786a67b5be63aa58c928d97055cce
Parents: 2105c1b
Author: kp <ph...@sprecher-automation.com>
Authored: Mon Oct 30 14:33:47 2017 +0100
Committer: kp <ph...@sprecher-automation.com>
Committed: Mon Oct 30 14:33:47 2017 +0100
----------------------------------------------------------------------
.../servlet/ShiroHttpServletRequestTest.java | 78 ++++++++++++++++++++
1 file changed, 78 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/shiro/blob/154d5e2d/web/src/test/java/org/apache/shiro/web/servlet/ShiroHttpServletRequestTest.java
----------------------------------------------------------------------
diff --git a/web/src/test/java/org/apache/shiro/web/servlet/ShiroHttpServletRequestTest.java b/web/src/test/java/org/apache/shiro/web/servlet/ShiroHttpServletRequestTest.java
new file mode 100644
index 0000000..85da229
--- /dev/null
+++ b/web/src/test/java/org/apache/shiro/web/servlet/ShiroHttpServletRequestTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.web.servlet;
+
+import static org.easymock.EasyMock.*;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.shiro.session.Session;
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.util.ThreadContext;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.TestCase;
+
+public class ShiroHttpServletRequestTest extends TestCase {
+
+ private ShiroHttpServletRequest request;
+
+ private HttpServletRequest mockRequest;
+ private ServletContext mockContext;
+ private Subject mockSubject;
+
+ @Before
+ public void setUp() throws Exception {
+ this.mockRequest = createMock(HttpServletRequest.class);
+ this.mockContext = createMock(ServletContext.class);
+ this.mockSubject = createMock(Subject.class);
+
+ ThreadContext.bind(this.mockSubject);
+ this.request = new ShiroHttpServletRequest(mockRequest, mockContext, false);
+ }
+
+ /**
+ * Test asserting <a href="https://issues.apache.org/jira/browse/SHIRO-637">SHIRO-637<a/>.
+ */
+ @Test
+ public void testRegetSession() throws Exception {
+ Session session1 = createMock(Session.class);
+ Session session2 = createMock(Session.class);
+
+ mockSubject.logout();
+ expect(mockSubject.getSession(true))
+ .andReturn(session1).times(1)
+ .andReturn(session2).times(1);
+ expect(mockSubject.getSession(false))
+ .andReturn(session1).times(2)
+ .andReturn(null).times(3);
+ replay(mockSubject);
+
+ assertNotNull(request.getSession(true));
+ assertNotNull(request.getSession(false));
+
+ mockSubject.logout();
+
+ assertNull(request.getSession(false));
+ assertNotNull(request.getSession(true));
+ verify(mockSubject);
+ }
+}