geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r433220 - /geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java
Date Mon, 21 Aug 2006 10:33:23 GMT
Author: gnodet
Date: Mon Aug 21 03:33:13 2006
New Revision: 433220

URL: http://svn.apache.org/viewvc?rev=433220&view=rev
Log:
Remove the internal Key class which is not needed

Modified:
    geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java

Modified: geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java?rev=433220&r1=433219&r2=433220&view=diff
==============================================================================
--- geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java
(original)
+++ geronimo/sandbox/geronimo-jaspi/src/java/org/apache/geronimo/jaspi/AuthConfigFactoryImpl.java
Mon Aug 21 03:33:13 2006
@@ -72,15 +72,15 @@
     }
 
     public synchronized AuthConfigProvider getConfigProvider(String layer, String appContext,
RegistrationListener listener) {
-        Context ctx = (Context) registrations.get(new Key(layer, appContext).toString());
+        Context ctx = (Context) registrations.get(getRegistrationKey(layer, appContext));
         if (ctx == null) {
-            ctx = (Context) registrations.get(new Key(null, appContext).toString());
+            ctx = (Context) registrations.get(getRegistrationKey(null, appContext));
         }
         if (ctx == null) {
-            ctx = (Context) registrations.get(new Key(layer, null).toString());
+            ctx = (Context) registrations.get(getRegistrationKey(layer, null));
         }
         if (ctx == null) {
-            ctx = (Context) registrations.get(new Key(null, null).toString());
+            ctx = (Context) registrations.get(getRegistrationKey(null, null));
         }
         if (ctx != null) {
             if (listener != null) {
@@ -121,11 +121,11 @@
         if (sm != null) {
             sm.checkPermission(new AuthPermission("registerAuthConfigProvider"));
         }
-        Key key = new Key(layer, appContext);
+        String key = getRegistrationKey(layer, appContext);
         // Get or create context
-        Context ctx = (Context) registrations.get(key.toString());
+        Context ctx = (Context) registrations.get(key);
         if (ctx == null) {
-            ctx = new Context(key);
+            ctx = new Context(layer, appContext);
         }
         // Create provider
         try {
@@ -139,7 +139,7 @@
             });
             ctx.setProvider(provider);
             ctx.setDescription(description);
-            registrations.put(key.toString(), ctx);
+            registrations.put(key, ctx);
             saveConfig();
         } catch (PrivilegedActionException e) {
             Exception inner = e.getException();
@@ -159,7 +159,7 @@
             listener.notify(ctx.getMessageLayer(), ctx.getAppContext());
         }
         // Return registration Id
-        return key.toString();
+        return key;
     }
 
     public synchronized boolean removeRegistration(String registrationID) throws SecurityException
{
@@ -179,6 +179,10 @@
         return false;
     }
     
+    private String getRegistrationKey(String layer, String appContext) {
+        return layer + "/" + appContext;
+    }
+    
     private void loadConfig() throws AuthException {
         // TODO: load configuration file
     }
@@ -187,75 +191,25 @@
         // TODO: save configuration file
     }
     
-    private static class Key {
-        private final String layer;
-        private final String appContext;
-        
-        public Key(String layer, String appContext) {
-            this.layer = layer;
-            this.appContext = appContext;
-        }
-
-        public String getAppContext() {
-            return appContext;
-        }
-
-        public String getLayer() {
-            return layer;
-        }
-
-        public boolean equals(Object obj) {
-            if (!(obj instanceof Key)) {
-                return false;
-            }
-            Key oKey = (Key) obj;
-            if ((appContext == null && oKey.appContext != null) || !appContext.equals(oKey.appContext))
{
-                return false;
-            }
-            if ((layer == null && oKey.layer != null) || !layer.equals(oKey.layer))
{
-                return false;
-            }
-            return true;
-        }
-
-        public int hashCode() {
-            int h = 0;
-            if (layer != null) {
-                h ^= layer.hashCode();
-            }
-            if (appContext != null) {
-                h ^= appContext.hashCode();
-            }
-            h += ~(h << 9);
-            h ^=  (h >>> 14);
-            h +=  (h << 4);
-            h ^=  (h >>> 10);
-            return h;
-        }
-        
-        public String toString() {
-            return layer + "/" + appContext;
-        }
-
-    }
-    
     private static class Context implements RegistrationContext {
 
-        private final Key key;
+        private final String layer;
+        private final String appContext;
         private final List listeners = new ArrayList();
         private String description;
         private AuthConfigProvider provider;
         
-        public Context(Key key) {
-            this.key = key;
+        public Context(String layer, String appContext) {
+            this.layer = layer;
+            this.appContext = appContext;
         }
         
         public String getAppContext() {
-            return key.getAppContext();
+            return appContext;
         }
 
         public String getMessageLayer() {
-            return key.getLayer();
+            return layer;
         }
         
         public List getListeners() {



Mime
View raw message