[jboss-cvs] JBossAS SVN: r76445 - in projects/security/security-jboss-sx/trunk/acl: src/main/java/org/jboss/security/acl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 29 20:15:55 EDT 2008


Author: sguilhen at redhat.com
Date: 2008-07-29 20:15:55 -0400 (Tue, 29 Jul 2008)
New Revision: 76445

Modified:
   projects/security/security-jboss-sx/trunk/acl/.classpath
   projects/security/security-jboss-sx/trunk/acl/.project
   projects/security/security-jboss-sx/trunk/acl/src/main/java/org/jboss/security/acl/ACLProviderImpl.java
Log:
SECURITY-258: ACLProviderImpl now instantiates the persistence manager using a persistenceManager option in the initialize method.



Modified: projects/security/security-jboss-sx/trunk/acl/.classpath
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/.classpath	2008-07-29 23:50:53 UTC (rev 76444)
+++ projects/security/security-jboss-sx/trunk/acl/.classpath	2008-07-30 00:15:55 UTC (rev 76445)
@@ -6,7 +6,6 @@
   <classpathentry kind="src" path="src/tests/resources" output="target/test-classes" including="**/*.xml" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.0.2/activation-1.0.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar"/>
   <classpathentry kind="var" path="M2_REPO/ant/ant-junit/1.6.5/ant-junit-1.6.5.jar"/>
   <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar"/>
@@ -17,7 +16,6 @@
   <classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
   <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate/3.2.4.sp1/hibernate-3.2.4.sp1.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.3.0.ga/hibernate-annotations-3.3.0.ga.jar"/>
@@ -25,28 +23,22 @@
   <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.3.1.ga/hibernate-entitymanager-3.3.1.ga.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-validator/3.0.0.ga/hibernate-validator-3.0.0.ga.jar"/>
   <classpathentry kind="var" path="M2_REPO/hsqldb/hsqldb/1.8.0.2/hsqldb-1.8.0.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/security/identity-impl/2.0.2-SNAPSHOT/identity-impl-2.0.2-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/security/identity-impl/2.0.2-SNAPSHOT/identity-impl-2.0.2-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="src" path="/identity-impl"/>
   <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.3.GA/javassist-3.3.GA.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.2.GA/jboss-common-core-2.0.2.GA.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.1.GA/jboss-common-core-2.2.1.GA.jar"/>
   <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA.jar"/>
   <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar"/>
   <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA.jar"/>
   <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar"/>
   <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0.Beta12/jboss-reflect-2.0.0.Beta12.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi/2.0.2.CR6/jboss-security-spi-2.0.2.CR6.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.CR10/jbossxb-2.0.0.CR10.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar"/>
   <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
   <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar"/>
   <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
 </classpath>
\ No newline at end of file

Modified: projects/security/security-jboss-sx/trunk/acl/.project
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/.project	2008-07-29 23:50:53 UTC (rev 76444)
+++ projects/security/security-jboss-sx/trunk/acl/.project	2008-07-30 00:15:55 UTC (rev 76445)
@@ -1,7 +1,9 @@
 <projectDescription>
   <name>jboss-security-acl-impl</name>
   <comment>JBoss Security is a cross cutting project that handles security for the JEMS projects</comment>
-  <projects/>
+  <projects>
+    <project>identity-impl</project>
+  </projects>
   <buildSpec>
     <buildCommand>
       <name>org.eclipse.jdt.core.javabuilder</name>

Modified: projects/security/security-jboss-sx/trunk/acl/src/main/java/org/jboss/security/acl/ACLProviderImpl.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/main/java/org/jboss/security/acl/ACLProviderImpl.java	2008-07-29 23:50:53 UTC (rev 76444)
+++ projects/security/security-jboss-sx/trunk/acl/src/main/java/org/jboss/security/acl/ACLProviderImpl.java	2008-07-30 00:15:55 UTC (rev 76445)
@@ -1,8 +1,8 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
@@ -21,6 +21,9 @@
  */
 package org.jboss.security.acl;
 
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Map;
 import java.util.Set;
 
@@ -31,8 +34,7 @@
 
 /**
  * <p>
- * This class is a simple {@code ACLProvider} implementation that maintains the ACLs in memory. It is
- * used mainly for testing purposes.
+ * This class is the standard {@code ACLProvider} implementation.
  * </p>
  * 
  * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
@@ -40,27 +42,49 @@
 public class ACLProviderImpl implements ACLProvider
 {
 
+   private static final String PERSISTENCE_STRATEGY_OPTION = "persistenceStrategy";
+
    /** persistence strategy used to retrieve the ACLs */
    private ACLPersistenceStrategy strategy;
 
-   /**
+   /*
+    * (non-Javadoc)
+    * 
     * @see org.jboss.security.acl.ACLProvider#initialize(java.util.Map, java.util.Map)
     */
    public void initialize(Map<String, Object> sharedState, Map<String, Object> options)
    {
+      String strategyClassName = (String) options.get(PERSISTENCE_STRATEGY_OPTION);
+      if (strategyClassName == null)
+         strategyClassName = "org.jboss.security.acl.JPAPersistenceStrategy";
+
+      try
+      {
+         Class<?> strategyClass = this.loadClass(strategyClassName);
+         this.strategy = (ACLPersistenceStrategy) strategyClass.newInstance();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Failed to instantiate persistence strategy class", e);
+      }
    }
 
-   /**
-    * @see org.jboss.security.acl.ACLProvider#getEntitlements(java.lang.Class, org.jboss.security.authorization.Resource,
-    *           org.jboss.security.identity.Identity)
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.jboss.security.acl.ACLProvider#getEntitlements(java.lang.Class,
+    *      org.jboss.security.authorization.Resource, org.jboss.security.identity.Identity)
     */
    public <T> Set<T> getEntitlements(Class<T> clazz, Resource resource, Identity identity)
          throws AuthorizationException
    {
+      // TODO: how to instantiate and populate T - how to traverse through resources?
       throw new NotImplementedException();
    }
 
-   /**
+   /*
+    * (non-Javadoc)
+    * 
     * @see org.jboss.security.acl.ACLProvider#getPersistenceStrategy()
     */
    public ACLPersistenceStrategy getPersistenceStrategy()
@@ -68,17 +92,23 @@
       return this.strategy;
    }
 
-   /**
+   /*
+    * (non-Javadoc)
+    * 
     * @see org.jboss.security.acl.ACLProvider#setPersistenceStrategy(org.jboss.security.acl.ACLPersistenceStrategy)
     */
    public void setPersistenceStrategy(ACLPersistenceStrategy strategy)
    {
+      if(strategy == null)
+         throw new IllegalArgumentException("PersistenceStrategy cannot be null");
       this.strategy = strategy;
    }
 
-   /**
-    * @see org.jboss.security.acl.ACLProvider#isAccessGranted(org.jboss.security.authorization.Resource, 
-    *           org.jboss.security.identity.Identity, org.jboss.security.acl.ACLPermission)
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.jboss.security.acl.ACLProvider#isAccessGranted(org.jboss.security.authorization.Resource,
+    *      org.jboss.security.identity.Identity, org.jboss.security.acl.ACLPermission)
     */
    public boolean isAccessGranted(Resource resource, Identity identity, ACLPermission permission)
          throws AuthorizationException
@@ -94,7 +124,9 @@
       throw new AuthorizationException("Unable to retrieve ACL: persistece strategy not set");
    }
 
-   /**
+   /*
+    * (non-Javadoc)
+    * 
     * @see org.jboss.security.acl.ACLProvider#tearDown()
     */
    public boolean tearDown()
@@ -102,4 +134,31 @@
       return true;
    }
 
+   /**
+    * <p>
+    * Loads the specified class using a {@code PrivilegedExceptionAction}.
+    * </p>
+    * 
+    * @param name a {@code String} containing the fully-qualified name of the class to be loaded.
+    * @return a reference to the loaded {@code Class}.
+    * @throws PrivilegedActionException if an error occurs while loading the specified class.
+    */
+   private Class<?> loadClass(final String name) throws PrivilegedActionException
+   {
+      return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>()
+      {
+         public Class<?> run() throws PrivilegedActionException
+         {
+            try
+            {
+               ClassLoader loader = Thread.currentThread().getContextClassLoader();
+               return loader.loadClass(name);
+            }
+            catch (Exception e)
+            {
+               throw new PrivilegedActionException(e);
+            }
+         }
+      });
+   }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list