tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1685674 - in /tomcat/trunk/java: javax/security/auth/message/config/AuthConfigFactory.java org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
Date Mon, 15 Jun 2015 21:34:01 GMT
Author: markt
Date: Mon Jun 15 21:34:00 2015
New Revision: 1685674

URL: http://svn.apache.org/r1685674
Log:
Initial AuthConfigFactory implementation.
Patch by fjodorver

Modified:
    tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java
    tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java

Modified: tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java?rev=1685674&r1=1685673&r2=1685674&view=diff
==============================================================================
--- tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java (original)
+++ tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java Mon Jun 15
21:34:00 2015
@@ -46,7 +46,7 @@ public abstract class AuthConfigFactory
             new SecurityPermission(PROVIDER_REGISTRATION_PERMISSION_NAME);
 
     private static final String DEFAULT_JASPI_AUTHCONFIGFACTORYIMPL =
-            "org.apache.geronimo.components.jaspi.AuthConfigFactoryImpl";
+            "org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl";
 
     private static AuthConfigFactory factory;
     private static ClassLoader contextClassLoader;

Modified: tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java?rev=1685674&r1=1685673&r2=1685674&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/AuthConfigFactoryImpl.java
Mon Jun 15 21:34:00 2015
@@ -16,6 +16,9 @@
  */
 package org.apache.catalina.authenticator.jaspic;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.security.auth.message.config.AuthConfigFactory;
@@ -24,47 +27,145 @@ import javax.security.auth.message.confi
 
 public class AuthConfigFactoryImpl extends AuthConfigFactory {
 
+    private Map<String, ConfigProviderInfo> configProviders = new HashMap<>();
+
+
     @Override
     public AuthConfigProvider getConfigProvider(String layer, String appContext,
             RegistrationListener listener) {
-        return null;
+
+        String registrationKey = getRegistrationKey(layer, appContext);
+
+        ConfigProviderInfo provider = configProviders.get(registrationKey);
+        if (provider == null) {
+            provider = configProviders.get(getRegistrationKey(null, appContext));
+        }
+        if (provider == null) {
+            provider = configProviders.get(getRegistrationKey(layer, null));
+        }
+        if (provider == null) {
+            provider = configProviders.get(getRegistrationKey(null, null));
+        }
+        if (provider == null) {
+            return null;
+        }
+
+        if (listener != null) {
+            provider.addListener(listener);
+        }
+
+        return provider.getAuthConfigProvider();
     }
 
+
     @Override
     @SuppressWarnings("rawtypes") // JASPIC API uses raw types
     public String registerConfigProvider(String className, Map properties, String layer,
             String appContext, String description) {
-        return null;
+        throw new IllegalStateException("Not implemented yet!");
     }
 
+
     @Override
     public String registerConfigProvider(AuthConfigProvider provider, String layer,
             String appContext, String description) {
-        return null;
+
+        String registrationId = getRegistrationKey(layer, appContext);
+        ConfigProviderInfo providerInfo =
+                new ConfigProviderInfo(provider, true, layer, appContext, description);
+        configProviders.put(registrationId, providerInfo);
+        return registrationId;
     }
 
+
     @Override
     public boolean removeRegistration(String registrationID) {
-        return false;
+        return configProviders.remove(registrationID) != null;
     }
 
+
     @Override
     public String[] detachListener(RegistrationListener listener, String layer, String appContext)
{
         return null;
     }
 
+
     @Override
     public String[] getRegistrationIDs(AuthConfigProvider provider) {
         return null;
     }
 
+
     @Override
     public RegistrationContext getRegistrationContext(String registrationID) {
-        return null;
+        return configProviders.get(registrationID);
     }
 
+
     @Override
     public void refresh() {
 
     }
+
+
+    private String getRegistrationKey(String layer, String appContext) {
+        return layer + "/" + appContext;
+    }
+
+
+    private static class ConfigProviderInfo implements AuthConfigFactory.RegistrationContext
{
+        private final AuthConfigProvider authConfigProvider;
+        private String appContext;
+        private String description;
+        private String messageLayer;
+        private final boolean persistent;
+        private final List<RegistrationListener> listeners = new ArrayList<>();
+
+        private ConfigProviderInfo(AuthConfigProvider authConfigProvider, boolean persistent,
+                String layer, String appContext, String description) {
+            this.authConfigProvider = authConfigProvider;
+            this.persistent = persistent;
+            this.messageLayer = layer;
+            this.appContext = appContext;
+            this.description = description;
+        }
+
+        private ConfigProviderInfo(AuthConfigProvider authConfigProvider,
+                List<RegistrationListener> listeners, boolean persistent) {
+            this.authConfigProvider = authConfigProvider;
+            this.persistent = persistent;
+        }
+
+        public AuthConfigProvider getAuthConfigProvider() {
+            return authConfigProvider;
+        }
+
+        public List<RegistrationListener> getListeners() {
+            return listeners;
+        }
+
+        public void addListener(RegistrationListener listener) {
+            listeners.add(listener);
+        }
+
+        @Override
+        public String getAppContext() {
+            return appContext;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        @Override
+        public String getMessageLayer() {
+            return messageLayer;
+        }
+
+        @Override
+        public boolean isPersistent() {
+            return persistent;
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message