[jboss-cvs] JBossAS SVN: r65294 - in trunk/tomcat/src/main/org/jboss/web/tomcat/service: sso and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 11 11:09:39 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-09-11 11:09:39 -0400 (Tue, 11 Sep 2007)
New Revision: 65294

Modified:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployer.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java
Log:
[JBAS-4676] Provide a dedicated cache for ClusteredSingleSignOn
[JBAS-4677] Disallow buddy replication for ClusteredSingleSignOn cache

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployer.java	2007-09-11 15:07:07 UTC (rev 65293)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployer.java	2007-09-11 15:09:39 UTC (rev 65294)
@@ -483,48 +483,6 @@
 
       server.invoke(objectName, "start", new Object[]{},
          new String[]{});
-
-      // Configure any SingleSignOn valves      
-
-      ObjectName ssoQuery = new ObjectName(catalinaDomain + ":type=Valve,*");
-      Iterator iterator = server.queryMBeans(ssoQuery, null).iterator();
-      while (iterator.hasNext())
-      {
-         ObjectName ssoObjectName =
-            ((ObjectInstance) iterator.next()).getObjectName();
-         String name = ssoObjectName.getKeyProperty("name");
-
-         /* Ensure that the SingleSignOn valve requires that each
-            request be reauthenticated to the security mgr. Should not
-            be neccessary now that we cache the principal in the session.
-         if ((name != null) && (name.indexOf("SingleSignOn") >= 0))
-         {
-            log.info("Turning on reauthentication of each request on " +
-                     ssoObjectName);
-            server.setAttribute(ssoObjectName, new Attribute
-               ("requireReauthentication", Boolean.TRUE));
-         }
-         */
-
-         // If the valve is a ClusteredSingleSignOn and we have a shared
-         // TreeCache configured, configure the valve to use the shared one
-         if (cacheName != null && "ClusteredSingleSignOn".equals(name))
-         {
-            String tcName = (String) server.getAttribute(ssoObjectName,
-               "treeCacheName");
-            tcName = (tcName != null ? tcName : DEFAULT_CACHE_NAME);
-            ObjectName ssoCacheName = new ObjectName(tcName);
-            // Only override if the valve's cacheName property was not
-            // explicitly set in server.xml to a non-default value
-            if (ssoCacheName.equals(new ObjectName(DEFAULT_CACHE_NAME)))
-            {
-               log.info("Setting the cache name to " + cacheName +
-                  " on " + ssoObjectName);
-               server.setAttribute(ssoObjectName,
-                  new Attribute("treeCacheName", cacheName));
-            }
-         }
-      }
       
       //Set up the authenticators in JNDI such that they can be configured for web apps
       InitialContext ic = new InitialContext();

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java	2007-09-11 15:07:07 UTC (rev 65293)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/sso/TreeCacheSSOClusterManager.java	2007-09-11 15:09:39 UTC (rev 65294)
@@ -46,7 +46,6 @@
 import org.jboss.cache.Node;
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionNotEmptyException;
-import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.config.Option;
 import org.jboss.cache.notifications.annotation.CacheListener;
 import org.jboss.cache.notifications.annotation.NodeModified;
@@ -101,7 +100,7 @@
     * Default global value for the cacheName property
     */
    public static final String DEFAULT_GLOBAL_CACHE_NAME =
-      "jboss.cache:service=TomcatClusteringCache";
+      "jboss.cache:service=ClusteredSSOCache";
 
    /**
     * Default global value for the threadPoolName property
@@ -191,11 +190,6 @@
    private boolean missingCacheErrorLogged = false;
    
    /**
-    * Whether our cache is using buddy replication
-    */
-   private boolean usingBuddyReplication;
-   
-   /**
     * Our node's address in the cluster.
     */
    private Serializable localAddress = null;
@@ -357,9 +351,6 @@
          if(doTx)
             tm.begin();
          
-         // Gravitate the SSO if necessary
-         gravitateSSO(ssoId);
-         
          putInTreeCache(fqn, session.getId(), null);
       }
       catch (Exception e)
@@ -443,9 +434,6 @@
       
       try
       {         
-         // Gravitate the SSO if necessary
-         gravitateSSO(ssoId);
-         
          removeFromTreeCache(fqn, false);
       }
       catch (Exception e)
@@ -480,9 +468,7 @@
       // Find the latest credential info from the cluster
       Fqn fqn = getCredentialsFqn(ssoId);
       try
-      {         
-         // Gravitate the SSO if necessary
-         gravitateSSO(ssoId);
+      {
          
          SSOCredentials data = (SSOCredentials) getFromTreeCache(fqn, KEY);
          if (data != null)
@@ -524,9 +510,6 @@
          log.trace("Registering SSO " + ssoId + " in clustered cache");
       }
       
-      // Gravitate the SSO if necessary
-      gravitateSSO(ssoId);
-      
       storeSSOData(ssoId, authType, username, password);
    }
 
@@ -580,9 +563,6 @@
          if(doTx)
             tm.begin();
          
-         // Gravitate the SSO if necessary
-         gravitateSSO(ssoId);
-         
          Set keys = getSessionKeys(ssoId);
          if (keys.contains(session.getId()))
          {
@@ -656,9 +636,6 @@
          log.trace("Updating credentials for SSO " + ssoId +
             " in clustered cache");
       }
-      
-      // Gravitate the SSO if necessary
-      gravitateSSO(ssoId);
 
       storeSSOData(ssoId, authType, username, password);
    }
@@ -682,15 +659,12 @@
          return;
       
       Fqn fqn = event.getFqn();
-      boolean isBuddyFqn = isBuddyFqn(fqn);
-      String ssoId = getIdFromFqn(fqn, isBuddyFqn);
+      String ssoId = getIdFromFqn(fqn);
       
       if (ssoId == null)
          return;
       
-      int basePos = isBuddyFqn ? 2 : 0;
-      
-      if (fqn.size() == (2 + basePos))
+      if (fqn.size() == 2)
       {
          // Entire SSO is being removed; i.e. an invalidation
          
@@ -700,7 +674,7 @@
             handleRemoteInvalidation(ssoId);
          }
       }
-      else if (fqn.size() == (4 + basePos))
+      else if (fqn.size() == 4)
       {
          // A peer is gone
          handlePeerRemoval(ssoId);
@@ -837,15 +811,14 @@
          return;
       
       Fqn fqn = event.getFqn();
-      boolean isBuddyFqn = isBuddyFqn(fqn);
-      String type = getTypeFromFqn(fqn, isBuddyFqn);
+      String type = getTypeFromFqn(fqn);
       if (CREDENTIALS.equals(type))
       {
-         handleCredentialUpdate(getIdFromFqn(fqn, isBuddyFqn), event.getData());
+         handleCredentialUpdate(getIdFromFqn(fqn), event.getData());
       }
       else if (SESSIONS.equals(type))
       {
-         handleSessionSetChange(fqn, isBuddyFqn);
+         handleSessionSetChange(fqn);
       }
    }
 
@@ -905,16 +878,15 @@
     *  
     * @param fqn an Fqn that points to the SESSIONS node of an SSO or lower
     */
-   private void handleSessionSetChange(Fqn fqn, boolean isBuddy)
+   private void handleSessionSetChange(Fqn fqn)
    {
-      int basePos = isBuddy ? 2 : 0;
       // Ignore anything not for a peer's session node
-      if (fqn.size() != (4 + basePos))
+      if (fqn.size() != 4)
          return;
 
       // Peers remove their entire node when it's empty, so any
       // other modification means it's not empty      
-      ssoValve.notifySSONotEmpty(getIdFromFqn(fqn, isBuddy));
+      ssoValve.notifySSONotEmpty(getIdFromFqn(fqn));
    }
 
    
@@ -1085,30 +1057,18 @@
       return new Fqn(objs);
    }
 
-   private boolean isBuddyFqn(Fqn fqn)
-   {
-      boolean isBuddy = usingBuddyReplication;
-   
-      if (isBuddy)
-      {
-         isBuddy = fqn.size() > 0 && BuddyManager.BUDDY_BACKUP_SUBTREE.equals(fqn.get(0));
-      }
-      return isBuddy;
-   }
-
    /**
     * Extracts an SSO session id from a fully qualified name object.
     *
     * @param fqn the Fully Qualified Name used by TreeCache
     * @return the second element in the Fqn -- the SSO session id
     */
-   private String getIdFromFqn(Fqn fqn, boolean isBuddy)
+   private String getIdFromFqn(Fqn fqn)
    {
       String id = null;
-      int basePos = isBuddy ? 2 : 0;
-      if (fqn.size() > (1 + basePos) && SSO.equals(fqn.get(0 + basePos)))
+      if (fqn.size() > 1 && SSO.equals(fqn.get(0)))
       {
-         id = (String) fqn.get(1 + basePos);
+         id = (String) fqn.get(1);
       }
       return id;
    }
@@ -1118,17 +1078,15 @@
     * object.
     *
     * @param fqn the Fully Qualified Name used by TreeCache
-    * @param isBuddy does fqn come from a buddy backup subtree?
     * @return the 3rd in the Fqn -- either
     *         {@link #CREDENTIALS CREDENTIALS} or {@link #SESSIONS SESSIONS},
     *         or <code>null</code> if <code>fqn</code> is not for an SSO.
     */
-   private String getTypeFromFqn(Fqn fqn, boolean isBuddy)
+   private String getTypeFromFqn(Fqn fqn)
    {
       String type = null;
-      int basePos = isBuddy ? 2 : 0;
-      if (fqn.size() > (2 + basePos) && SSO.equals(fqn.get(0 + basePos)))
-         type = (String) fqn.get(2 + basePos);
+      if (fqn.size() > 2 && SSO.equals(fqn.get(0)))
+         type = (String) fqn.get(2);
       return type;
    }
    
@@ -1152,19 +1110,6 @@
       }
       return keys;
    }
-   
-   private void gravitateSSO(String ssoId)
-   {
-      if (usingBuddyReplication)
-      {
-         Fqn fqn = getSingleSignOnFqn(ssoId);
-         InvocationContext ctx = cache.getInvocationContext();
-         Option opt = new Option();
-         opt.setForceDataGravitation(true);
-         ctx.setOptionOverrides(opt);
-         cache.get(fqn, "dummy");
-      }
-   }
 
    /**
     * Obtains needed configuration information from the tree cache.
@@ -1191,9 +1136,10 @@
       if (cache.getConfiguration().getBuddyReplicationConfig() != null
             && cache.getConfiguration().getBuddyReplicationConfig().isEnabled())
       {
-         usingBuddyReplication = true;    
-         log.info("Underlying cache is configured for buddy replication; use of " +
-                  "buddy replication with ClusteredSingleSignOn is not advised");
+         throw new IllegalStateException("Underlying cache is configured for " +
+                                         "buddy replication; use of buddy " +
+                                         "replication with ClusteredSingleSignOn " +
+                                         "is not supported");
       }
       
       // Find out our address




More information about the jboss-cvs-commits mailing list