shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lhazlew...@apache.org
Subject svn commit: r937094 [2/2] - in /incubator/shiro/trunk: core/src/main/java/org/apache/shiro/crypto/ core/src/main/java/org/apache/shiro/mgt/ core/src/main/java/org/apache/shiro/subject/ core/src/main/java/org/apache/shiro/subject/support/ core/src/test/...
Date Thu, 22 Apr 2010 22:49:22 GMT
Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/DefaultWebSecurityManager.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/DefaultWebSecurityManager.java?rev=937094&r1=937093&r2=937094&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/DefaultWebSecurityManager.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/DefaultWebSecurityManager.java
Thu Apr 22 22:49:21 2010
@@ -19,10 +19,10 @@
 package org.apache.shiro.web;
 
 import org.apache.shiro.mgt.DefaultSecurityManager;
-import org.apache.shiro.mgt.SubjectFactory;
 import org.apache.shiro.realm.Realm;
 import org.apache.shiro.session.mgt.SessionManager;
 import org.apache.shiro.subject.Subject;
+import org.apache.shiro.subject.SubjectContext;
 import org.apache.shiro.util.LifecycleUtils;
 import org.apache.shiro.web.attr.CookieAttribute;
 import org.apache.shiro.web.mgt.DefaultWebSubjectFactory;
@@ -31,6 +31,8 @@ import org.apache.shiro.web.session.Defa
 import org.apache.shiro.web.session.ServletContainerSessionManager;
 import org.apache.shiro.web.session.WebSessionManager;
 import org.apache.shiro.web.subject.WebSubject;
+import org.apache.shiro.web.subject.WebSubjectContext;
+import org.apache.shiro.web.subject.support.DefaultWebSubjectContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -38,7 +40,6 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import java.io.Serializable;
 import java.util.Collection;
-import java.util.Map;
 
 
 /**
@@ -76,7 +77,23 @@ public class DefaultWebSecurityManager e
         setRealms(realms);
     }
 
+
+    @Override
+    protected SubjectContext createSubjectContext() {
+        return new DefaultWebSubjectContext();
+    }
+
+    @Override
+    protected SubjectContext copy(SubjectContext subjectContext) {
+        if (subjectContext instanceof WebSubjectContext) {
+            return new DefaultWebSubjectContext((WebSubjectContext) subjectContext);
+        } else {
+            return super.copy(subjectContext);
+        }
+    }
+
     //TODO - yuck - create an interface
+
     protected WebRememberMeManager getRememberMeManagerForCookieAttributes() {
         if (!(getRememberMeManager() instanceof WebRememberMeManager)) {
             String msg = "Currently the " + getClass().getName() + " implementation only
allows setting " +
@@ -230,11 +247,12 @@ public class DefaultWebSecurityManager e
     }
 
     @Override
-    protected Serializable getSessionId(Map subjectContext) {
+    protected Serializable getSessionId(SubjectContext subjectContext) {
         Serializable sessionId = super.getSessionId(subjectContext);
-        if (sessionId == null) {
-            ServletRequest request = (ServletRequest) subjectContext.get(SubjectFactory.SERVLET_REQUEST);
-            ServletResponse response = (ServletResponse) subjectContext.get(SubjectFactory.SERVLET_RESPONSE);
+        if (sessionId == null && subjectContext instanceof WebSubjectContext) {
+            WebSubjectContext wsc = (WebSubjectContext) subjectContext;
+            ServletRequest request = wsc.resolveServletRequest();
+            ServletResponse response = wsc.resolveServletResponse();
             if (request != null && response != null) {
                 sessionId = ((WebSessionManager) getSessionManager()).getSessionId(request,
response);
             }
@@ -249,10 +267,12 @@ public class DefaultWebSecurityManager e
     }
 
     protected void removeRequestIdentity(Subject subject) {
-        WebSubject webSubject = (WebSubject) subject;
-        ServletRequest request = webSubject.getServletRequest();
-        if (request != null) {
-            request.setAttribute(ShiroHttpServletRequest.IDENTITY_REMOVED_KEY, Boolean.TRUE);
+        if (subject instanceof WebSubject) {
+            WebSubject webSubject = (WebSubject) subject;
+            ServletRequest request = webSubject.getServletRequest();
+            if (request != null) {
+                request.setAttribute(ShiroHttpServletRequest.IDENTITY_REMOVED_KEY, Boolean.TRUE);
+            }
         }
     }
 }

Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/WebRememberMeManager.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/WebRememberMeManager.java?rev=937094&r1=937093&r2=937094&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/WebRememberMeManager.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/WebRememberMeManager.java
Thu Apr 22 22:49:21 2010
@@ -20,19 +20,19 @@ package org.apache.shiro.web;
 
 import org.apache.shiro.codec.Base64;
 import org.apache.shiro.mgt.AbstractRememberMeManager;
-import org.apache.shiro.mgt.SubjectFactory;
 import org.apache.shiro.subject.Subject;
+import org.apache.shiro.subject.SubjectContext;
 import org.apache.shiro.util.CollectionUtils;
 import org.apache.shiro.web.attr.CookieAttribute;
 import org.apache.shiro.web.attr.WebAttribute;
 import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
 import org.apache.shiro.web.subject.WebSubject;
+import org.apache.shiro.web.subject.WebSubjectContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
-import java.util.Map;
 
 
 /**
@@ -108,7 +108,7 @@ public class WebRememberMeManager extend
     }
 
     /**
-     * Passthrough JavaBeans property that will get the underyling rememberMe cookie's name.
+     * Passthrough JavaBeans property that will get the underlying rememberMe cookie's name.
      * <p/>
      * The default value is {@link #DEFAULT_REMEMBER_ME_COOKIE_NAME}
      * <p/>
@@ -121,7 +121,7 @@ public class WebRememberMeManager extend
     }
 
     /**
-     * Passthrough JavaBeans property that will set the underyling rememberMe cookie's name.
+     * Passthrough JavaBeans property that will set the underlying rememberMe cookie's name.
      * <p/>
      * The default value is {@link #DEFAULT_REMEMBER_ME_COOKIE_NAME}
      * <p/>
@@ -232,15 +232,23 @@ public class WebRememberMeManager extend
         getIdentityAttribute().storeValue(base64, request, response);
     }
 
-    private ServletRequest getServletRequest(Map subjectContext) {
-        return (ServletRequest) subjectContext.get(SubjectFactory.SERVLET_REQUEST);
+    private ServletRequest getServletRequest(SubjectContext subjectContext) {
+        ServletRequest request = null;
+        if (subjectContext != null && subjectContext instanceof WebSubjectContext)
{
+            request = ((WebSubjectContext) subjectContext).getServletRequest();
+        }
+        return request;
     }
 
-    private ServletResponse getServletResponse(Map subjectContext) {
-        return (ServletResponse) subjectContext.get(SubjectFactory.SERVLET_RESPONSE);
+    private ServletResponse getServletResponse(SubjectContext subjectContext) {
+        ServletResponse response = null;
+        if (subjectContext != null && subjectContext instanceof WebSubjectContext)
{
+            response = ((WebSubjectContext) subjectContext).getServletResponse();
+        }
+        return response;
     }
 
-    protected boolean isIdentityRemoved(Map subjectContext) {
+    protected boolean isIdentityRemoved(SubjectContext subjectContext) {
         ServletRequest request = getServletRequest(subjectContext);
         if (request != null) {
             Boolean removed = (Boolean) request.getAttribute(ShiroHttpServletRequest.IDENTITY_REMOVED_KEY);
@@ -249,7 +257,7 @@ public class WebRememberMeManager extend
         return false;
     }
 
-    protected byte[] getRememberedSerializedIdentity(Map subjectContext) {
+    protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) {
         if (CollectionUtils.isEmpty(subjectContext)) {
             if (log.isTraceEnabled()) {
                 log.trace("Null or empty subject context map - unable to retrieve request/response
pair to obtain " +
@@ -302,7 +310,6 @@ public class WebRememberMeManager extend
         return base64;
     }
 
-
     protected void forgetIdentity(Subject subject) {
         WebSubject webSubject = (WebSubject) subject;
         ServletRequest request = webSubject.getServletRequest();
@@ -310,7 +317,7 @@ public class WebRememberMeManager extend
         forgetIdentity(request, response);
     }
 
-    protected void forgetIdentity(Map subjectContext) {
+    protected void forgetIdentity(SubjectContext subjectContext) {
         ServletRequest request = getServletRequest(subjectContext);
         ServletResponse response = getServletResponse(subjectContext);
         forgetIdentity(request, response);

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=937094&r1=937093&r2=937094&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
Thu Apr 22 22:49:21 2010
@@ -20,17 +20,15 @@ package org.apache.shiro.web.mgt;
 
 import org.apache.shiro.mgt.DefaultSubjectFactory;
 import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.mgt.SubjectFactory;
 import org.apache.shiro.session.Session;
 import org.apache.shiro.subject.PrincipalCollection;
 import org.apache.shiro.subject.Subject;
-import org.apache.shiro.web.WebUtils;
-import org.apache.shiro.web.subject.WebDelegatingSubject;
-import org.apache.shiro.web.subject.WebSubject;
+import org.apache.shiro.subject.SubjectContext;
+import org.apache.shiro.web.subject.WebSubjectContext;
+import org.apache.shiro.web.subject.support.WebDelegatingSubject;
 
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
-import java.util.Map;
 
 /**
  * A {@code SubjectFactory} implementation that creates {@link WebDelegatingSubject} instances.
@@ -48,72 +46,18 @@ public class DefaultWebSubjectFactory ex
         super();
     }
 
-    protected ServletRequest getServletRequest(Map context) {
-        ServletRequest request = getTypedValue(context, SubjectFactory.SERVLET_REQUEST, ServletRequest.class);
-
-        //fall back on existing subject instance if it exists:
-        if (request == null) {
-            Subject existing = getTypedValue(context, SubjectFactory.SUBJECT, Subject.class);
-            if (existing instanceof WebSubject) {
-                request = ((WebSubject) existing).getServletRequest();
-            }
-        }
-        //last resort - try the thread-local (TODO - remove this if possible):
-        if (request == null) {
-            request = WebUtils.getServletRequest();
-        }
-
-        if (request == null) {
-            throw new IllegalStateException("ServletRequest is not available!  A ServletRequest
must be present " +
-                    "in either the Subject context map, on an existing WebSubject or via
the thread context.  This " +
-                    "exception is probably indicative of an erroneous application configuration.");
-        }
-        return request;
-    }
-
-    protected ServletResponse getServletResponse(Map context) {
-        ServletResponse response = getTypedValue(context, SubjectFactory.SERVLET_RESPONSE,
ServletResponse.class);
-
-        //fall back on existing subject instance if it exists:
-        if (response == null) {
-            Subject existing = getTypedValue(context, SubjectFactory.SUBJECT, Subject.class);
-            if (existing instanceof WebSubject) {
-                response = ((WebSubject) existing).getServletResponse();
-            }
-        }
-
-        //last resort - try the thread-local (TODO - remove this if possible):
-        if (response == null) {
-            response = WebUtils.getServletResponse();
-        }
-
-        if (response == null) {
-            throw new IllegalStateException("ServletResponse is not available!  A ServletResponse
must be present " +
-                    "in either the Subject context map, on an existing WebSubject or via
the thread context.  This " +
-                    "exception is probably indicative of an erroneous application configuration.");
-        }
-
-        return response;
-    }
-
-    @Override
-    protected String getHost(Map context, Session session) {
-        String host = super.getHost(context, session);
-        if (host == null) {
-            ServletRequest request = getServletRequest(context);
-            host = request.getRemoteHost();
-        }
-        return host;
-    }
-
-    public Subject createSubject(Map context) {
-        SecurityManager securityManager = getSecurityManager(context);
-        Session session = getSession(context);
-        PrincipalCollection principals = getPrincipals(context, session);
-        boolean authenticated = isAuthenticated(context, session);
-        String host = getHost(context, session);
-        ServletRequest request = getServletRequest(context);
-        ServletResponse response = getServletResponse(context);
+    public Subject createSubject(SubjectContext context) {
+        if (!(context instanceof WebSubjectContext)) {
+            return super.createSubject(context);
+        }
+        WebSubjectContext wsc = (WebSubjectContext) context;
+        SecurityManager securityManager = wsc.resolveSecurityManager();
+        Session session = wsc.resolveSession();
+        PrincipalCollection principals = wsc.resolvePrincipals();
+        boolean authenticated = wsc.resolveAuthenticated();
+        String host = wsc.resolveHost();
+        ServletRequest request = wsc.resolveServletRequest();
+        ServletResponse response = wsc.resolveServletResponse();
         return newSubjectInstance(principals, authenticated, host, session, request, response,
securityManager);
     }
 

Modified: 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=937094&r1=937093&r2=937094&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java (original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java Thu
Apr 22 22:49:21 2010
@@ -20,9 +20,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.SubjectContext;
 import org.apache.shiro.web.WebUtils;
+import org.apache.shiro.web.subject.support.DefaultWebSubjectContext;
 
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
@@ -77,16 +78,21 @@ public interface WebSubject extends Subj
             setResponse(response);
         }
 
+        @Override
+        protected SubjectContext newSubjectContextInstance() {
+            return new DefaultWebSubjectContext();
+        }
+
         protected Builder setRequest(ServletRequest request) {
             if (request != null) {
-                getSubjectContext().put(SubjectFactory.SERVLET_REQUEST, request);
+                ((WebSubjectContext) getSubjectContext()).setServletRequest(request);
             }
             return this;
         }
 
         protected Builder setResponse(ServletResponse response) {
             if (response != null) {
-                getSubjectContext().put(SubjectFactory.SERVLET_RESPONSE, response);
+                ((WebSubjectContext) getSubjectContext()).setServletResponse(response);
             }
             return this;
         }

Added: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectContext.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectContext.java?rev=937094&view=auto
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectContext.java
(added)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebSubjectContext.java
Thu Apr 22 22:49:21 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.subject;
+
+import org.apache.shiro.subject.SubjectContext;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * A {@code WebSubjectContext} is a {@link SubjectContext} that additionally provides for
type-safe
+ * methods to set and retrieve a {@link ServletRequest} and {@link ServletResponse}.
+ *
+ * @author Les Hazlewood
+ * @since 1.0
+ */
+public interface WebSubjectContext extends SubjectContext {
+
+    /**
+     * Returns the {@code ServletRequest} received by the servlet container triggering the
creation of the
+     * {@code Subject} instance.
+     *
+     * @return the {@code ServletRequest} received by the servlet container triggering the
creation of the
+     *         {@code Subject} instance.
+     */
+    ServletRequest getServletRequest();
+
+    /**
+     * Sets the {@code ServletRequest} received by the servlet container triggering the creation
of the
+     * {@code Subject} instance.
+     *
+     * @param request the {@code ServletRequest} received by the servlet container triggering
the creation of the
+     *                {@code Subject} instance.
+     */
+    void setServletRequest(ServletRequest request);
+
+    ServletRequest resolveServletRequest();
+
+    /**
+     * The paired {@code ServletResponse} corresponding to the associated {@link #getServletRequest
servletRequest}.
+     *
+     * @return the paired {@code ServletResponse} corresponding to the associated
+     *         {@link #getServletRequest servletRequest}.
+     */
+    ServletResponse getServletResponse();
+
+    /**
+     * Sets the paired {@code ServletResponse} corresponding to the associated {@link #getServletRequest
servletRequest}.
+     *
+     * @param response The paired {@code ServletResponse} corresponding to the associated
+     *                 {@link #getServletRequest servletRequest}.
+     */
+    void setServletResponse(ServletResponse response);
+
+    ServletResponse resolveServletResponse();
+}

Added: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/DefaultWebSubjectContext.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/DefaultWebSubjectContext.java?rev=937094&view=auto
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/DefaultWebSubjectContext.java
(added)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/DefaultWebSubjectContext.java
Thu Apr 22 22:49:21 2010
@@ -0,0 +1,120 @@
+/*
+ * 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.subject.support;
+
+import org.apache.shiro.subject.Subject;
+import org.apache.shiro.subject.support.DefaultSubjectContext;
+import org.apache.shiro.web.WebUtils;
+import org.apache.shiro.web.subject.WebSubject;
+import org.apache.shiro.web.subject.WebSubjectContext;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * Default {@code WebSubjectContext} implementation that provides for additional storage
and retrieval of
+ * a {@link ServletRequest} and {@link ServletResponse}.
+ *
+ * @author Les Hazlewood
+ * @since 1.0
+ */
+public class DefaultWebSubjectContext extends DefaultSubjectContext implements WebSubjectContext
{
+
+    private static final String SERVLET_REQUEST = DefaultWebSubjectContext.class.getName()
+ ".SERVLET_REQUEST";
+
+    private static final String SERVLET_RESPONSE = DefaultWebSubjectContext.class.getName()
+ ".SERVLET_RESPONSE";
+
+    public DefaultWebSubjectContext() {
+    }
+
+    public DefaultWebSubjectContext(WebSubjectContext context) {
+        super(context);
+    }
+
+    @Override
+    public String resolveHost() {
+        String host = super.resolveHost();
+        if (host == null) {
+            ServletRequest request = resolveServletRequest();
+            if (request != null) {
+                host = request.getRemoteHost();
+            }
+        }
+        return host;
+    }
+
+    public ServletRequest getServletRequest() {
+        return getTypedValue(SERVLET_REQUEST, ServletRequest.class);
+    }
+
+    public void setServletRequest(ServletRequest request) {
+        if (request != null) {
+            put(SERVLET_REQUEST, request);
+        }
+    }
+
+    public ServletRequest resolveServletRequest() {
+
+        ServletRequest request = getServletRequest();
+
+        //fall back on existing subject instance if it exists:
+        if (request == null) {
+            Subject existing = getSubject();
+            if (existing instanceof WebSubject) {
+                request = ((WebSubject) existing).getServletRequest();
+            }
+        }
+        //last resort - try the thread-local (TODO - remove this if possible):
+        if (request == null) {
+            request = WebUtils.getServletRequest();
+        }
+
+        return request;
+    }
+
+    public ServletResponse getServletResponse() {
+        return getTypedValue(SERVLET_RESPONSE, ServletResponse.class);
+    }
+
+    public void setServletResponse(ServletResponse response) {
+        if (response != null) {
+            put(SERVLET_RESPONSE, response);
+        }
+    }
+
+    public ServletResponse resolveServletResponse() {
+
+        ServletResponse response = getServletResponse();
+
+        //fall back on existing subject instance if it exists:
+        if (response == null) {
+            Subject existing = getSubject();
+            if (existing instanceof WebSubject) {
+                response = ((WebSubject) existing).getServletResponse();
+            }
+        }
+
+        //last resort - try the thread-local (TODO - remove this if possible):
+        if (response == null) {
+            response = WebUtils.getServletResponse();
+        }
+
+        return response;
+    }
+}

Copied: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebDelegatingSubject.java
(from r935228, 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/support/WebDelegatingSubject.java?p2=incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/support/WebDelegatingSubject.java&p1=incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/subject/WebDelegatingSubject.java&r1=935228&r2=937094&rev=937094&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/support/WebDelegatingSubject.java
Thu Apr 22 22:49:21 2010
@@ -16,14 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.shiro.web.subject;
+package org.apache.shiro.web.subject.support;
 
 import org.apache.shiro.mgt.SecurityManager;
 import org.apache.shiro.session.Session;
-import org.apache.shiro.subject.DelegatingSubject;
 import org.apache.shiro.subject.PrincipalCollection;
-import org.apache.shiro.web.subject.support.WebSubjectCallable;
-import org.apache.shiro.web.subject.support.WebSubjectRunnable;
+import org.apache.shiro.subject.support.DelegatingSubject;
+import org.apache.shiro.web.subject.WebSubject;
 
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;

Modified: incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/WebRememberMeManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/WebRememberMeManagerTest.java?rev=937094&r1=937093&r2=937094&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/WebRememberMeManagerTest.java
(original)
+++ incubator/shiro/trunk/web/src/test/java/org/apache/shiro/web/WebRememberMeManagerTest.java
Thu Apr 22 22:49:21 2010
@@ -22,18 +22,17 @@ import org.apache.shiro.authc.Authentica
 import org.apache.shiro.authc.SimpleAuthenticationInfo;
 import org.apache.shiro.authc.UsernamePasswordToken;
 import org.apache.shiro.crypto.CryptoException;
-import org.apache.shiro.mgt.SubjectFactory;
 import org.apache.shiro.subject.PrincipalCollection;
 import org.apache.shiro.subject.SimplePrincipalCollection;
 import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
 import org.apache.shiro.web.subject.WebSubject;
+import org.apache.shiro.web.subject.WebSubjectContext;
+import org.apache.shiro.web.subject.support.DefaultWebSubjectContext;
 import org.junit.Test;
 
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.util.HashMap;
-import java.util.Map;
 
 import static org.easymock.EasyMock.*;
 import static org.junit.Assert.assertNotNull;
@@ -77,9 +76,9 @@ public class WebRememberMeManagerTest {
     public void getRememberedPrincipals() {
         HttpServletRequest mockRequest = createMock(HttpServletRequest.class);
         HttpServletResponse mockResponse = createMock(HttpServletResponse.class);
-        Map<String, Object> context = new HashMap<String, Object>();
-        context.put(SubjectFactory.SERVLET_REQUEST, mockRequest);
-        context.put(SubjectFactory.SERVLET_RESPONSE, mockResponse);
+        WebSubjectContext context = new DefaultWebSubjectContext();
+        context.setServletRequest(mockRequest);
+        context.setServletResponse(mockResponse);
 
         expect(mockRequest.getAttribute(ShiroHttpServletRequest.IDENTITY_REMOVED_KEY)).andReturn(null);
 
@@ -117,9 +116,9 @@ public class WebRememberMeManagerTest {
         HttpServletRequest mockRequest = createNiceMock(HttpServletRequest.class);
         HttpServletResponse mockResponse = createNiceMock(HttpServletResponse.class);
 
-        Map<String, Object> context = new HashMap<String, Object>();
-        context.put(SubjectFactory.SERVLET_REQUEST, mockRequest);
-        context.put(SubjectFactory.SERVLET_RESPONSE, mockResponse);
+        WebSubjectContext context = new DefaultWebSubjectContext();
+        context.setServletRequest(mockRequest);
+        context.setServletResponse(mockResponse);
 
         expect(mockRequest.getAttribute(ShiroHttpServletRequest.IDENTITY_REMOVED_KEY)).andReturn(null);
 



Mime
View raw message