tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r792446 - in /tomcat/trunk/java/org/apache/catalina: realm/GenericPrincipal.java session/LocalStrings.properties session/StandardSession.java
Date Thu, 09 Jul 2009 08:35:39 GMT
Author: markt
Date: Thu Jul  9 08:35:39 2009
New Revision: 792446

URL: http://svn.apache.org/viewvc?rev=792446&view=rev
Log:
Reduce coupling between StandardSession and JAAS as per Filip's suggestion

Modified:
    tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java
    tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/session/StandardSession.java

Modified: tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java?rev=792446&r1=792445&r2=792446&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/GenericPrincipal.java Thu Jul  9 08:35:39
2009
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
 
 import org.apache.catalina.Realm;
 
@@ -189,11 +190,6 @@
      */
     protected LoginContext loginContext = null;
 
-    public LoginContext getLoginContext() {
-        return loginContext;
-    }
-
-
     // --------------------------------------------------------- Public Methods
 
 
@@ -230,5 +226,23 @@
 
     }
 
+    
+    /**
+     * Calls logout, if necessary, on any associated JAASLoginContext. May in
+     * the future be extended to cover other logout requirements.
+     * 
+     * @throws Exception If something goes wrong with the logout. Uses Exception
+     *                   to allow for future expansion of this method to cover
+     *                   other logout mechanisms that might throw a different
+     *                   exception to LoginContext
+     * 
+     */
+    public void logout() throws Exception {
+        if (loginContext != null) {
+            loginContext.logout();
+        }
+    }
+
+
 
 }

Modified: tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties?rev=792446&r1=792445&r2=792446&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties Thu Jul  9 08:35:39
2009
@@ -61,7 +61,7 @@
 standardSession.getId.ise=getId: Session already invalidated
 standardSession.getMaxInactiveInterval.ise=getMaxInactiveInterval: Session already invalidated
 standardSession.getValueNames.ise=getValueNames: Session already invalidated
-standardSession.jaaslogoutfail=Exception logging out user when expiring session 
+standardSession.logoutfail=Exception logging out user when expiring session 
 standardSession.notSerializable=Cannot serialize session attribute {0} for session {1}
 standardSession.removeAttribute.ise=removeAttribute: Session already invalidated
 standardSession.sessionEvent=Session event listener threw exception

Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardSession.java?rev=792446&r1=792445&r2=792446&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StandardSession.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Thu Jul  9 08:35:39
2009
@@ -37,7 +37,6 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import javax.security.auth.login.LoginException;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpSessionActivationListener;
@@ -760,17 +759,15 @@
                 fireSessionEvent(Session.SESSION_DESTROYED_EVENT, null);
             }
 
-            // Call the JAAS logout method if necessary
+            // Call the logout method
             if (principal instanceof GenericPrincipal) {
                 GenericPrincipal gp = (GenericPrincipal) principal;
-                if (gp.getLoginContext() != null) {
-                    try {
-                        gp.getLoginContext().logout();
-                    } catch (LoginException e) {
-                        manager.getContainer().getLogger().error(
-                                sm.getString("standardSession.jaaslogoutfail"),
-                                e);
-                    }
+                try {
+                    gp.logout();
+                } catch (Exception e) {
+                    manager.getContainer().getLogger().error(
+                            sm.getString("standardSession.logoutfail"),
+                            e);
                 }
             }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message