geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/test/org/apache/geronimo/security SecurityServiceTest.java
Date Fri, 16 Jan 2004 02:10:46 GMT
djencks     2004/01/15 18:10:46

  Modified:    modules/core/src/java/org/apache/geronimo/security
                        AbstractModuleConfiguration.java
                        EJBModuleConfiguration.java SecurityService.java
                        WebModuleConfiguration.java
               modules/core/src/test/org/apache/geronimo/security
                        SecurityServiceTest.java
  Log:
  Fix problem with lack of no arg constructor and simplify SecurityService
  
  Revision  Changes    Path
  1.4       +3 -1      incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/AbstractModuleConfiguration.java
  
  Index: AbstractModuleConfiguration.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/AbstractModuleConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractModuleConfiguration.java	2 Jan 2004 04:31:44 -0000	1.3
  +++ AbstractModuleConfiguration.java	16 Jan 2004 02:10:46 -0000	1.4
  @@ -75,6 +75,8 @@
    */
   public abstract class AbstractModuleConfiguration implements ModuleConfiguration, GeronimoMBeanTarget
{
   
  +    public static final String BASE_OBJECT_NAME = "geronimo.security:type=ModuleConfiguration";
  +
       private String contextId;
       private GeronimoMBeanContext context;
       private PolicyConfigurationFactory factory;
  
  
  
  1.7       +1 -3      incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/EJBModuleConfiguration.java
  
  Index: EJBModuleConfiguration.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/EJBModuleConfiguration.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EJBModuleConfiguration.java	3 Jan 2004 01:09:31 -0000	1.6
  +++ EJBModuleConfiguration.java	16 Jan 2004 02:10:46 -0000	1.7
  @@ -80,8 +80,6 @@
    */
   public class EJBModuleConfiguration extends AbstractModuleConfiguration {
   
  -    public static final String BASE_OBJECT_NAME = "geronimo.security:type=EJBModuleConfiguration";
  -
       public EJBModuleConfiguration(String contextId, EjbJar ejbJar) throws GeronimoSecurityException
{
           super(contextId);
           configure(ejbJar);
  
  
  
  1.7       +19 -81    incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/SecurityService.java
  
  Index: SecurityService.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/SecurityService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SecurityService.java	4 Jan 2004 22:59:34 -0000	1.6
  +++ SecurityService.java	16 Jan 2004 02:10:46 -0000	1.7
  @@ -66,11 +66,11 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.geronimo.kernel.service.GeronimoAttributeInfo;
   import org.apache.geronimo.kernel.service.GeronimoMBeanEndpoint;
   import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
   import org.apache.geronimo.kernel.service.GeronimoOperationInfo;
   import org.apache.geronimo.kernel.service.GeronimoParameterInfo;
  -import org.apache.geronimo.kernel.service.GeronimoAttributeInfo;
   import org.apache.geronimo.security.util.ConfigurationUtil;
   
   
  @@ -86,8 +86,7 @@
   
       private String policyConfigurationFactory;
       private Collection realms = Collections.EMPTY_SET;
  -    private Collection ejbModuleConfigurations = Collections.EMPTY_SET;
  -    private Collection webModuleConfigurations = Collections.EMPTY_SET;
  +    private Collection moduleConfigurations = Collections.EMPTY_SET;
   
   
       /**
  @@ -99,19 +98,12 @@
           GeronimoMBeanInfo mbeanInfo = new GeronimoMBeanInfo();
           mbeanInfo.setTargetClass(SecurityService.class.getName());
   
  -        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("getEjbModuleConfiguration",
  +        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("getModuleConfiguration",
                   new GeronimoParameterInfo[] {
                       new GeronimoParameterInfo("contextID", String.class, ""),
                       new GeronimoParameterInfo("remove", Boolean.TYPE, "")},
                   GeronimoOperationInfo.ACTION_INFO,
  -                "Get security configuration for ejb module identified by contextID"));
  -
  -        mbeanInfo.addOperationInfo(new GeronimoOperationInfo("getWebModuleConfiguration",
  -                new GeronimoParameterInfo[] {
  -                    new GeronimoParameterInfo("contextID", String.class, ""),
  -                    new GeronimoParameterInfo("remove", Boolean.TYPE, "")},
  -                GeronimoOperationInfo.ACTION_INFO,
  -                "Get security configuration for web module identified by contextID"));
  +                "Get security configuration for module identified by contextID"));
   
           mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("PolicyConfigurationFactory",
                                                                true, true,
  @@ -119,8 +111,7 @@
                                                                (Object)"org.apache.geronimo.security.GeronimoPolicyConfigurationFactory"));
   
           mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("Realms", SecurityRealm.class,
ObjectName.getInstance(SecurityRealm.BASE_OBJECT_NAME + ",*")));
  -        mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("EJBModuleConfigurations", EJBModuleConfiguration.class,
ObjectName.getInstance(EJBModuleConfiguration.BASE_OBJECT_NAME + ",*")));
  -        mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("WebModuleConfigurations", WebModuleConfiguration.class,
ObjectName.getInstance(WebModuleConfiguration.BASE_OBJECT_NAME + ",*")));
  +        mbeanInfo.addEndpoint(new GeronimoMBeanEndpoint("ModuleConfigurations", ModuleConfiguration.class,
ObjectName.getInstance(AbstractModuleConfiguration.BASE_OBJECT_NAME + ",*")));
   
           return mbeanInfo;
       }
  @@ -178,20 +169,12 @@
           this.realms = realms;
       }
   
  -    public Collection getEJBModuleConfigurations() {
  -        return ejbModuleConfigurations;
  -    }
  -
  -    public void setEJBModuleConfigurations(Collection ejbModuleConfigurations) {
  -        this.ejbModuleConfigurations = ejbModuleConfigurations;
  +    public Collection getModuleConfigurations() {
  +        return moduleConfigurations;
       }
   
  -    public Collection getWebModuleConfigurations() {
  -        return webModuleConfigurations;
  -    }
  -
  -    public void setWebModuleConfigurations(Collection webModuleConfigurations) {
  -        this.webModuleConfigurations = webModuleConfigurations;
  +    public void setModuleConfigurations(Collection moduleConfigurations) {
  +        this.moduleConfigurations = moduleConfigurations;
       }
   
       /**
  @@ -222,67 +205,22 @@
        * @return an MBean that implements the <code>WebModuleConfigurationMBean</code>
Interface matched to the
        *                  identified policy context.
        * @throws GeronimoSecurityException if the implementation throws a checked exception
that has not been accounted for by
  -     *                  the <code>getWebModuleConfiguration</code> method signature.
  +     *                  the <code>getModuleConfiguration</code> method signature.
        */
  -    public WebModuleConfiguration getWebModuleConfiguration(String contextID, boolean remove)
throws GeronimoSecurityException {
  +    public ModuleConfiguration getModuleConfiguration(String contextID, boolean remove)
throws GeronimoSecurityException {
           assert contextID != null : "ContextID must be supplied!";
           SecurityManager sm = System.getSecurityManager();
  -        if (sm != null) sm.checkPermission(CONFIGURE);
  -
  -        for (Iterator iterator = webModuleConfigurations.iterator(); iterator.hasNext();)
{
  -            WebModuleConfiguration webModuleConfiguration = (WebModuleConfiguration) iterator.next();
  -            if (contextID.equals(webModuleConfiguration.getContextID())) {
  -                if (remove) {
  -                    webModuleConfiguration.delete();
  -                }
  -                return webModuleConfiguration;
  -            }
  +        if (sm != null) {
  +            sm.checkPermission(CONFIGURE);
           }
  -        return null;
  -    }
  -
  -    /**
  -     * <p>This method is used to obtain a EJB module configuration that corresponds
to the identified policy context.
  -     * The methods of the <code>EjbModuleConfigurationMBean</code> class are
used to map deployment descriptor
  -     * information into policy statements needed by the identified policy context as well
as the principal to roll
  -     * mapping.</p>
  -     *
  -     * <p>If at the time of the call, the identified EJB module configuration does
not exist, then the EJB module
  -     * configuration will be created and the JMX MBean that implements the context's
  -     * <code>EjbModuleConfigurationMBean</code> interface will be returned.
If the state of the identified context is
  -     * "deleted" or "inService" it will be transitioned to the "open" state as a result
of the call. The states in the
  -     * lifecycle of a policy context are defined by the <code>EjbModuleConfigurationMBean</code>
interface.</p>
  -     *
  -     * <p>For a given value of policy context identifier, this method must always
return the same instance of
  -     * <code>EjbModuleConfigurationMBean</code> and there must be at most one
actual instance of a
  -     * <code>EjbModuleConfigurationMBean</code> with a given policy context
identifier (during a process context).</p>
  -     *
  -     * <p>To preserve the invariant that there be at most one <code>EjbModuleConfigurationMBean</code>
object for a
  -     * given policy context, it may be necessary for this method to be thread safe.</p>
  -     *
  -     * @param contextID A String identifying the EJB module configuration to be returned.
The value passed to this
  -     *                  parameter must not be null.
  -     * @param remove A boolean value that establishes whether or not the security configuration
of an existing EJB
  -     *                  module is to be removed before its <code>EjbModuleConfigurationMBean</code>
object is returned.
  -     *                  If the value passed to this parameter is <code>true</code>
the security configuration of an
  -     *                  existing EJB module will be removed. If the value is <code>false</code>,
it will not be removed.
  -     * @return an MBean that implements the <code>EjbModuleConfigurationMBean</code>
Interface matched to the
  -     *                  identified policy context.
  -     * @throws GeronimoSecurityException if the implementation throws a checked exception
that has not been accounted for by
  -     *                  the <code>getEjbModuleConfiguration</code> method signature.
  -     */
  -    public EJBModuleConfiguration getEjbModuleConfiguration(String contextID, boolean remove)
throws GeronimoSecurityException {
  -        assert contextID != null : "ContextID must be supplied!";
  -        SecurityManager sm = System.getSecurityManager();
  -        if (sm != null) sm.checkPermission(CONFIGURE);
   
  -        for (Iterator iterator = ejbModuleConfigurations.iterator(); iterator.hasNext();)
{
  -            EJBModuleConfiguration ejbModuleConfiguration = (EJBModuleConfiguration) iterator.next();
  -            if (contextID.equals(ejbModuleConfiguration.getContextID())) {
  +        for (Iterator iterator = moduleConfigurations.iterator(); iterator.hasNext();)
{
  +            ModuleConfiguration moduleConfiguration = (ModuleConfiguration) iterator.next();
  +            if (contextID.equals(moduleConfiguration.getContextID())) {
                   if (remove) {
  -                    ejbModuleConfiguration.delete();
  +                    moduleConfiguration.delete();
                   }
  -                return ejbModuleConfiguration;
  +                return moduleConfiguration;
               }
           }
           return null;
  
  
  
  1.7       +1 -3      incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/WebModuleConfiguration.java
  
  Index: WebModuleConfiguration.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/WebModuleConfiguration.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WebModuleConfiguration.java	3 Jan 2004 01:09:31 -0000	1.6
  +++ WebModuleConfiguration.java	16 Jan 2004 02:10:46 -0000	1.7
  @@ -88,8 +88,6 @@
    */
   public class WebModuleConfiguration extends AbstractModuleConfiguration {
   
  -    public static final String BASE_OBJECT_NAME = "geronimo.security:type=WebModuleConfiguration";
  -
       public WebModuleConfiguration(String contextId, WebApp webApp) throws GeronimoSecurityException
{
           super(contextId);
           configure(webApp);
  
  
  
  1.3       +5 -5      incubator-geronimo/modules/core/src/test/org/apache/geronimo/security/SecurityServiceTest.java
  
  Index: SecurityServiceTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/security/SecurityServiceTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SecurityServiceTest.java	28 Dec 2003 19:34:05 -0000	1.2
  +++ SecurityServiceTest.java	16 Jan 2004 02:10:46 -0000	1.3
  @@ -57,6 +57,7 @@
   
   import java.io.File;
   import java.util.Collections;
  +import java.util.Arrays;
   
   import junit.framework.TestCase;
   import org.apache.geronimo.security.providers.PropertiesFileSecurityRealm;
  @@ -93,19 +94,18 @@
           assemblyDescriptor.setExcludeList(new ExcludeList());
           ejbJar.setAssemblyDescriptor(assemblyDescriptor);
           ejbJar.setSecurity(new Security());
  -        securityService.setEJBModuleConfigurations(Collections.singleton(new EJBModuleConfiguration("Foo",
ejbJar)));
           WebApp webApp = new WebApp();
           webApp.setSecurity(new Security());
  -        securityService.setWebModuleConfigurations(Collections.singleton(new WebModuleConfiguration("Bar",
webApp)));
  +        securityService.setModuleConfigurations(Arrays.asList(new Object[] {new EJBModuleConfiguration("Foo",
ejbJar),new WebModuleConfiguration("Bar", webApp)}));
       }
   
       public void tearDown() throws Exception {
       }
   
       public void testConfig() throws Exception {
  -        EJBModuleConfiguration ejbModuleConfiguration = securityService.getEjbModuleConfiguration("Foo",
false);
  +        ModuleConfiguration ejbModuleConfiguration = securityService.getModuleConfiguration("Foo",
false);
           assertTrue("expected an ejbModuleConfiguration", ejbModuleConfiguration != null);
  -        WebModuleConfiguration webModuleConfiguration = securityService.getWebModuleConfiguration("Bar",
false);
  +        ModuleConfiguration webModuleConfiguration = securityService.getModuleConfiguration("Bar",
false);
           assertTrue("expected a webModuleConfiguration", webModuleConfiguration != null);
       }
   }
  
  
  

Mime
View raw message