geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r154807 - geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java
Date Tue, 22 Feb 2005 06:53:20 GMT
Author: adc
Date: Mon Feb 21 22:53:19 2005
New Revision: 154807

URL: http://svn.apache.org/viewcvs?view=rev&rev=154807
Log:
Fixed delegate handling.

Modified:
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java?view=diff&r1=154806&r2=154807
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jacc/GeronimoPolicy.java
Mon Feb 21 22:53:19 2005
@@ -22,7 +22,6 @@
 import java.security.PermissionCollection;
 import java.security.Policy;
 import java.security.ProtectionDomain;
-import javax.security.jacc.PolicyConfigurationFactory;
 import javax.security.jacc.PolicyContext;
 import javax.security.jacc.PolicyContextException;
 
@@ -36,11 +35,27 @@
     private boolean loaded;
 
     public GeronimoPolicy() {
-        this(null);
-    }
+        String provider = System.getProperty("org.apache.geronimo.jacc.policy.provider");
 
-    public GeronimoPolicy(Policy root) {
-        this.root = root;
+        if (provider == null) {
+            root = Policy.getPolicy();
+        } else {
+            try {
+                Object obj = Class.forName(provider).newInstance();
+                if (obj instanceof Policy) {
+                    root = (Policy) obj;
+                } else {
+                    throw new RuntimeException(provider + "is not a type of java.security.Policy");
+                }
+            } catch (InstantiationException e) {
+                throw new RuntimeException("Unable to create an instance of " + provider,
e);
+            } catch (IllegalAccessException e) {
+                throw new RuntimeException("Unable to create an instance of " + provider,
e);
+            } catch (ClassNotFoundException e) {
+                throw new RuntimeException("Unable to create an instance of " + provider,
e);
+            }
+        }
+        root.refresh();
     }
 
     public PermissionCollection getPermissions(CodeSource codesource) {
@@ -53,7 +68,7 @@
     public boolean implies(ProtectionDomain domain, Permission permission) {
 
         if (!loaded) {
-            factory = obtainFactory();
+            factory = GeronimoPolicyConfigurationFactory.getSingleton();
             loaded = true;
         }
 
@@ -75,15 +90,5 @@
         if (root != null) return root.implies(domain, permission);
 
         return false;
-    }
-
-    private GeronimoPolicyConfigurationFactory obtainFactory() {
-        GeronimoPolicyConfigurationFactory result = null;
-        try {
-            result = (GeronimoPolicyConfigurationFactory) PolicyConfigurationFactory.getPolicyConfigurationFactory();
-        } catch (ClassNotFoundException e) {
-        } catch (PolicyContextException e) {
-        }
-        return result;
     }
 }



Mime
View raw message