directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r491388 - in /directory/sandbox/triplesec-jacc/jacc: ./ src/main/java/org/apache/directory/triplesec/jacc/
Date Sun, 31 Dec 2006 05:18:12 GMT
Author: djencks
Date: Sat Dec 30 21:18:11 2006
New Revision: 491388

URL: http://svn.apache.org/viewvc?view=rev&rev=491388
Log:
add missing Policy class (copied from geronimo), feeble start on installing roles through
jacc

Added:
    directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicy.java
      - copied, changed from r491387, geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java
Modified:
    directory/sandbox/triplesec-jacc/jacc/pom.xml
    directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfiguration.java
    directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfigurationFactory.java

Modified: directory/sandbox/triplesec-jacc/jacc/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/jacc/pom.xml?view=diff&rev=491388&r1=491387&r2=491388
==============================================================================
--- directory/sandbox/triplesec-jacc/jacc/pom.xml (original)
+++ directory/sandbox/triplesec-jacc/jacc/pom.xml Sat Dec 30 21:18:11 2006
@@ -39,6 +39,11 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>triplesec-admin-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-j2ee-jacc_1.0_spec</artifactId>
         </dependency>

Copied: directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicy.java
(from r491387, geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java)
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicy.java?view=diff&rev=491388&p1=geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java&r1=491387&p2=directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicy.java&r2=491388
==============================================================================
--- geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java
(original)
+++ directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicy.java
Sat Dec 30 21:18:11 2006
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.security.jacc;
+package org.apache.directory.triplesec.jacc;
 
 import java.security.CodeSource;
 import java.security.Permission;
@@ -29,13 +29,14 @@
 /**
  * @version $Rev$ $Date$
  */
-public class GeronimoPolicy extends Policy {
+public class TripleSecPolicy extends Policy {
     private final Policy root;
-    private GeronimoPolicyConfigurationFactory factory;
+    private TripleSecPolicyConfigurationFactory factory;
     private boolean loaded;
 
-    public GeronimoPolicy() {
-        String provider = System.getProperty("org.apache.geronimo.jacc.policy.provider");
+    public TripleSecPolicy() {
+        //TODO need to review spec and think about if this level of override is necessary
+        String provider = System.getProperty("org.apache.directory.triplesec.jacc.policy.provider");
 
         if (provider == null) {
             root = Policy.getPolicy();
@@ -71,7 +72,7 @@
     public boolean implies(ProtectionDomain domain, Permission permission) {
 
         if (!loaded) {
-            factory = GeronimoPolicyConfigurationFactory.getSingleton();
+            factory = TripleSecPolicyConfigurationFactory.getSingleton();
             loaded = true;
         }
 
@@ -79,7 +80,7 @@
             String contextID = PolicyContext.getContextID();
             if (contextID != null) {
                 try {
-                    GeronimoPolicyConfiguration configuration = factory.getGeronimoPolicyConfiguration(contextID);
+                    TripleSecPolicyConfiguration configuration = factory.getTripleSecPolicyConfiguration(contextID);
 
                     if (configuration.inService()) {
                         if (configuration.implies(domain, permission)) return true;

Modified: directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfiguration.java?view=diff&rev=491388&r1=491387&r2=491388
==============================================================================
--- directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfiguration.java
(original)
+++ directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfiguration.java
Sat Dec 30 21:18:11 2006
@@ -28,6 +28,11 @@
 
 import org.apache.directory.triplesec.guardian.Profile;
 import org.apache.directory.triplesec.jaas.SafehausPrincipal;
+import org.apache.directory.triplesec.admin.dao.DaoFactory;
+import org.apache.directory.triplesec.admin.dao.ApplicationDao;
+import org.apache.directory.triplesec.admin.dao.RoleDao;
+import org.apache.directory.triplesec.admin.Application;
+import org.apache.directory.triplesec.admin.DataAccessException;
 
 
 /**
@@ -39,11 +44,18 @@
     final static int DELETED = 3;
 
     private final String contextID;
+    private RoleDao roleDao;
     private int state;
 
-    TripleSecPolicyConfiguration(String contextID) {
+
+    TripleSecPolicyConfiguration(String contextID, DaoFactory daoFactory) throws PolicyContextException
{
         this.contextID = contextID;
         this.state = OPEN;
+        try {
+            roleDao = daoFactory.getRoleDao();
+        } catch (DataAccessException e) {
+            throw new PolicyContextException("Could not access RoleDao", e);
+        }
     }
 
     public String getContextID() throws PolicyContextException {
@@ -79,7 +91,7 @@
 
     public void addToRole(String roleName, Permission permission) throws PolicyContextException
{
         if (state != OPEN) throw new UnsupportedOperationException("Not in an open state");
-
+        
         //TODO Install contextId/rolename to permission association in TripleSec LDAP
     }
 

Modified: directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfigurationFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfigurationFactory.java?view=diff&rev=491388&r1=491387&r2=491388
==============================================================================
--- directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfigurationFactory.java
(original)
+++ directory/sandbox/triplesec-jacc/jacc/src/main/java/org/apache/directory/triplesec/jacc/TripleSecPolicyConfigurationFactory.java
Sat Dec 30 21:18:11 2006
@@ -19,12 +19,16 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
+
 import javax.security.jacc.PolicyConfiguration;
 import javax.security.jacc.PolicyConfigurationFactory;
 import javax.security.jacc.PolicyContextException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.directory.triplesec.admin.dao.DaoFactory;
+import org.apache.directory.triplesec.admin.DataAccessException;
 
 /**
  * @version $Rev$ $Date$
@@ -33,7 +37,9 @@
 
     private final Log log = LogFactory.getLog(TripleSecPolicyConfigurationFactory.class);
     private static TripleSecPolicyConfigurationFactory singleton;
-    private Map configurations = new HashMap();
+
+    private final DaoFactory daoFactory;
+    private Map<String, TripleSecPolicyConfiguration> configurations = new HashMap<String,
TripleSecPolicyConfiguration>();
 
     public TripleSecPolicyConfigurationFactory() {
         synchronized (TripleSecPolicyConfigurationFactory.class) {
@@ -41,15 +47,22 @@
                 log.error("Singleton already assigned.  There may be more than one TripleSecPolicyConfigurationFactory
being used.");
                 throw new IllegalStateException("Singleton already assigned");
             }
+            Properties props = new Properties();
+            //TODO fill in the properties
+            try {
+                daoFactory = DaoFactory.createInstance(props);
+            } catch (DataAccessException e) {
+                throw new RuntimeException("Could not create DaoFactory", e);
+            }
             singleton = this;
         }
     }
 
     public PolicyConfiguration getPolicyConfiguration(String contextID, boolean remove) throws
PolicyContextException {
-        TripleSecPolicyConfiguration configuration = (TripleSecPolicyConfiguration) configurations.get(contextID);
+        TripleSecPolicyConfiguration configuration = configurations.get(contextID);
 
         if (configuration == null) {
-            configuration = new TripleSecPolicyConfiguration(contextID);
+            configuration = new TripleSecPolicyConfiguration(contextID, daoFactory);
             configurations.put(contextID, configuration);
         } else {
             configuration.open(remove);
@@ -68,5 +81,9 @@
 
     static TripleSecPolicyConfigurationFactory getSingleton() {
         return singleton;
+    }
+
+    public TripleSecPolicyConfiguration getTripleSecPolicyConfiguration(String contextID)
{
+        return configurations.get(contextID);
     }
 }



Mime
View raw message