shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r807394 - in /incubator/shiro/trunk: core/src/main/java/org/apache/shiro/cache/ core/src/main/java/org/apache/shiro/subject/ core/src/main/java/org/apache/shiro/subject/support/ core/src/main/java/org/apache/shiro/util/ core/src/test/java/o...
Date Mon, 24 Aug 2009 21:47:49 GMT
Author: lhazlewood
Date: Mon Aug 24 21:47:48 2009
New Revision: 807394

URL: http://svn.apache.org/viewvc?rev=807394&view=rev
Log:
updated SubjectBuilder/WebSubjectBuilder implementations.  Refactored ThreadStateManager to
be interface-driven (ThreadState).  Refactored code where necessary to call these APIs.  Still
debating on final name for SubjectBuilder (mailing list post to ensue).

Added:
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java
      - copied, changed from r807306, incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/ThreadStateManager.java
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/util/ThreadState.java
    incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/AbstractSecurityManagerTest.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectThreadState.java
      - copied, changed from r807306, incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebThreadStateManager.java
Removed:
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/ThreadStateManager.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebThreadStateManager.java
Modified:
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/cache/HashtableCacheManager.java
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/DelegatingSubject.java
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/Subject.java
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/SubjectBuilder.java
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java
    incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java
    incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java
    incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationExecutor.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/ShiroFilter.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebDelegatingSubject.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectBuilder.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectCallable.java
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectRunnable.java
    incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/AbstractWebSecurityManagerTest.java
    incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DefaultWebSecurityManagerTest.java
    incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DelegatingWebSecurityManagerTest.java

Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/cache/HashtableCacheManager.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/cache/HashtableCacheManager.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/cache/HashtableCacheManager.java
(original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/cache/HashtableCacheManager.java
Mon Aug 24 21:47:48 2009
@@ -28,6 +28,7 @@
  * @author Jeremy Haile
  * @author Les Hazlewood
  * @since 0.2
+ * @deprecated use the {@link DefaultCacheManager} instead, which works fine in both test
and production environments.
  */
 public class HashtableCacheManager implements CacheManager {
 

Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/DelegatingSubject.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/DelegatingSubject.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/DelegatingSubject.java
(original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/DelegatingSubject.java
Mon Aug 24 21:47:48 2009
@@ -327,11 +327,11 @@
         }
     }
 
-    public <V> Callable<V> createCallable(Callable<V> callable) {
+    public <V> Callable<V> associateWith(Callable<V> callable) {
         return new SubjectCallable<V>(this, callable);
     }
 
-    public Runnable createRunnable(Runnable runnable) {
+    public Runnable associateWith(Runnable runnable) {
         if (runnable instanceof Thread) {
             String msg = "This implementation does not support Thread arguments because of
JDK ThreadLocal " +
                     "inheritance mechanisms required by Shiro.  Instead, the method argument
should be a non-Thread " +

Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/Subject.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/Subject.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/Subject.java (original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/Subject.java Mon Aug
24 21:47:48 2009
@@ -371,7 +371,7 @@
      * @return a {@code Callable} that can be run as this {@code Subject}.
      * @since 1.0
      */
-    <V> Callable<V> createCallable(Callable<V> callable);
+    <V> Callable<V> associateWith(Callable<V> callable);
 
     /**
      * Returns a {@code Runnable} instance matching the given argument while additionally
ensuring that it will
@@ -380,14 +380,14 @@
      * <p/>
      * *Note that if you need a return value to be returned as a result of the runnable's
execution or if you need to
      * react to any Exceptions, it is highly recommended to use the
-     * {@link #createCallable(java.util.concurrent.Callable) createCallable} method instead
of this one.
+     * {@link #associateWith(java.util.concurrent.Callable) createCallable} method instead
of this one.
      *
      * @param runnable the runnable to execute as this {@code Subject}
      * @return a {@code Runnable} that can be run as this {@code Subject} on another thread.
-     * @see #createCallable(java.util.concurrent.Callable)
+     * @see #associateWith (java.util.concurrent.Callable)
      * @since 1.0
      */
-    Runnable createRunnable(Runnable runnable);
+    Runnable associateWith(Runnable runnable);
 
     /*void runAs(PrincipalCollection identity);
 

Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/SubjectBuilder.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/SubjectBuilder.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/SubjectBuilder.java
(original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/SubjectBuilder.java
Mon Aug 24 21:47:48 2009
@@ -1,5 +1,6 @@
 package org.apache.shiro.subject;
 
+import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.mgt.SecurityManager;
 import org.apache.shiro.mgt.SubjectFactory;
 import org.apache.shiro.session.Session;
@@ -13,12 +14,12 @@
  * Builder design pattern implementation for acquiring {@link Subject} instances in a simplified
way without having
  * to know Shiro's construction techniques.
  * <h4>Usage</h4>
- * The simplest usage of this builder is to construct an anonymous, sessionless {@code Subject}
instance:
+ * The simplest usage of this builder is to construct an anonymous, session-less {@code Subject}
instance:
  * <pre>
  * SecurityManager securityManager = //obtain from application configuration
- * Subject subject = new {@link #SubjectBuilder(SecurityManager) SubjectBuilder}(securityManager).{@link
#build() build()};</pre>
+ * Subject subject = new {@link #SubjectBuilder(SecurityManager) SubjectBuilder}(securityManager).{@link
#buildSubject() build()};</pre>
  * <p/>
- * Any of the {@code set*} methods may be called before the {@link #build() build()} call
to provide context
+ * Any of the {@code set*} methods may be called before the {@link #buildSubject () build()}
call to provide context
  * on how to construct the {@code Subject} instance.  For example, if you have a session
id and want to acquire the
  * subject that owns that session (assuming the session exists and is not expired):
  * <pre>
@@ -44,8 +45,8 @@
 
     private final SecurityManager securityManager;
 
-    protected Map<String, Object> getSubjectContext() {
-        return this.subjectContext;
+    public SubjectBuilder() {
+        this(SecurityUtils.getSecurityManager());
     }
 
     public SubjectBuilder(SecurityManager securityManager) {
@@ -56,6 +57,10 @@
         this.subjectContext = new HashMap<String, Object>();
     }
 
+    protected Map<String, Object> getSubjectContext() {
+        return this.subjectContext;
+    }
+
     public SubjectBuilder setSessionId(Serializable sessionId) {
         if (sessionId != null) {
             this.subjectContext.put(SubjectFactory.SESSION_ID, sessionId);
@@ -85,13 +90,11 @@
     }
 
     public SubjectBuilder setAuthenticated(boolean authenticated) {
-        if (authenticated) {
-            this.subjectContext.put(SubjectFactory.AUTHENTICATED, authenticated);
-        }
+        this.subjectContext.put(SubjectFactory.AUTHENTICATED, authenticated);
         return this;
     }
 
-    public Subject build() {
+    public Subject buildSubject() {
         return this.securityManager.getSubject(this.subjectContext);
     }
 

Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java
(original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java
Mon Aug 24 21:47:48 2009
@@ -19,6 +19,7 @@
 package org.apache.shiro.subject.support;
 
 import org.apache.shiro.subject.Subject;
+import org.apache.shiro.util.ThreadState;
 
 import java.util.concurrent.Callable;
 
@@ -27,18 +28,18 @@
  */
 public class SubjectCallable<V> implements Callable<V> {
 
-    protected final ThreadStateManager threadStateManager;
+    protected final ThreadState threadState;
     private final Callable<V> callable;
 
     public SubjectCallable(Subject subject, Callable<V> delegate) {
-        this(new ThreadStateManager(subject), delegate);
+        this(new SubjectThreadState(subject), delegate);
     }
 
-    protected SubjectCallable(ThreadStateManager manager, Callable<V> delegate) {
-        if (manager == null) {
-            throw new IllegalArgumentException("ThreadStateManager argument cannot be null.");
+    protected SubjectCallable(ThreadState threadState, Callable<V> delegate) {
+        if (threadState == null) {
+            throw new IllegalArgumentException("ThreadState argument cannot be null.");
         }
-        this.threadStateManager = manager;
+        this.threadState = threadState;
         if (delegate == null) {
             throw new IllegalArgumentException("Callable delegate instance cannot be null.");
         }
@@ -47,10 +48,10 @@
 
     public V call() throws Exception {
         try {
-            threadStateManager.bindThreadState();
+            threadState.bind();
             return doCall(this.callable);
         } finally {
-            threadStateManager.restoreThreadState();
+            threadState.restore();
         }
     }
 

Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java
(original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java
Mon Aug 24 21:47:48 2009
@@ -19,24 +19,25 @@
 package org.apache.shiro.subject.support;
 
 import org.apache.shiro.subject.Subject;
+import org.apache.shiro.util.ThreadState;
 
 /**
  * @since 1.0
  */
 public class SubjectRunnable implements Runnable {
 
-    protected final ThreadStateManager threadStateManager;
+    protected final ThreadState threadState;
     private final Runnable runnable;
 
     public SubjectRunnable(Subject subject, Runnable delegate) {
-        this(new ThreadStateManager(subject), delegate);
+        this(new SubjectThreadState(subject), delegate);
     }
 
-    protected SubjectRunnable(ThreadStateManager manager, Runnable delegate) {
-        if (manager == null) {
-            throw new IllegalArgumentException("ThreadStateManager argument cannot be null.");
+    protected SubjectRunnable(ThreadState threadState, Runnable delegate) {
+        if (threadState == null) {
+            throw new IllegalArgumentException("ThreadState argument cannot be null.");
         }
-        this.threadStateManager = manager;
+        this.threadState = threadState;
         if (delegate == null) {
             throw new IllegalArgumentException("Runnable argument cannot be null.");
         }
@@ -45,10 +46,10 @@
 
     public void run() {
         try {
-            threadStateManager.bindThreadState();
+            threadState.bind();
             doRun();
         } finally {
-            threadStateManager.restoreThreadState();
+            threadState.restore();
         }
     }
 

Copied: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java
(from r807306, incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/ThreadStateManager.java)
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java?p2=incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java&p1=incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/ThreadStateManager.java&r1=807306&r2=807394&rev=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/ThreadStateManager.java
(original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java
Mon Aug 24 21:47:48 2009
@@ -23,6 +23,7 @@
 import org.apache.shiro.subject.DelegatingSubject;
 import org.apache.shiro.subject.Subject;
 import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.util.ThreadState;
 
 import java.io.Serializable;
 import java.net.InetAddress;
@@ -30,32 +31,40 @@
 /**
  * @since 1.0
  */
-public class ThreadStateManager {
+public class SubjectThreadState implements ThreadState {
 
-    private final Subject originalSubject;
-    private final InetAddress originalInetAddress;
-    private final Serializable originalSessionId;
-    private final transient SecurityManager originalSecurityManager;
+    private Subject originalSubject;
+    private InetAddress originalInetAddress;
+    private Serializable originalSessionId;
+    private transient SecurityManager originalSecurityManager;
+
+    private final InetAddress inetAddress;
+    private final Serializable sessionId;
+    private final Subject subject;
+    private final transient SecurityManager securityManager;
 
-    public ThreadStateManager(Subject subject) {
+    public SubjectThreadState(Subject subject) {
         this(subject, ThreadContext.getInetAddress());
     }
 
-    protected ThreadStateManager(Subject subject, InetAddress inetAddressFallback) {
+    protected SubjectThreadState(Subject subject, InetAddress inetAddressFallback) {
         if (subject == null) {
             throw new IllegalArgumentException("Subject argument cannot be null.");
         }
-        this.originalSubject = subject;
+        this.originalSubject = ThreadContext.getSubject();
+        this.subject = subject;
+
+        this.originalSecurityManager = ThreadContext.getSecurityManager();
 
         //TODO - not an interface call (yuck)
-        if (this.originalSubject instanceof DelegatingSubject) {
-            this.originalSecurityManager = ((DelegatingSubject) this.originalSubject).getSecurityManager();
+        if (this.subject instanceof DelegatingSubject) {
+            this.securityManager = ((DelegatingSubject) this.subject).getSecurityManager();
         } else {
-            this.originalSecurityManager = ThreadContext.getSecurityManager();
+            this.securityManager = this.originalSecurityManager;
         }
 
-        Session session = this.originalSubject.getSession(false);
-
+        this.originalInetAddress = ThreadContext.getInetAddress();
+        Session session = this.subject.getSession(false);
         InetAddress inet = null;
         if (session != null) {
             inet = session.getHostAddress();
@@ -63,62 +72,68 @@
         if (inet == null) {
             inet = inetAddressFallback;
         }
-        this.originalInetAddress = inet;
+        this.inetAddress = inet;
 
+        this.originalSessionId = ThreadContext.getSessionId();
         if (session != null) {
-            this.originalSessionId = session.getId();
+            this.sessionId = session.getId();
         } else {
-            this.originalSessionId = ThreadContext.getSessionId();
+            this.sessionId = this.originalSessionId;
         }
     }
 
-    public InetAddress getOriginalInetAddress() {
-        return originalInetAddress;
+    protected Subject getSubject() {
+        return this.subject;
     }
 
-    public SecurityManager getOriginalSecurityManager() {
-        return originalSecurityManager;
-    }
-
-    public Serializable getOriginalSessionId() {
-        return originalSessionId;
-    }
-
-    public Subject getOriginalSubject() {
-        return originalSubject;
-    }
-
-    public void bindThreadState() {
-        ThreadContext.bind(this.originalSecurityManager);
-        ThreadContext.bind(this.originalSubject);
-        ThreadContext.bind(this.originalInetAddress);
-        ThreadContext.bindSessionId(this.originalSessionId);
-    }
+    public void bind() {
+        this.originalInetAddress = ThreadContext.getInetAddress();
+        this.originalSessionId = ThreadContext.getSessionId();
+        this.originalSubject = ThreadContext.getSubject();
+        this.originalSecurityManager = ThreadContext.getSecurityManager();
 
-    public void restoreThreadState() {
-        if (originalSubject == null) {
-            ThreadContext.unbindSubject();
+        if (inetAddress == null) {
+            ThreadContext.unbindInetAddress();
         } else {
-            ThreadContext.bind(originalSubject);
+            ThreadContext.bind(inetAddress);
         }
-        if (originalInetAddress == null) {
-            ThreadContext.unbindInetAddress();
+        if (sessionId == null) {
+            ThreadContext.unbindSessionId();
         } else {
-            ThreadContext.bind(originalInetAddress);
+            ThreadContext.bindSessionId(sessionId);
         }
-        if (originalSecurityManager == null) {
+        ThreadContext.bind(subject);
+        if (securityManager == null) {
             ThreadContext.unbindSecurityManager();
         } else {
-            ThreadContext.bind(originalSecurityManager);
+            ThreadContext.bind(securityManager);
+        }
+    }
+
+    public void restore() {
+        if (originalInetAddress == null) {
+            ThreadContext.unbindInetAddress();
+        } else {
+            ThreadContext.bind(originalInetAddress);
         }
         if (originalSessionId == null) {
             ThreadContext.unbindSessionId();
         } else {
             ThreadContext.bindSessionId(originalSessionId);
         }
+        if (originalSubject == null) {
+            ThreadContext.unbindSubject();
+        } else {
+            ThreadContext.bind(originalSubject);
+        }
+        if (originalSecurityManager == null) {
+            ThreadContext.unbindSecurityManager();
+        } else {
+            ThreadContext.bind(originalSecurityManager);
+        }
     }
 
-    public void clearAllThreadState() {
+    public void clear() {
         ThreadContext.clear();
     }
 }

Added: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/util/ThreadState.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/util/ThreadState.java?rev=807394&view=auto
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/util/ThreadState.java (added)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/util/ThreadState.java Mon Aug
24 21:47:48 2009
@@ -0,0 +1,26 @@
+package org.apache.shiro.util;
+
+/**
+ * A {@code ThreadState} instance manages any state that might need to be bound and/or restored
during a thread's
+ * execution.
+ *
+ * @since 1.0
+ */
+public interface ThreadState {
+
+    /**
+     * Binds any state that should be made accessible during a thread's execution.
+     */
+    void bind();
+
+    /**
+     * Restores a thread to its state before bind {@link #bind bind} was invoked.
+     */
+    void restore();
+
+    /**
+     * Clears a thread's state modifications entirely.
+     */
+    void clear();
+
+}

Added: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/AbstractSecurityManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/AbstractSecurityManagerTest.java?rev=807394&view=auto
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/AbstractSecurityManagerTest.java
(added)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/AbstractSecurityManagerTest.java
Mon Aug 24 21:47:48 2009
@@ -0,0 +1,32 @@
+package org.apache.shiro.mgt;
+
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.subject.SubjectBuilder;
+import org.apache.shiro.subject.support.SubjectThreadState;
+import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.util.ThreadState;
+import org.junit.After;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lhazlewood
+ * Date: Aug 24, 2009
+ * Time: 5:20:35 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public abstract class AbstractSecurityManagerTest {
+
+    protected ThreadState threadState;
+
+    @After
+    public void tearDown() {
+        ThreadContext.clear();
+    }
+
+    protected Subject newSubject(SecurityManager securityManager) {
+        Subject subject = new SubjectBuilder(securityManager).buildSubject();
+        threadState = new SubjectThreadState(subject);
+        threadState.bind();
+        return subject;
+    }
+}

Modified: incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java
(original)
+++ incubator/shiro/trunk/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java
Mon Aug 24 21:47:48 2009
@@ -39,7 +39,7 @@
  * @author Les Hazlewood
  * @since 0.2
  */
-public class DefaultSecurityManagerTest {
+public class DefaultSecurityManagerTest extends AbstractSecurityManagerTest {
 
     DefaultSecurityManager sm = null;
 
@@ -55,7 +55,7 @@
     public void tearDown() {
         SecurityUtils.setSecurityManager(null);
         sm.destroy();
-        ThreadContext.clear();
+        super.tearDown();
     }
 
     @Test

Modified: incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationExecutor.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationExecutor.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationExecutor.java
(original)
+++ incubator/shiro/trunk/support/spring/src/main/java/org/apache/shiro/spring/remoting/SecureRemoteInvocationExecutor.java
Mon Aug 24 21:47:48 2009
@@ -21,7 +21,7 @@
 import org.apache.shiro.mgt.SecurityManager;
 import org.apache.shiro.mgt.SubjectFactory;
 import org.apache.shiro.subject.Subject;
-import org.apache.shiro.subject.support.ThreadStateManager;
+import org.apache.shiro.subject.support.SubjectThreadState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.remoting.support.DefaultRemoteInvocationExecutor;
@@ -81,7 +81,7 @@
     @SuppressWarnings({"unchecked"})
     public Object invoke(RemoteInvocation invocation, Object targetObject) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException {
 
-        ThreadStateManager threadStateManager = null;
+        SubjectThreadState subjectThreadState = null;
 
         try {
             Map context = new HashMap();
@@ -102,8 +102,8 @@
             }
 
             Subject subject = securityManager.getSubject(context);
-            threadStateManager = new ThreadStateManager(subject);
-            threadStateManager.bindThreadState();
+            subjectThreadState = new SubjectThreadState(subject);
+            subjectThreadState.bind();
 
             return super.invoke(invocation, targetObject);
         } catch (NoSuchMethodException nsme) {
@@ -115,8 +115,8 @@
         } catch (Throwable t) {
             throw new InvocationTargetException(t);
         } finally {
-            if (threadStateManager != null) {
-                threadStateManager.clearAllThreadState();
+            if (subjectThreadState != null) {
+                subjectThreadState.clear();
             }
         }
     }

Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java
Mon Aug 24 21:47:48 2009
@@ -18,8 +18,8 @@
  * A {@code SubjectFactory} implementation that creates {@link WebDelegatingSubject} instances.
  * <p/>
  * {@code WebDelegatingSubject} instances are required if Request/Response objects are to
be maintained across
- * threads when using the {@code Subject} {@link Subject#createCallable(java.util.concurrent.Callable)
createCallable}
- * and {@link Subject#createRunnable(Runnable) createRunnable} methods.
+ * threads when using the {@code Subject} {@link Subject#associateWith(java.util.concurrent.Callable)
createCallable}
+ * and {@link Subject#associateWith(Runnable) createRunnable} methods.
  *
  * @see #newSubjectInstance(org.apache.shiro.subject.PrincipalCollection, boolean, java.net.InetAddress,
org.apache.shiro.session.Session, org.apache.shiro.mgt.SecurityManager)
  * @since 1.0

Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/ShiroFilter.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/ShiroFilter.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/ShiroFilter.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/ShiroFilter.java
Mon Aug 24 21:47:48 2009
@@ -27,12 +27,14 @@
 import org.apache.shiro.util.ClassUtils;
 import org.apache.shiro.util.LifecycleUtils;
 import static org.apache.shiro.util.StringUtils.clean;
+import org.apache.shiro.util.ThreadState;
 import org.apache.shiro.web.DefaultWebSecurityManager;
 import org.apache.shiro.web.WebUtils;
 import org.apache.shiro.web.config.IniWebConfiguration;
 import org.apache.shiro.web.config.WebConfiguration;
+import org.apache.shiro.web.subject.WebSubject;
 import org.apache.shiro.web.subject.WebSubjectBuilder;
-import org.apache.shiro.web.subject.support.WebThreadStateManager;
+import org.apache.shiro.web.subject.support.WebSubjectThreadState;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -469,7 +471,7 @@
     /**
      * Binds the current request/response pair and additional information to a thread-local
to be made available to Shiro
      * during the course of the request/response process.  This implementation binds the
request/response pair and
-     * any associated Subject (and its relevant thread-based data) via a {@link WebThreadStateManager}.
 That
+     * any associated Subject (and its relevant thread-based data) via a {@link org.apache.shiro.web.subject.support.WebSubjectThreadState}.
 That
      * threadState is returned so it can be used during thread cleanup at the end of the
request.
      * <p/>
      * To guarantee properly cleaned threads in a thread-pooled Servlet Container environment,
the corresponding
@@ -483,14 +485,14 @@
      * @return ThreadStateManager the thread state used to bind necessary state for the request
execution.
      * @since 1.0
      */
-    protected WebThreadStateManager bind(ServletRequest request, ServletResponse response)
{
-        //TODO - remove when Builder/ThreadStateManager API is complete:
+    protected ThreadState bind(ServletRequest request, ServletResponse response) {
+        //TODO - remove when Builder/SubjectThreadState API is complete:
         WebUtils.bind(request);
         WebUtils.bind(response);
 
-        Subject subject = new WebSubjectBuilder(getSecurityManager(), request, response).build();
-        WebThreadStateManager threadState = new WebThreadStateManager(subject, request, response);
-        threadState.bindThreadState();
+        WebSubject subject = new WebSubjectBuilder(getSecurityManager(), request, response).buildWebSubject();
+        ThreadState threadState = new WebSubjectThreadState(subject);
+        threadState.bind();
         return threadState;
     }
 
@@ -498,7 +500,7 @@
      * Unbinds (removes out of scope) the current {@code ServletRequest} and {@link ServletResponse}.
      * <p/>
      * This method implementation merely clears <em>all</em> thread state by
calling
-     * {@link org.apache.shiro.subject.support.ThreadStateManager#clearAllThreadState()}
to guarantee
+     * {@link org.apache.shiro.subject.support.SubjectThreadState#clear()} to guarantee
      * that <em>everything</em> that might have been bound to the thread by Shiro
has been removed to ensure the
      * underlying Thread may be safely re-used in a thread-pooled Servlet Container environment.
      *
@@ -506,8 +508,8 @@
      * @since 1.0
      */
     @SuppressWarnings({"UnusedDeclaration"})
-    protected void unbind(WebThreadStateManager threadState) {
-        threadState.clearAllThreadState();
+    protected void unbind(ThreadState threadState) {
+        threadState.clear();
     }
 
     /**
@@ -555,11 +557,11 @@
      * session timeouts are honored</li>
      * <li>{@link #executeChain(ServletRequest,ServletResponse,FilterChain) Executes}
      * the appropriate {@code FilterChain}</li>
-     * <li>{@link #unbind(org.apache.shiro.web.subject.support.WebThreadStateManager)
Unbinds} the request/response
+     * <li>{@link #unbind(org.apache.shiro.util.ThreadState) Unbinds} the request/response
      * pair and any other associated data from the thread.
      * </ul>
      * <p/>
-     * The {@link #unbind(org.apache.shiro.web.subject.support.WebThreadStateManager) unbind}
method is called in a
+     * The {@link #unbind(org.apache.shiro.util.ThreadState) unbind} method is called in
a
      * {@code finally} block to guarantee the thread may be cleanly re-used in a thread-pooled
Servlet Container
      * environment.
      *
@@ -575,7 +577,7 @@
         ServletRequest request = prepareServletRequest(servletRequest, servletResponse, chain);
         ServletResponse response = prepareServletResponse(request, servletResponse, chain);
 
-        WebThreadStateManager threadState = bind(request, response);
+        ThreadState threadState = bind(request, response);
 
         try {
             updateSessionLastAccessTime(request, response);

Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebDelegatingSubject.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebDelegatingSubject.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebDelegatingSubject.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebDelegatingSubject.java
Mon Aug 24 21:47:48 2009
@@ -33,7 +33,7 @@
 /**
  * @since 1.0
  */
-public class WebDelegatingSubject extends DelegatingSubject {
+public class WebDelegatingSubject extends DelegatingSubject implements WebSubject {
 
     private final ServletRequest servletRequest;
     private final ServletResponse servletResponse;
@@ -56,12 +56,12 @@
     }
 
     @Override
-    public <V> Callable<V> createCallable(Callable<V> callable) {
-        return new WebSubjectCallable<V>(this, callable, getServletRequest(), getServletResponse());
+    public <V> Callable<V> associateWith(Callable<V> callable) {
+        return new WebSubjectCallable<V>(this, callable);
     }
 
     @Override
-    public Runnable createRunnable(Runnable runnable) {
-        return new WebSubjectRunnable(this, runnable, getServletRequest(), getServletResponse());
+    public Runnable associateWith(Runnable runnable) {
+        return new WebSubjectRunnable(this, runnable);
     }
 }

Added: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java?rev=807394&view=auto
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java (added)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java Mon
Aug 24 21:47:48 2009
@@ -0,0 +1,29 @@
+package org.apache.shiro.web.subject;
+
+import org.apache.shiro.subject.Subject;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * A {@code WebSubject} represents a Subject instance that was acquired upon receiving a
{@link ServletRequest}.
+ *
+ * @since 1.0
+ */
+public interface WebSubject extends Subject {
+
+    /**
+     * Returns the {@code ServletRequest} accessible when the Subject instance was created.
+     *
+     * @return the {@code ServletRequest} accessible when the Subject instance was created.
+     */
+    ServletRequest getServletRequest();
+
+    /**
+     * Returns the {@code ServletResponse} accessible when the Subject instance was created.
+     *
+     * @return the {@code ServletResponse} accessible when the Subject instance was created.
+     */
+    ServletResponse getServletResponse();
+
+}

Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectBuilder.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectBuilder.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectBuilder.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectBuilder.java
Mon Aug 24 21:47:48 2009
@@ -18,8 +18,10 @@
  */
 package org.apache.shiro.web.subject;
 
+import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.mgt.SecurityManager;
 import org.apache.shiro.mgt.SubjectFactory;
+import org.apache.shiro.subject.Subject;
 import org.apache.shiro.subject.SubjectBuilder;
 
 import javax.servlet.ServletRequest;
@@ -30,8 +32,18 @@
  */
 public class WebSubjectBuilder extends SubjectBuilder {
 
+    public WebSubjectBuilder(ServletRequest request, ServletResponse response) {
+        this(SecurityUtils.getSecurityManager(), request, response);
+    }
+
     public WebSubjectBuilder(SecurityManager securityManager, ServletRequest request, ServletResponse
response) {
         super(securityManager);
+        if (request == null) {
+            throw new IllegalArgumentException("ServletRequest argument cannot be null.");
+        }
+        if (response == null) {
+            throw new IllegalArgumentException("ServletResponse argument cannot be null.");
+        }
         setRequest(request);
         setResponse(response);
     }
@@ -50,4 +62,14 @@
         return this;
     }
 
+    public WebSubject buildWebSubject() {
+        Subject subject = super.buildSubject();
+        if (!(subject instanceof WebSubject)) {
+            String msg = "Subject implementation returned from the SecurityManager was not
a " +
+                    WebSubject.class.getName() + " implementation.  Please ensure a Web-enabled
SecurityManager " +
+                    "has been configured and made available to this builder.";
+            throw new IllegalStateException(msg);
+        }
+        return (WebSubject) subject;
+    }
 }

Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectCallable.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectCallable.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectCallable.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectCallable.java
Mon Aug 24 21:47:48 2009
@@ -18,11 +18,9 @@
  */
 package org.apache.shiro.web.subject.support;
 
-import org.apache.shiro.subject.Subject;
 import org.apache.shiro.subject.support.SubjectCallable;
+import org.apache.shiro.web.subject.WebSubject;
 
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
 import java.util.concurrent.Callable;
 
 /**
@@ -30,7 +28,7 @@
  */
 public class WebSubjectCallable<V> extends SubjectCallable<V> {
 
-    public WebSubjectCallable(Subject subject, Callable<V> delegate, ServletRequest
request, ServletResponse response) {
-        super(new WebThreadStateManager(subject, request, response), delegate);
+    public WebSubjectCallable(WebSubject subject, Callable<V> delegate) {
+        super(new WebSubjectThreadState(subject), delegate);
     }
 }

Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectRunnable.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectRunnable.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectRunnable.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectRunnable.java
Mon Aug 24 21:47:48 2009
@@ -18,18 +18,15 @@
  */
 package org.apache.shiro.web.subject.support;
 
-import org.apache.shiro.subject.Subject;
 import org.apache.shiro.subject.support.SubjectRunnable;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
+import org.apache.shiro.web.subject.WebSubject;
 
 /**
  * @since 1.0
  */
 public class WebSubjectRunnable extends SubjectRunnable {
 
-    public WebSubjectRunnable(Subject subject, Runnable delegate, ServletRequest request,
ServletResponse response) {
-        super(new WebThreadStateManager(subject, request, response), delegate);
+    public WebSubjectRunnable(WebSubject subject, Runnable delegate) {
+        super(new WebSubjectThreadState(subject), delegate);
     }
 }

Copied: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectThreadState.java
(from r807306, incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebThreadStateManager.java)
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectThreadState.java?p2=incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectThreadState.java&p1=incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebThreadStateManager.java&r1=807306&r2=807394&rev=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebThreadStateManager.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebSubjectThreadState.java
Mon Aug 24 21:47:48 2009
@@ -18,54 +18,16 @@
  */
 package org.apache.shiro.web.subject.support;
 
-import org.apache.shiro.subject.Subject;
-import org.apache.shiro.subject.support.ThreadStateManager;
+import org.apache.shiro.subject.support.SubjectThreadState;
 import org.apache.shiro.web.WebUtils;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
+import org.apache.shiro.web.subject.WebSubject;
 
 /**
  * @since 1.0
  */
-public class WebThreadStateManager extends ThreadStateManager {
-
-    protected final ServletRequest originalRequest;
-    protected final ServletResponse originalResponse;
-
-    public WebThreadStateManager(Subject subject, ServletRequest request, ServletResponse
response) {
-        super(subject, WebUtils.getInetAddress(request));
-        this.originalRequest = request;
-        this.originalResponse = response;
-    }
-
-    public ServletRequest getOriginalRequest() {
-        return originalRequest;
-    }
-
-    public ServletResponse getOriginalResponse() {
-        return originalResponse;
-    }
-
-    @Override
-    public void bindThreadState() {
-        super.bindThreadState();
-        WebUtils.bind(this.originalRequest);
-        WebUtils.bind(this.originalResponse);
-    }
+public class WebSubjectThreadState extends SubjectThreadState {
 
-    @Override
-    public void restoreThreadState() {
-        super.restoreThreadState();
-        if (originalRequest == null) {
-            WebUtils.unbindServletRequest();
-        } else {
-            WebUtils.bind(originalRequest);
-        }
-        if (originalResponse == null) {
-            WebUtils.unbindServletResponse();
-        } else {
-            WebUtils.bind(originalResponse);
-        }
+    public WebSubjectThreadState(WebSubject subject) {
+        super(subject, WebUtils.getInetAddress(subject.getServletRequest()));
     }
 }

Modified: incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/AbstractWebSecurityManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/AbstractWebSecurityManagerTest.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/AbstractWebSecurityManagerTest.java
(original)
+++ incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/AbstractWebSecurityManagerTest.java
Mon Aug 24 21:47:48 2009
@@ -20,10 +20,11 @@
 
 import org.apache.shiro.mgt.SecurityManager;
 import org.apache.shiro.subject.Subject;
+import org.apache.shiro.util.ThreadContext;
+import org.apache.shiro.web.subject.WebSubject;
 import org.apache.shiro.web.subject.WebSubjectBuilder;
-import org.apache.shiro.web.subject.support.WebThreadStateManager;
+import org.apache.shiro.web.subject.support.WebSubjectThreadState;
 import org.junit.After;
-import org.junit.Before;
 
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
@@ -33,26 +34,20 @@
  */
 public abstract class AbstractWebSecurityManagerTest {
 
-    private WebThreadStateManager threadState;
-
-    @Before
-    public void setup() {
-        if (this.threadState != null) {
-            this.threadState.clearAllThreadState();
-        }
-    }
+    private WebSubjectThreadState threadState;
 
     @After
     public void tearDown() {
-        if (this.threadState != null) {
-            this.threadState.clearAllThreadState();
-        }
+        ThreadContext.clear();
     }
 
     protected Subject newSubject(SecurityManager sm, ServletRequest request, ServletResponse
response) {
-        Subject subject = new WebSubjectBuilder(sm, request, response).build();
-        this.threadState = new WebThreadStateManager(subject, request, response);
-        this.threadState.bindThreadState();
+        //TODO - remove dependency on WebUtils
+        WebUtils.bind(request);
+        WebUtils.bind(response);
+        WebSubject subject = new WebSubjectBuilder(sm, request, response).buildWebSubject();
+        this.threadState = new WebSubjectThreadState(subject);
+        this.threadState.bind();
         return subject;
     }
 

Modified: incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DefaultWebSecurityManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DefaultWebSecurityManagerTest.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DefaultWebSecurityManagerTest.java
(original)
+++ incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DefaultWebSecurityManagerTest.java
Mon Aug 24 21:47:48 2009
@@ -45,14 +45,13 @@
 
     @Before
     public void setup() {
-        super.setup();
         sm = new DefaultWebSecurityManager();
     }
 
     @After
     public void tearDown() {
-        super.tearDown();
         sm.destroy();
+        super.tearDown();
     }
 
     protected Subject newSubject(ServletRequest request, ServletResponse response) {

Modified: incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DelegatingWebSecurityManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DelegatingWebSecurityManagerTest.java?rev=807394&r1=807393&r2=807394&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DelegatingWebSecurityManagerTest.java
(original)
+++ incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/DelegatingWebSecurityManagerTest.java
Mon Aug 24 21:47:48 2009
@@ -52,14 +52,13 @@
 
     @Before
     public void setup() {
-        super.setup();
         sm = new DelegatingWebSecurityManager();
     }
 
     @After
     public void tearDown() {
-        super.tearDown();
         sm.destroy();
+        super.tearDown();
     }
 
     protected Subject newSubject(ServletRequest request, ServletResponse response) {



Mime
View raw message