avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon/merlin/kernel/impl/conf kernel.xml
Date Wed, 25 Feb 2004 20:31:01 GMT
mcconnell    2004/02/25 12:31:01

  Modified:    merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        DefaultSecurityModel.java DefaultSystemContext.java
               merlin/kernel/impl/conf kernel.xml
  Added:       merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        DefaultModelFactory.java
  Removed:     merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
                        StandardModelFactory.java
  Log:
  Rename StandardModelFactory to DefaultModelFactory, add some javadoc on the static DefaultSecurityModel
helper methods, and populate the kernel with some standard permissions.
  
  Revision  Changes    Path
  1.2       +29 -9     avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSecurityModel.java
  
  Index: DefaultSecurityModel.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSecurityModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultSecurityModel.java	25 Feb 2004 18:55:40 -0000	1.1
  +++ DefaultSecurityModel.java	25 Feb 2004 20:31:01 -0000	1.2
  @@ -43,21 +43,41 @@
    * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
    * @version $Revision$ $Date$
    */
  -public class DefaultSecurityModel implements SecurityModel
  +public final class DefaultSecurityModel implements SecurityModel
   {
       //-------------------------------------------------------------------
       // static
       //-------------------------------------------------------------------
   
  +    private static final String PERMISSIONS_ELEMENT = "permissions";
  +    private static final String PERMISSION_ELEMENT = "permission";
  +    private static final String CLASS_ATTRIBUTE = "class";
  +    private static final String NAME_ATTRIBUTE = "name";
  +    private static final String ACTION_ELEMENT = "action";
  +    private static final String CERTIFICATES_ELEMENT = "certificates";
  +    private static final String PKCS7_ELEMENT = "pkcs7";
  +    private static final String X509_ELEMENT = "x509";
  +
       private static final Permission[] EMPTY_PERMISSIONS = new Permission[0];
       private static final Certificate[] EMPTY_CERTIFICATES = new Certificate[0];
   
  +   /**
  +    * Utility method to construct a new {@link SecurityManager} from a supplied
  +    * configuration. The configuration fragment may contain an optional 
  +    * &lt;certificates&gt; element and an optional &lt;permissions&gt;
element.
  +    * The &lt;certificates&gt; element may contain 0..n &lt;certificate&gt;

  +    * elements.  The &lt;permissions&gt; element may contain 0..n &lt;permission&gt;
  +    * elements. 
  +    *
  +    * @param config the security manager configuration
  +    * @return a new security manager
  +    */
       public static SecurityModel createSecurityModel( Configuration config )
         throws Exception
       {
  -        Configuration certs = config.getChild( "certificates" );
  +        Configuration certs = config.getChild( CERTIFICATES_ELEMENT );
           Certificate[] certificates = createCertificates( certs );
  -        Configuration grant = config.getChild( "grant" );
  +        Configuration grant = config.getChild( PERMISSIONS_ELEMENT );
           Permission[] permissions = createPermissions( grant );
           return new DefaultSecurityModel( certificates, permissions );
       }
  @@ -170,7 +190,7 @@
           {
               Configuration child = children[i];
               String name = child.getName();
  -            if( name.equals( "pkcs7" ) )
  +            if( name.equals( PKCS7_ELEMENT ) )
               {
                   Certificate[] certs = 
                     DefaultSecurityModel.createPKCS7( child );
  @@ -179,7 +199,7 @@
                       list.add( certs[j] );
                   }
               }
  -            else if( name.equals( "x509" ) )
  +            else if( name.equals( X509_ELEMENT ) )
               {
                   Certificate[] certs = 
                     DefaultSecurityModel.createX509( child );
  @@ -272,15 +292,15 @@
   
       private static Permission createPermission( Configuration config ) throws Exception
       {
  -        String classname = config.getAttribute( "class" );
  -        String name = config.getAttribute( "name", null );
  +        String classname = config.getAttribute( CLASS_ATTRIBUTE );
  +        String name = config.getAttribute( NAME_ATTRIBUTE, null );
           String actions = getActions( config );
           return createPermission( classname, name, actions );
       }
   
       private static String getActions( Configuration config ) throws ConfigurationException
       {
  -        Configuration[] actions = config.getChildren( "action" );
  +        Configuration[] actions = config.getChildren( ACTION_ELEMENT );
           if( actions.length == 0 ) return null;
           String result = "";
           for( int i=0 ; i < actions.length ; i ++ )
  
  
  
  1.21      +3 -3      avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java
  
  Index: DefaultSystemContext.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DefaultSystemContext.java	25 Feb 2004 18:55:40 -0000	1.20
  +++ DefaultSystemContext.java	25 Feb 2004 20:31:01 -0000	1.21
  @@ -29,7 +29,7 @@
   
   import org.apache.avalon.composition.model.DeploymentModel;
   import org.apache.avalon.composition.model.ContainmentModel;
  -import org.apache.avalon.composition.model.impl.StandardModelFactory;
  +import org.apache.avalon.composition.model.impl.DefaultModelFactory;
   import org.apache.avalon.composition.provider.ModelFactory;
   import org.apache.avalon.composition.provider.SystemContext;
   import org.apache.avalon.composition.provider.SystemException;
  @@ -235,7 +235,7 @@
           m_logger = m_logging.getLoggerForCategory( category );
           m_system = SystemContext.class.getClassLoader();
           m_common = DeploymentModel.class.getClassLoader();
  -        m_factory = new StandardModelFactory( this );
  +        m_factory = new DefaultModelFactory( this );
   
           //
           // use avalon-repository to load the runtime
  
  
  
  1.9       +27 -11    avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelFactory.java
  
  
  
  
  1.5       +24 -0     avalon/merlin/kernel/impl/conf/kernel.xml
  
  Index: kernel.xml
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/kernel/impl/conf/kernel.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- kernel.xml	24 Jan 2004 23:25:31 -0000	1.4
  +++ kernel.xml	25 Feb 2004 20:31:01 -0000	1.5
  @@ -8,6 +8,30 @@
        </categories>
      </logging>
   
  +   <security>
  +     <certificates/>
  +     <permissions>
  +       <permission class="java.util.PropertyPermission" name="java.*">
  +         <action>read</action>
  +       </permission>
  +       <permission class="java.util.PropertyPermission" name="os.*">
  +         <action>read</action>
  +       </permission>
  +       <permission class="java.util.PropertyPermission" name="file.separator">
  +         <action>read</action>
  +       </permission>
  +       <permission class="java.util.PropertyPermission" name="path.separator">
  +         <action>read</action>
  +       </permission>
  +       <permission class="java.util.PropertyPermission" name="line.separator">
  +         <action>read</action>
  +       </permission>
  +       <permission class="java.util.PropertyPermission" name="user.name">
  +         <action>read</action>
  +       </permission>
  +     </permissions>
  +   </security>
  +
      <repository>
        <hosts>
          <host path="http://dpml.net/"/>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message