You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by ka...@apache.org on 2010/04/02 01:21:32 UTC
svn commit: r930133 - in /incubator/shiro/trunk/support/spring/src:
main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java
test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java
Author: kaosko
Date: Thu Apr 1 23:21:31 2010
New Revision: 930133
URL: http://svn.apache.org/viewvc?rev=930133&view=rev
Log:
IN PROGRESS - issue SHIRO-89: Sample Spring Application - WebStart won't launch
http://issues.apache.org/jira/browse/SHIRO-89
- Make it possible to inject sessionId as a constructor parameter to SecureRemoteInvocationFactory. Don't like the whole heuristic approach but will do for now. The implementation can be changed later without changing the interfaces
Modified:
incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java
incubator/shiro/trunk/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java
Modified: incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java?rev=930133&r1=930132&r2=930133&view=diff
==============================================================================
--- incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java (original)
+++ incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactory.java Thu Apr 1 23:21:31 2010
@@ -52,6 +52,15 @@ public class SecureRemoteInvocationFacto
private static final String SESSION_ID_SYSTEM_PROPERTY_NAME = "shiro.session.id";
+ private String sessionId;
+
+ public SecureRemoteInvocationFactory(String sessionId) {
+ this();
+ this.sessionId = sessionId;
+ }
+
+ public SecureRemoteInvocationFactory() {}
+
/**
* Creates a {@link RemoteInvocation} with the current session ID as an
* {@link RemoteInvocation#getAttribute(String) attribute}.
@@ -76,23 +85,27 @@ public class SecureRemoteInvocationFacto
}
}
- //tried the delegate. If sessionId is still null, only then try the Subject:
- try {
- // HACK Check if can get the securityManager - this'll cause an exception if it's not set
- SecurityUtils.getSecurityManager();
- if (sessionId == null && !sessionManagerMethodInvocation) {
- Subject subject = SecurityUtils.getSubject();
- Session session = subject.getSession(false);
- if (session != null) {
- sessionId = session.getId();
- host = session.getHost();
+ //tried the delegate. Use the injected session id if given
+ if (sessionId == null) sessionId = this.sessionId;
+
+ // If sessionId is null, only then try the Subject:
+ if (sessionId == null) {
+ try {
+ // HACK Check if can get the securityManager - this'll cause an exception if it's not set
+ SecurityUtils.getSecurityManager();
+ if (sessionId == null && !sessionManagerMethodInvocation) {
+ Subject subject = SecurityUtils.getSubject();
+ Session session = subject.getSession(false);
+ if (session != null) {
+ sessionId = session.getId();
+ host = session.getHost();
+ }
}
}
+ catch (Exception e) {
+ log.trace("No security manager set. Trying next to get session id from system property");
+ }
}
- catch (Exception e) {
- log.trace("No security manager set. Trying next to get session id from system property");
- }
-
//No call to the sessionManager, and the Subject doesn't have a session. Try a system property
//as a last result:
if (sessionId == null) {
Modified: incubator/shiro/trunk/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java?rev=930133&r1=930132&r2=930133&view=diff
==============================================================================
--- incubator/shiro/trunk/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java (original)
+++ incubator/shiro/trunk/support/spring/src/test/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationFactoryTest.java Thu Apr 1 23:21:31 2010
@@ -87,7 +87,7 @@ public class SecureRemoteInvocationFacto
verify(mi);
- assertEquals(ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY), dummySessionId);
+ assertEquals(dummySessionId, ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY));
}
/*@Test