geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r566460 - in /geronimo/server/trunk: ./ modules/geronimo-security/ modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaspi/
Date Thu, 16 Aug 2007 01:08:51 GMT
Author: djencks
Date: Wed Aug 15 18:08:50 2007
New Revision: 566460

URL: http://svn.apache.org/viewvc?view=rev&rev=566460
Log:
GERONIMO-3417 import jaspi spec, copy and update gnodet's partial implementation

Added:
    geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaspi/
    geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaspi/AuthConfigFactoryImpl.java
      - copied, changed from r550279, geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java
Modified:
    geronimo/server/trunk/modules/geronimo-security/pom.xml
    geronimo/server/trunk/pom.xml

Modified: geronimo/server/trunk/modules/geronimo-security/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-security/pom.xml?view=diff&rev=566460&r1=566459&r2=566460
==============================================================================
--- geronimo/server/trunk/modules/geronimo-security/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-security/pom.xml Wed Aug 15 18:08:50 2007
@@ -57,10 +57,10 @@
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-jacc_1.1_spec</artifactId>
         </dependency>
-        
+
         <dependency>
-            <groupId>regexp</groupId>
-            <artifactId>regexp</artifactId>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jaspi_1.0_spec</artifactId>
         </dependency>
         
         <dependency>

Copied: geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaspi/AuthConfigFactoryImpl.java
(from r550279, geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaspi/AuthConfigFactoryImpl.java?view=diff&rev=566460&p1=geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java&r1=550279&p2=geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaspi/AuthConfigFactoryImpl.java&r2=566460
==============================================================================
--- geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java
(original)
+++ geronimo/server/trunk/modules/geronimo-security/src/main/java/org/apache/geronimo/security/jaspi/AuthConfigFactoryImpl.java
Wed Aug 15 18:08:50 2007
@@ -14,11 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.geronimo.jaspi;
+package org.apache.geronimo.security.jaspi;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -37,16 +38,16 @@
 public class AuthConfigFactoryImpl extends AuthConfigFactory {
 
     private static ClassLoader contextClassLoader;
-    private Map registrations = new HashMap();
+    private Map<String, Context> registrations = new HashMap<String, Context>();
     
     static {
-        contextClassLoader = (ClassLoader) java.security.AccessController
-                        .doPrivileged(new java.security.PrivilegedAction() {
-                            public Object run() {
+        contextClassLoader = java.security.AccessController
+                        .doPrivileged(new java.security.PrivilegedAction<ClassLoader>()
{
+                            public ClassLoader run() {
                                 return Thread.currentThread().getContextClassLoader();
                             }
                         });
-    };
+    }
     
     public AuthConfigFactoryImpl() throws AuthException {
         loadConfig();
@@ -57,30 +58,29 @@
         if (sm != null) {
             sm.checkPermission(new AuthPermission("detachAuthListener"));
         }
-        List ids = new ArrayList();
-        for (Iterator it = registrations.entrySet().iterator(); it.hasNext();) {
-            Map.Entry entry = (Map.Entry) it.next();
-            Context ctx = (Context) entry.getValue();
+        List<String> ids = new ArrayList<String>();
+        for (Map.Entry<String, Context> entry : registrations.entrySet()) {
+            Context ctx = entry.getValue();
             if ((layer == null || layer.equals(ctx.getMessageLayer())) &&
-                (appContext == null || appContext.equals(ctx.getAppContext()))) {
+                    (appContext == null || appContext.equals(ctx.getAppContext()))) {
                 if (ctx.getListeners().remove(listener)) {
                     ids.add(entry.getKey());
                 }
             }
         }
-        return (String[]) ids.toArray(new String[ids.size()]);
+        return ids.toArray(new String[ids.size()]);
     }
 
     public synchronized AuthConfigProvider getConfigProvider(String layer, String appContext,
RegistrationListener listener) {
-        Context ctx = (Context) registrations.get(getRegistrationKey(layer, appContext));
+        Context ctx = registrations.get(getRegistrationKey(layer, appContext));
         if (ctx == null) {
-            ctx = (Context) registrations.get(getRegistrationKey(null, appContext));
+            ctx = registrations.get(getRegistrationKey(null, appContext));
         }
         if (ctx == null) {
-            ctx = (Context) registrations.get(getRegistrationKey(layer, null));
+            ctx = registrations.get(getRegistrationKey(layer, null));
         }
         if (ctx == null) {
-            ctx = (Context) registrations.get(getRegistrationKey(null, null));
+            ctx = registrations.get(getRegistrationKey(null, null));
         }
         if (ctx != null) {
             if (listener != null) {
@@ -92,20 +92,19 @@
     }
 
     public synchronized RegistrationContext getRegistrationContext(String registrationID)
{
-        return (Context) registrations.get(registrationID);
+        return registrations.get(registrationID);
     }
 
     public synchronized String[] getRegistrationIDs(AuthConfigProvider provider) {
-        List ids = new ArrayList();
-        for (Iterator it = registrations.entrySet().iterator(); it.hasNext();) {
-            Map.Entry entry = (Map.Entry) it.next();
-            Context ctx = (Context) entry.getValue();
+        List<String> ids = new ArrayList<String>();
+        for (Map.Entry<String, Context> entry : registrations.entrySet()) {
+            Context ctx = entry.getValue();
             if (provider == null ||
-                provider.getClass().getName().equals(ctx.getProvider().getClass().getName()))
{
+                    provider.getClass().getName().equals(ctx.getProvider().getClass().getName()))
{
                 ids.add(entry.getKey());
             }
         }
-        return (String[]) ids.toArray(new String[ids.size()]);
+        return ids.toArray(new String[ids.size()]);
     }
 
     public synchronized void refresh() throws AuthException, SecurityException {
@@ -115,7 +114,11 @@
         }
         loadConfig();
     }
-    
+
+    public String registerConfigProvider(AuthConfigProvider authConfigProvider, String string,
String string1, String string2) throws AuthException, SecurityException {
+        return null;
+    }
+
     public synchronized String registerConfigProvider(final String className, final Map properties,
String layer, String appContext, String description) throws AuthException, SecurityException
{
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
@@ -123,18 +126,18 @@
         }
         String key = getRegistrationKey(layer, appContext);
         // Get or create context
-        Context ctx = (Context) registrations.get(key);
+        Context ctx = registrations.get(key);
         if (ctx == null) {
             ctx = new Context(layer, appContext);
         }
         // Create provider
         try {
-            AuthConfigProvider provider = (AuthConfigProvider) java.security.AccessController
-            .doPrivileged(new java.security.PrivilegedExceptionAction() {
-                public Object run() throws ClassNotFoundException, SecurityException, NoSuchMethodException,
IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
 {
-                    Class cl = Class.forName(className, true, contextClassLoader);
-                    Constructor cnst = cl.getConstructor(new Class[] { Map.class });
-                    return cnst.newInstance(new Object[] { properties });
+            AuthConfigProvider provider = java.security.AccessController
+            .doPrivileged(new PrivilegedExceptionAction<AuthConfigProvider>() {
+                public AuthConfigProvider run() throws ClassNotFoundException, SecurityException,
NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException,
InvocationTargetException  {
+                    Class<? extends AuthConfigProvider> cl = (Class<? extends AuthConfigProvider>)
Class.forName(className, true, contextClassLoader);
+                    Constructor<? extends AuthConfigProvider> cnst = cl.getConstructor(Map.class);
+                    return cnst.newInstance(properties);
                 }
             });
             ctx.setProvider(provider);
@@ -153,9 +156,8 @@
             throw (AuthException) new AuthException("AuthConfigFactory error: " + e).initCause(e);
         }
         // Notify listeners
-        List listeners = ctx.getListeners();
-        for (Iterator iter = listeners.iterator(); iter.hasNext();) {
-            RegistrationListener listener = (RegistrationListener) iter.next();
+        List<RegistrationListener> listeners = ctx.getListeners();
+        for (RegistrationListener listener : listeners) {
             listener.notify(ctx.getMessageLayer(), ctx.getAppContext());
         }
         // Return registration Id
@@ -167,11 +169,10 @@
         if (sm != null) {
             sm.checkPermission(new AuthPermission("removeAuthRegistration"));
         }
-        Context ctx = (Context) registrations.remove(registrationID);
+        Context ctx = registrations.remove(registrationID);
         if (ctx != null) {
-            List listeners = ctx.getListeners();
-            for (Iterator iter = listeners.iterator(); iter.hasNext();) {
-                RegistrationListener listener = (RegistrationListener) iter.next();
+            List<RegistrationListener> listeners = ctx.getListeners();
+            for (RegistrationListener listener : listeners) {
                 listener.notify(ctx.getMessageLayer(), ctx.getAppContext());
             }
             return true;
@@ -195,7 +196,7 @@
 
         private final String layer;
         private final String appContext;
-        private final List listeners = new ArrayList();
+        private final List<RegistrationListener> listeners = new ArrayList<RegistrationListener>();
         private String description;
         private AuthConfigProvider provider;
         
@@ -211,8 +212,12 @@
         public String getMessageLayer() {
             return layer;
         }
-        
-        public List getListeners() {
+
+        public boolean isPersistent() {
+            return false;
+        }
+
+        public List<RegistrationListener> getListeners() {
             return listeners;
         }
         

Modified: geronimo/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/pom.xml?view=diff&rev=566460&r1=566459&r2=566460
==============================================================================
--- geronimo/server/trunk/pom.xml (original)
+++ geronimo/server/trunk/pom.xml Wed Aug 15 18:08:50 2007
@@ -130,6 +130,12 @@
 
             <dependency>
                 <groupId>org.apache.geronimo.specs</groupId>
+                <artifactId>geronimo-jaspi_1.0_spec</artifactId>
+                <version>1.0-SNAPSHOT</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.geronimo.specs</groupId>
                 <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
                 <version>1.0</version>
             </dependency>



Mime
View raw message