[Jboss-cvs] JBossAS SVN: r55338 - branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Aug 5 11:06:31 EDT 2006


Author: ryan.campbell at jboss.com
Date: 2006-08-05 11:06:31 -0400 (Sat, 05 Aug 2006)
New Revision: 55338

Modified:
   branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java
   branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login/XMLLoginConfigMBean.java
Log:
merge in JBAS-3365

Modified: branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java	2006-08-05 14:48:28 UTC (rev 55337)
+++ branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login/XMLLoginConfig.java	2006-08-05 15:06:31 UTC (rev 55338)
@@ -1,4 +1,3 @@
-
 /*
  * JBoss, Home of Professional Open Source
  *
@@ -7,6 +6,7 @@
  */
 package org.jboss.security.auth.login;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -22,10 +22,10 @@
  @author Scott.Stark at jboss.org
  @version $Revision$
  */
-public class XMLLoginConfig extends ServiceMBeanSupport
-      implements XMLLoginConfigMBean
+public class XMLLoginConfig extends ServiceMBeanSupport implements XMLLoginConfigMBean
 {
    private XMLLoginConfigImpl config;
+
    private boolean passSecurityDomainName;
 
    public XMLLoginConfig()
@@ -33,7 +33,7 @@
       config = new XMLLoginConfigImpl();
    }
 
-// --- Begin XMLLoginConfigMBean interface methods
+   // --- Begin XMLLoginConfigMBean interface methods
 
    /** Set the URL of the XML login configuration file that should
     be loaded by this mbean on startup.
@@ -42,6 +42,7 @@
    {
       return config.getConfigURL();
    }
+
    /** Set the URL of the XML login configuration file that should
     be loaded by this mbean on startup.
     */
@@ -53,8 +54,7 @@
    /** Set the resource name of the XML login configuration file that should
     be loaded by this mbean on startup.
     */
-   public void setConfigResource(String resourceName)
-      throws IOException
+   public void setConfigResource(String resourceName) throws IOException
    {
       config.setConfigResource(resourceName);
    }
@@ -65,6 +65,7 @@
    {
       return config.getValidateDTD();
    }
+
    /** Set whether the login config xml document is validated againsts its DTD
     */
    public void setValidateDTD(boolean flag)
@@ -76,6 +77,7 @@
    {
       return passSecurityDomainName;
    }
+
    public void setPassSecurityDomainName(boolean flag)
    {
       this.passSecurityDomainName = flag;
@@ -88,6 +90,7 @@
    {
       config.addAppConfig(appName, entries);
    }
+
    /** Remove an application login configuration.
     */
    public void removeAppConfig(String appName)
@@ -107,7 +110,7 @@
    /** Load the login configuration information from the given config URL.
     * @param configURL A URL to an XML or Sun login config file.
     * @throws Exception on failure to load the configuration
-    */ 
+    */
    public String[] loadConfig(URL configURL) throws Exception
    {
       return config.loadConfig(configURL);
@@ -116,34 +119,99 @@
    public void removeConfigs(String[] appNames)
    {
       int count = appNames == null ? 0 : appNames.length;
-      for(int a = 0; a < count; a ++)
+      for (int a = 0; a < count; a++)
          removeAppConfig(appNames[a]);
    }
 
+   /**
+    * Add a new entry to an application configuration.
+    * 
+    * @param appName the name of the configuration to add the entry to
+    * @param entry the new entry
+    */
+   public void addEntry(String appName, AppConfigurationEntry entry)
+   {
+      AppConfigurationEntry[] appEntries = config.getAppConfigurationEntry(appName);
+
+      if (appEntries != null)
+      {
+         AppConfigurationEntry[] newEntries = new AppConfigurationEntry[appEntries.length + 1];
+         for (int i = 0; i < appEntries.length; i++)
+         {
+            newEntries[i] = appEntries[i];
+         }
+         newEntries[appEntries.length] = entry;
+
+         // Adding a new configuration replaces the old one
+         config.addAppConfig(appName, newEntries);
+      }
+   }
+
+   /**
+    * Remove an entry from an application configuration if the deploymentName
+    * value in its options map matches that of an entry in the configuration.
+    * 
+    * @param appName the name of the configuration to remove the entry from
+    * @param entry the entry to remove
+    */
+   public void removeEntry(String appName, AppConfigurationEntry entry)
+   {
+      AppConfigurationEntry[] appEntries = config.getAppConfigurationEntry(appName);
+
+      if (appEntries != null)
+      {
+         Map options = entry.getOptions();
+         String deploymentName = (String) options.get("deploymentName");
+         if (deploymentName == null)
+         {
+            return;
+         }
+
+         ArrayList newEntries = new ArrayList();
+
+         for (int i = 0; i < appEntries.length; i++)
+         {
+            Map tempOptions = appEntries[i].getOptions();
+            String tempDeploymentName = (String) tempOptions.get("deploymentName");
+
+            if (tempDeploymentName == null || !tempDeploymentName.equals(deploymentName))
+            {
+               newEntries.add(appEntries[i]);
+            }
+         }
+
+         AppConfigurationEntry[] entries = new AppConfigurationEntry[newEntries.size()];
+         newEntries.toArray(entries);
+
+         // Adding a new configuration replaces the old one
+         config.addAppConfig(appName, entries);
+      }
+   }
+
    /** Display the login configuration for the given application.
     */
    public String displayAppConfig(String appName)
    {
-      StringBuffer buffer = new StringBuffer("<h2>"+appName+" LoginConfiguration</h2>\n");
+      StringBuffer buffer = new StringBuffer("<h2>" + appName + " LoginConfiguration</h2>\n");
       AppConfigurationEntry[] appEntry = config.getAppConfigurationEntry(appName);
-      if( appEntry == null )
+      if (appEntry == null)
          buffer.append("No Entry\n");
       else
       {
-         for(int c = 0; c < appEntry.length; c ++)
+         for (int c = 0; c < appEntry.length; c++)
          {
             AppConfigurationEntry entry = appEntry[c];
-            buffer.append("LoginModule Class: "+entry.getLoginModuleName());
-            buffer.append("\n<br>ControlFlag: "+entry.getControlFlag());
+            buffer.append("LoginModule Class: " + entry.getLoginModuleName());
+            buffer.append("\n<br>ControlFlag: " + entry.getControlFlag());
             buffer.append("\n<br>Options:<ul>");
             Map options = entry.getOptions();
             Iterator iter = options.entrySet().iterator();
-            while( iter.hasNext() )
+            while (iter.hasNext())
             {
                Entry e = (Entry) iter.next();
                buffer.append("<li>");
-               buffer.append("name="+e.getKey());
-               buffer.append(", value="+e.getValue());
+               buffer.append("name=" + e.getKey());
+               buffer.append(", value=" + e.getValue());
                buffer.append("</li>\n");
             }
             buffer.append("</ul>\n");
@@ -151,10 +219,11 @@
       }
       return buffer.toString();
    }
-// --- End XMLLoginConfigMBean interface methods
 
-// --- Begin ServiceMBeanSupport overriden methods
+   // --- End XMLLoginConfigMBean interface methods
 
+   // --- Begin ServiceMBeanSupport overriden methods
+
    /** Load the configuration
     */
    protected void startService() throws Exception
@@ -169,6 +238,6 @@
       config.clear();
    }
 
-// --- End ServiceMBeanSupport overriden methods
+   // --- End ServiceMBeanSupport overriden methods
 
 }

Modified: branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login/XMLLoginConfigMBean.java
===================================================================
--- branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login/XMLLoginConfigMBean.java	2006-08-05 14:48:28 UTC (rev 55337)
+++ branches/JBoss_4_0_3_SP1_CP/security/src/main/org/jboss/security/auth/login/XMLLoginConfigMBean.java	2006-08-05 15:06:31 UTC (rev 55338)
@@ -8,6 +8,8 @@
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.Map;
+
 import javax.security.auth.login.AppConfigurationEntry;
 import javax.security.auth.login.Configuration;
 
@@ -16,8 +18,8 @@
 /** The managment bean interface for the XML based JAAS login configuration
  object.
 
- at author  Scott.Stark at jboss.org
- at version $Revision$
+ @author  Scott.Stark at jboss.org
+ @version $Revision$
  */
 public interface XMLLoginConfigMBean extends ServiceMBean
 {
@@ -25,6 +27,7 @@
     be loaded by this mbean on startup.
     */
    public URL getConfigURL();
+
    /** Set the URL of the XML login configuration file that should
     be loaded by this mbean on startup.
     */
@@ -38,11 +41,13 @@
    /** Get whether the login config xml document is validated againsts its DTD
     */
    public boolean getValidateDTD();
+
    /** Set whether the login config xml document is validated againsts its DTD
     */
    public void setValidateDTD(boolean flag);
 
    public boolean getPassSecurityDomainName();
+
    public void setPassSecurityDomainName(boolean flag);
 
    /** Get the XML based configuration given the Configuration it should
@@ -54,6 +59,7 @@
     the given appName will be replaced.
     */
    public void addAppConfig(String appName, AppConfigurationEntry[] entries);
+
    /** Remove an application login configuration.
     */
    public void removeAppConfig(String appName);
@@ -62,17 +68,34 @@
     * @param configURL A URL to an XML or Sun login config file.
     * @return An array of the application config names loaded
     * @throws Exception on failure to load the configuration
-    */ 
+    */
    public String[] loadConfig(URL configURL) throws Exception;
+
    /** Remove the given login configurations. This invokes removeAppConfig
     * for each element of appNames.
     * 
     * @param appNames the names of the login configurations to remove. 
-    */ 
+    */
    public void removeConfigs(String[] appNames);
 
    /** Display the login configuration for the given application.
     */
    public String displayAppConfig(String appName);
+
+   /**
+    * Add a new entry to an application configuration.
+    * 
+    * @param appName the name of the configuration to add the entry to
+    * @param entry the new entry
+    */
+   public void addEntry(String appName, AppConfigurationEntry entry);
+
+   /**
+    * Remove an entry from an application configuration if the deploymentName
+    * value in its options map matches that of an entry in the configuration.
+    * 
+    * @param appName the name of the configuration to remove the entry from
+    * @param entry the entry to remove
+    */
+   public void removeEntry(String appName, AppConfigurationEntry entry);
 }
-




More information about the jboss-cvs-commits mailing list