geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1098801 [1/2] - in /geronimo/components/jaspi/trunk: ./ geronimo-jaspi/ geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/ geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ geronimo-jaspi/src/main/java...
Date Mon, 02 May 2011 21:43:19 GMT
Author: djencks
Date: Mon May  2 21:43:18 2011
New Revision: 1098801

URL: http://svn.apache.org/viewvc?rev=1098801&view=rev
Log:
GERONIMO-5944 Remove use of sxc.  Refactor into separate model and implementation

Added:
    geronimo/components/jaspi/trunk/.gitignore
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthConfigImpl.java   (with props)
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthContextImpl.java   (with props)
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ConfigProviderImpl.java   (with props)
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthConfigImpl.java   (with props)
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthContextImpl.java   (with props)
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/geronimo-jaspi.xsd   (contents, props changed)
      - copied, changed from r1096035, geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/xsd/geronimo-jaspi.xsd
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/JaxbTest.java   (contents, props changed)
      - copied, changed from r1096035, geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java
Removed:
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/AuthModuleTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/ClientAuthConfigTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/ClientAuthContextTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/ConfigProviderTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/JaspiTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/MessagePolicyTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/ObjectFactoryJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/ProtectionPolicyTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/ServerAuthConfigTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/ServerAuthContextTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/TargetPolicyTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/sxc/org/apache/geronimo/components/jaspi/model/TargetTypeJAXB.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/xsd/geronimo-jaspi.xsd
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java
Modified:
    geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/AuthConfigFactoryImpl.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/AuthModuleType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthConfigType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthContextType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiUtil.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObject.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObjectMapAdapter.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/MessagePolicyType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ProtectionPolicyType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthConfigType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthContextType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetPolicyType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetType.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/package-info.java
    geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/META-INF/sun-jaxb.episode

Added: geronimo/components/jaspi/trunk/.gitignore
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/.gitignore?rev=1098801&view=auto
==============================================================================
--- geronimo/components/jaspi/trunk/.gitignore (added)
+++ geronimo/components/jaspi/trunk/.gitignore Mon May  2 21:43:18 2011
@@ -0,0 +1,8 @@
+*.i??
+.project
+.classpath
+.settings
+target
+eclipse-classes
+bin
+*.log

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml?rev=1098801&r1=1098800&r2=1098801&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml (original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/pom.xml Mon May  2 21:43:18 2011
@@ -16,7 +16,7 @@
     limitations under the License.
 -->
 
-<!-- $Rev$ $Date$ -->
+<!-- $Rev: 1032962 $ $Date: 2010-11-09 04:23:49 -0800 (Tue, 09 Nov 2010) $ -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
@@ -31,11 +31,11 @@
 
     <groupId>org.apache.geronimo.components</groupId>
     <artifactId>geronimo-jaspi</artifactId>
-    <version>1.1.2-SNAPSHOT</version>
+    <version>2.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
     <name>Apache Geronimo JASPI implementation</name>
 
-    <description>Geronimo JASPI implementation using jaxb/sxc for simple xml persistence.</description>
+    <description>Geronimo JASPI implementation using xml/jaxb for simple xml configuration.</description>
 
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/geronimo/components/jaspi/trunk/geronimo-jaspi</connection>
@@ -89,12 +89,12 @@
             <version>3.6</version>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>sxc-jaxb</artifactId>
-            <!--<version>0.8-SNAPSHOT</version>-->
-            <version>0.7.2_1</version>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>org.apache.geronimo.bundles</groupId>-->
+            <!--<artifactId>sxc-jaxb</artifactId>-->
+            <!--&lt;!&ndash;<version>0.8-SNAPSHOT</version>&ndash;&gt;-->
+            <!--<version>0.7.2_1</version>-->
+        <!--</dependency>-->
 
         <!--<dependency>-->
             <!--<groupId>org.apache.geronimo.bundles</groupId>-->
@@ -108,12 +108,12 @@
             <!--<version>2.2_1</version>-->
         <!--</dependency>-->
 
-        <dependency>
-            <groupId>com.sun.xml.bind</groupId>
-            <artifactId>jaxb-xjc</artifactId>
-            <version>2.2</version>
-            <scope>provided</scope>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>com.sun.xml.bind</groupId>-->
+            <!--<artifactId>jaxb-xjc</artifactId>-->
+            <!--<version>2.2</version>-->
+            <!--<scope>provided</scope>-->
+        <!--</dependency>-->
 
         <dependency>
             <groupId>org.testng</groupId>
@@ -161,20 +161,22 @@
                 <version>2.3.4</version>
                 <configuration>
                     <instructions>
-                        <Export-Package>org.apache.geronimo.components.jaspi*;version=1.0</Export-Package>
+                        <Export-Package>
+                            org.apache.geronimo.components.jaspi;version=2.0,
+                            org.apache.geronimo.components.jaspi.model;version=2.0
+                        </Export-Package>
                         <Export-SPI-Provider>org.apache.geronimo.components.jaspi.AuthConfigFactoryImpl</Export-SPI-Provider>
                         <Import-Package>
-                            org.apache.geronimo.components.jaspi*;version="[1.0,1.1)",
-                            com.sun.xml.bind.*:resolution:=optional,
+                            !org.apache.geronimo.components.jaspi.*,
+                            org.apache.geronimo.osgi.registry.api;resolution:=optional,
                             *
                         </Import-Package>
-                        <!-- once a maven-bundle-plugin that can interpret the impl/uses version policy is released we can remove the explicit version ranges on import-package -->
                         <_versionpolicy-impl>[$(version;==;$(@)),$(version;=+;$(@)))</_versionpolicy-impl>
                         <_versionpolicy-uses>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy-uses>
                         <Specification-Version>1.0</Specification-Version>
                         <Specification-Title>JASPIC</Specification-Title>
                         <Specification-Vendor>Sun Microsystems</Specification-Vendor>
-                        <Private-Package>org.apache.geronimo.osgi.locator;sxc*</Private-Package>
+                        <Private-Package>org.apache.geronimo.osgi.locator</Private-Package>
                         <Bundle-Activator>org.apache.geronimo.osgi.locator.Activator</Bundle-Activator>
                     </instructions>
                 </configuration>
@@ -190,7 +192,7 @@
                     <plugin>
                         <groupId>org.jvnet.jaxb2.maven2</groupId>
                         <artifactId>maven-jaxb2-plugin</artifactId>
-                        <version>0.5</version>
+                        <version>0.7.2</version>
                         <executions>
                             <execution>
                                 <goals>
@@ -199,13 +201,22 @@
                             </execution>
                         </executions>
                         <configuration>
-                            <schemaDirectory>src/main/xsd</schemaDirectory>
-                            <packageName>org.apache.geronimo.components.jaspi.model</packageName>
+                            <generatePackage>org.apache.geronimo.components.jaspi.model</generatePackage>
+                            <specVersion>2.1</specVersion>
                             <extension>true</extension>
+                            <episode>true</episode>
                         </configuration>
                     </plugin>
                 </plugins>
             </build>
+            <!--<dependencies>-->
+                <!--<dependency>-->
+                    <!--<groupId>com.sun.xml.bind</groupId>-->
+                    <!--<artifactId>jaxb-xjc</artifactId>-->
+                    <!--<version>2.2</version>-->
+                    <!--<scope>provided</scope>-->
+                <!--</dependency>-->
+            <!--</dependencies>-->
         </profile>
         <profile>
             <id>sxc-generate</id>

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/AuthConfigFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/AuthConfigFactoryImpl.java?rev=1098801&r1=1098800&r2=1098801&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/AuthConfigFactoryImpl.java (original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/AuthConfigFactoryImpl.java Mon May  2 21:43:18 2011
@@ -16,9 +16,11 @@
  */
 package org.apache.geronimo.components.jaspi;
 
+import org.apache.geronimo.components.jaspi.impl.ConfigProviderImpl;
 import org.apache.geronimo.components.jaspi.model.ConfigProviderType;
 import org.apache.geronimo.components.jaspi.model.JaspiType;
 import org.apache.geronimo.components.jaspi.model.JaspiXmlUtil;
+import org.apache.geronimo.components.jaspi.model.ObjectFactory;
 import org.xml.sax.SAXException;
 
 import javax.security.auth.AuthPermission;
@@ -30,14 +32,12 @@ import javax.xml.bind.JAXBException;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLStreamException;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -53,7 +53,8 @@ public class AuthConfigFactoryImpl exten
     public static CallbackHandler staticCallbackHandler;
 
     private static ClassLoader contextClassLoader;
-    private JaspiType jaspiType = new JaspiType();
+
+    private Map<String, ConfigProviderInfo> configProviders = Collections.emptyMap();
 
     private final CallbackHandler callbackHandler;
     private final File configFile;
@@ -94,14 +95,20 @@ public class AuthConfigFactoryImpl exten
         return file;
     }
 
+    public AuthConfigFactoryImpl(JaspiType jaspiType, CallbackHandler callbackHandler) {
+        this.callbackHandler = callbackHandler;
+        this.configFile = null;
+        initialize(jaspiType);
+    }
+
     public synchronized String[] detachListener(RegistrationListener listener, String layer, String appContext) throws SecurityException {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             sm.checkPermission(new AuthPermission("detachAuthListener"));
         }
         List<String> ids = new ArrayList<String>();
-        for (Map.Entry<String, ConfigProviderType> entry : getRegistrations().entrySet()) {
-            ConfigProviderType ctx = entry.getValue();
+        for (Map.Entry<String, ConfigProviderInfo> entry : getRegistrations().entrySet()) {
+            ConfigProviderInfo ctx = entry.getValue();
             if ((layer == null || layer.equals(ctx.getMessageLayer())) &&
                     (appContext == null || appContext.equals(ctx.getAppContext()))) {
                 if (ctx.getListeners().remove(listener)) {
@@ -112,8 +119,8 @@ public class AuthConfigFactoryImpl exten
         return ids.toArray(new String[ids.size()]);
     }
 
-    private Map<String, ConfigProviderType> getRegistrations() {
-        return jaspiType.getConfigProvider();
+    private Map<String, ConfigProviderInfo> getRegistrations() {
+        return configProviders;
     }
 
     public synchronized AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener) {
@@ -123,7 +130,7 @@ public class AuthConfigFactoryImpl exten
         if (appContext == null) {
             throw new NullPointerException("appContext");
         }
-        ConfigProviderType ctx = getRegistrations().get(ConfigProviderType.getRegistrationKey(layer, appContext));
+        ConfigProviderInfo ctx = getRegistrations().get(ConfigProviderType.getRegistrationKey(layer, appContext));
         if (ctx == null) {
             ctx = getRegistrations().get(ConfigProviderType.getRegistrationKey(null, appContext));
         }
@@ -137,7 +144,7 @@ public class AuthConfigFactoryImpl exten
             if (listener != null) {
                 ctx.getListeners().add(listener);
             }
-            return ctx.getProvider();
+            return ctx.getAuthConfigProvider();
         }
         return null;
     }
@@ -148,10 +155,10 @@ public class AuthConfigFactoryImpl exten
 
     public synchronized String[] getRegistrationIDs(AuthConfigProvider provider) {
         List<String> ids = new ArrayList<String>();
-        for (Map.Entry<String, ConfigProviderType> entry : getRegistrations().entrySet()) {
-            ConfigProviderType ctx = entry.getValue();
+        for (Map.Entry<String, ConfigProviderInfo> entry : getRegistrations().entrySet()) {
+            ConfigProviderInfo ctx = entry.getValue();
             if (provider == null ||
-                    provider.getClass().getName().equals(ctx.getProvider().getClass().getName())) {
+                    provider.getClass().getName().equals(ctx.getAuthConfigProvider().getClass().getName())) {
                 ids.add(entry.getKey());
             }
         }
@@ -187,16 +194,18 @@ public class AuthConfigFactoryImpl exten
     private String registerConfigProvider(AuthConfigProvider provider, String layer, String appContext, String description, boolean persistent, Map<String, String> constructorParam, String className) {
         String key = ConfigProviderType.getRegistrationKey(layer, appContext);
         // Get or create context
-        ConfigProviderType ctx = getRegistrations().get(key);
-        if (ctx == null) {
-            ctx = new ConfigProviderType(layer, appContext, persistent, persistent? null: this);
-            getRegistrations().put(key, ctx);
+        ConfigProviderInfo info = getRegistrations().get(key);
+        List<RegistrationListener> listeners;
+        if (info == null) {
+            listeners = new ArrayList<RegistrationListener>();
         } else {
-            if (persistent != ctx.isPersistent()) {
+            if (persistent != info.isPersistent()) {
                 throw new IllegalArgumentException("Cannot change the persistence state");
             }
+            listeners = info.getListeners();
         }
         // Create provider
+        ConfigProviderType ctx = new ConfigProviderType(layer, appContext, persistent, persistent? null: this);
         ctx.setDescription(description);
         if (persistent) {
             if (provider != null) {
@@ -204,18 +213,18 @@ public class AuthConfigFactoryImpl exten
             }
             ctx.setClassName(className);
             ctx.setProperties(constructorParam);
-            ctx.initialize(callbackHandler);
+            provider = ConfigProviderImpl.newConfigProvider(this, ctx);
         } else {
             if (provider == null) {
                 throw new IllegalStateException("No config provider to set");
             }
-            ctx.setProvider(provider);
         }
+        info = new ConfigProviderInfo(provider, ctx, listeners, persistent);
+        getRegistrations().put(key, info);
 
         // Notify listeners
-        List<RegistrationListener> listeners = ctx.getListeners();
         for (RegistrationListener listener : listeners) {
-            listener.notify(ctx.getMessageLayer(), ctx.getAppContext());
+            listener.notify(info.getMessageLayer(), info.getAppContext());
         }
         // Return registration Id
         return key;
@@ -226,7 +235,7 @@ public class AuthConfigFactoryImpl exten
         if (sm != null) {
             sm.checkPermission(new AuthPermission("removeAuthRegistration"));
         }
-        ConfigProviderType ctx = getRegistrations().remove(registrationID);
+        ConfigProviderInfo ctx = getRegistrations().remove(registrationID);
         saveConfig();
         if (ctx != null) {
             List<RegistrationListener> listeners = ctx.getListeners();
@@ -240,6 +249,7 @@ public class AuthConfigFactoryImpl exten
 
     private void loadConfig() {
         if (configFile != null && configFile.length() > 0) {
+            JaspiType jaspiType;
             try {
                 FileReader in = new FileReader(configFile);
                 try {
@@ -258,14 +268,36 @@ public class AuthConfigFactoryImpl exten
             } catch (XMLStreamException e) {
                 throw new SecurityException("Could not read config", e);
             }
+            initialize(jaspiType);
+        }
+    }
+
+    private void initialize(JaspiType jaspiType) {
+        Map<String, ConfigProviderInfo> configProviderInfos = new HashMap<String, ConfigProviderInfo>();
+        try {
+            for (ConfigProviderType configProviderType: jaspiType.getConfigProvider()) {
+                AuthConfigProvider authConfigProvider = ConfigProviderImpl.newConfigProvider(this, configProviderType);
+                ConfigProviderInfo info = new ConfigProviderInfo(authConfigProvider, configProviderType, true);
+                configProviderInfos.put(configProviderType.getKey(), info);
+            }
+        } catch (Exception e) {
+            throw new SecurityException("Could not map config providers", e);
         }
+        this.configProviders = configProviderInfos;
     }
 
+
     private void saveConfig() {
         if (configFile != null) {
+            JaspiType jaspiType = new ObjectFactory().createJaspiType();
+
             try {
-                OutputStream outStream = new FileOutputStream(configFile);
-                Writer out = new OutputStreamWriter(outStream, "UTF-8");
+                for (ConfigProviderInfo info: configProviders.values()) {
+                    if (info.isPersistent()) {
+                        jaspiType.getConfigProvider().add(info.getConfigProviderType());
+                    }
+                }
+                FileWriter out = new FileWriter(configFile);
                 try {
                     JaspiXmlUtil.writeJaspi(jaspiType, out);
                 } finally {
@@ -277,9 +309,64 @@ public class AuthConfigFactoryImpl exten
                 throw new SecurityException("Could not write config", e);
             } catch (JAXBException e) {
                 throw new SecurityException("Could not write config", e);
+            } catch (Exception e) {
+                throw new SecurityException("Could not write config", e);
             }
         }
     }
 
 
+    private static class ConfigProviderInfo implements AuthConfigFactory.RegistrationContext {
+        private final AuthConfigProvider authConfigProvider;
+        private final ConfigProviderType configProviderType;
+        private final boolean persistent;
+        private final List<RegistrationListener> listeners;
+
+        private ConfigProviderInfo(AuthConfigProvider authConfigProvider, ConfigProviderType configProviderType, boolean persistent) {
+            this.authConfigProvider = authConfigProvider;
+            this.configProviderType = configProviderType;
+            this.persistent = persistent;
+            listeners = new ArrayList<RegistrationListener>();
+        }
+
+        private ConfigProviderInfo(AuthConfigProvider authConfigProvider, ConfigProviderType configProviderType, List<RegistrationListener> listeners, boolean persistent) {
+            this.authConfigProvider = authConfigProvider;
+            this.configProviderType = configProviderType;
+            this.listeners = listeners;
+            this.persistent = persistent;
+        }
+
+        public AuthConfigProvider getAuthConfigProvider() {
+            return authConfigProvider;
+        }
+
+        public ConfigProviderType getConfigProviderType() {
+            return configProviderType;
+        }
+
+        public List<RegistrationListener> getListeners() {
+            return listeners;
+        }
+
+        @Override
+        public String getAppContext() {
+            return configProviderType.getAppContext();
+        }
+
+        @Override
+        public String getDescription() {
+            return configProviderType.getDescription();
+        }
+
+        @Override
+        public String getMessageLayer() {
+            return configProviderType.getMessageLayer();
+        }
+
+        @Override
+        public boolean isPersistent() {
+            return persistent;
+        }
+    }
+
 }

Added: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthConfigImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthConfigImpl.java?rev=1098801&view=auto
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthConfigImpl.java (added)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthConfigImpl.java Mon May  2 21:43:18 2011
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.components.jaspi.impl;
+
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.MessageInfo;
+import javax.security.auth.message.config.ClientAuthConfig;
+import javax.security.auth.message.config.ClientAuthContext;
+import org.apache.geronimo.components.jaspi.model.ClientAuthConfigType;
+
+/**
+* @version $Rev:$ $Date:$
+*/
+public class ClientAuthConfigImpl implements ClientAuthConfig {
+
+    private final ClientAuthConfigType clientAuthConfigType;
+    private final Map<String, ClientAuthContext> clientAuthContextMap;
+
+    public ClientAuthConfigImpl(ClientAuthConfigType clientAuthConfigType, Map<String, ClientAuthContext> clientAuthContextMap) {
+        this.clientAuthConfigType = clientAuthConfigType;
+        this.clientAuthContextMap = clientAuthContextMap;
+    }
+
+    public ClientAuthContext getAuthContext(String authContextID, Subject clientSubject, Map properties) throws AuthException {
+        return clientAuthContextMap.get(authContextID);
+    }
+
+    public String getAppContext() {
+        return clientAuthConfigType.getAppContext();
+    }
+
+    public String getAuthContextID(MessageInfo messageInfo) throws IllegalArgumentException {
+        return clientAuthConfigType.getAuthContextID(messageInfo);
+    }
+
+    public String getMessageLayer() {
+        return clientAuthConfigType.getMessageLayer();
+    }
+
+    public boolean isProtected() {
+        return clientAuthConfigType.isProtected();
+    }
+
+    public void refresh() throws SecurityException {
+    }
+}

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthConfigImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthConfigImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthConfigImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthContextImpl.java?rev=1098801&view=auto
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthContextImpl.java (added)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthContextImpl.java Mon May  2 21:43:18 2011
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.components.jaspi.impl;
+
+import java.util.List;
+
+import javax.security.auth.Subject;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.AuthStatus;
+import javax.security.auth.message.MessageInfo;
+import javax.security.auth.message.config.ClientAuthContext;
+import javax.security.auth.message.module.ClientAuthModule;
+
+/**
+* @version $Rev:$ $Date:$
+*/
+public class ClientAuthContextImpl implements ClientAuthContext {
+
+    private final List<ClientAuthModule> clientAuthModules;
+
+    public ClientAuthContextImpl(List<ClientAuthModule> clientAuthModules) {
+        this.clientAuthModules = clientAuthModules;
+    }
+
+    public void cleanSubject(MessageInfo messageInfo, Subject subject) throws AuthException {
+        for (ClientAuthModule clientAuthModule : clientAuthModules) {
+            clientAuthModule.cleanSubject(messageInfo, subject);
+        }
+    }
+
+    public AuthStatus secureRequest(MessageInfo messageInfo, Subject clientSubject) throws AuthException {
+        for (ClientAuthModule clientAuthModule : clientAuthModules) {
+            AuthStatus result = clientAuthModule.secureRequest(messageInfo, clientSubject);
+
+            //jaspi spec p 74
+            if (result == AuthStatus.SUCCESS) {
+                continue;
+            }
+            if (result == AuthStatus.SEND_CONTINUE || result == AuthStatus.FAILURE) {
+                return result;
+            }
+            throw new AuthException("Invalid AuthStatus " + result + " from client auth module: " + clientAuthModule);
+        }
+        return AuthStatus.SUCCESS;
+    }
+
+    public AuthStatus validateResponse(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
+        for (ClientAuthModule clientAuthModule : clientAuthModules) {
+            AuthStatus result = clientAuthModule.validateResponse(messageInfo, clientSubject, serviceSubject);
+
+            //jaspi spec p 74
+            if (result == AuthStatus.SUCCESS) {
+                continue;
+            }
+            if (result == AuthStatus.SEND_CONTINUE || result == AuthStatus.FAILURE) {
+                return result;
+            }
+            throw new AuthException("Invalid AuthStatus " + result + " from client auth module: " + clientAuthModule);
+        }
+        return AuthStatus.SUCCESS;
+    }
+}

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthContextImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ClientAuthContextImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ConfigProviderImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ConfigProviderImpl.java?rev=1098801&view=auto
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ConfigProviderImpl.java (added)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ConfigProviderImpl.java Mon May  2 21:43:18 2011
@@ -0,0 +1,347 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.components.jaspi.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.MessagePolicy;
+import javax.security.auth.message.config.AuthConfigFactory;
+import javax.security.auth.message.config.AuthConfigProvider;
+import javax.security.auth.message.config.ClientAuthConfig;
+import javax.security.auth.message.config.ClientAuthContext;
+import javax.security.auth.message.config.ServerAuthConfig;
+import javax.security.auth.message.config.ServerAuthContext;
+import javax.security.auth.message.module.ClientAuthModule;
+import javax.security.auth.message.module.ServerAuthModule;
+import org.apache.geronimo.components.jaspi.model.AuthModuleType;
+import org.apache.geronimo.components.jaspi.model.ClientAuthConfigType;
+import org.apache.geronimo.components.jaspi.model.ClientAuthContextType;
+import org.apache.geronimo.components.jaspi.model.ConfigProviderType;
+import org.apache.geronimo.components.jaspi.model.KeyedObjectMapAdapter;
+import org.apache.geronimo.components.jaspi.model.MessagePolicyType;
+import org.apache.geronimo.components.jaspi.model.ProtectionPolicyType;
+import org.apache.geronimo.components.jaspi.model.ServerAuthConfigType;
+import org.apache.geronimo.components.jaspi.model.ServerAuthContextType;
+import org.apache.geronimo.components.jaspi.model.TargetPolicyType;
+import org.apache.geronimo.components.jaspi.model.TargetType;
+import org.apache.geronimo.osgi.locator.ProviderLocator;
+
+/**
+* @version $Rev:$ $Date:$
+*/
+public class ConfigProviderImpl implements AuthConfigProvider {
+
+    private final Map<String, ClientAuthConfigType> clientConfigTypeMap;
+    private final Map<String, ServerAuthConfigType> serverAuthConfigMap;
+
+    public ConfigProviderImpl(List<ClientAuthConfigType> clientAuthConfigTypes, List<ServerAuthConfigType> serverAuthConfigTypes) {
+        try {
+            this.clientConfigTypeMap =  new KeyedObjectMapAdapter<ClientAuthConfigType>().unmarshal(clientAuthConfigTypes);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        try {
+            this.serverAuthConfigMap = new KeyedObjectMapAdapter<ServerAuthConfigType>().unmarshal(serverAuthConfigTypes);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * spec required constructor
+     * @param properties useless properties map
+     * @param factory useless factory
+     */
+    public ConfigProviderImpl(Map<String, String> properties, AuthConfigFactory factory) {
+        throw new RuntimeException("don't call this");
+    }
+
+    public ClientAuthConfig getClientAuthConfig(String layer, String appContext, CallbackHandler handler) throws AuthException, SecurityException {
+        if (layer == null) {
+            throw new NullPointerException("messageLayer");
+        }
+        if (appContext == null) {
+            throw new NullPointerException("appContext");
+        }
+        ClientAuthConfigType ctx = clientConfigTypeMap.get(ConfigProviderType.getRegistrationKey(layer, appContext));
+        if (ctx == null) {
+            ctx = clientConfigTypeMap.get(ConfigProviderType.getRegistrationKey(null, appContext));
+        }
+        if (ctx == null) {
+            ctx = clientConfigTypeMap.get(ConfigProviderType.getRegistrationKey(layer, null));
+        }
+        if (ctx == null) {
+            ctx = clientConfigTypeMap.get(ConfigProviderType.getRegistrationKey(null, null));
+        }
+        if (ctx != null) {
+
+            return newClientAuthConfig(ctx, layer, appContext, handler);
+        }
+        throw new AuthException("No suitable ClientAuthConfig");
+    }
+
+    public ServerAuthConfig getServerAuthConfig(String layer, String appContext, CallbackHandler handler) throws AuthException, SecurityException {
+        if (layer == null) {
+            throw new NullPointerException("messageLayer");
+        }
+        if (appContext == null) {
+            throw new NullPointerException("appContext");
+        }
+        ServerAuthConfigType ctx = serverAuthConfigMap.get(ConfigProviderType.getRegistrationKey(layer, appContext));
+        if (ctx == null) {
+            ctx = serverAuthConfigMap.get(ConfigProviderType.getRegistrationKey(null, appContext));
+        }
+        if (ctx == null) {
+            ctx = serverAuthConfigMap.get(ConfigProviderType.getRegistrationKey(layer, null));
+        }
+        if (ctx == null) {
+            ctx = serverAuthConfigMap.get(ConfigProviderType.getRegistrationKey(null, null));
+        }
+        if (ctx != null) {
+
+            return newServerAuthConfig(ctx, layer, appContext, handler);
+        }
+        throw new AuthException("No suitable ServerAuthConfig");
+    }
+
+    public void refresh() throws SecurityException {
+    }
+
+    public static AuthConfigProvider newConfigProvider(final AuthConfigFactory authConfigFactory, final ConfigProviderType configProviderType) {
+        AuthConfigProvider provider;
+        if (configProviderType.getClassName() == null) {
+            provider = new ConfigProviderImpl(configProviderType.getClientAuthConfig(), configProviderType.getServerAuthConfig());
+        } else {
+            try {
+                provider = java.security.AccessController
+                .doPrivileged(new PrivilegedExceptionAction<AuthConfigProvider>() {
+                    public AuthConfigProvider run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
+                        Class<? extends AuthConfigProvider> cl = ProviderLocator.loadClass(configProviderType.getClassName(), getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(AuthConfigProvider.class);
+                        Constructor<? extends AuthConfigProvider> cnst = cl.getConstructor(Map.class, AuthConfigFactory.class);
+                        return cnst.newInstance(configProviderType.getProperties(), authConfigFactory);
+                    }
+                });
+            } catch (PrivilegedActionException e) {
+                Exception inner = e.getException();
+                if (inner instanceof InstantiationException) {
+                    throw new SecurityException("AuthConfigFactory error:"
+                                    + inner.getCause().getMessage(), inner.getCause());
+                } else {
+                    throw new SecurityException("AuthConfigFactory error: " + inner, inner);
+                }
+            } catch (Exception e) {
+                throw new SecurityException("AuthConfigFactory error: " + e, e);
+            }
+        }
+        return provider;
+    }
+
+    static ClientAuthConfig newClientAuthConfig(ClientAuthConfigType clientAuthConfigType, String messageLayer, String appContext, CallbackHandler callbackHandler) throws AuthException {
+        Map<String, ClientAuthContext> authContextMap = new HashMap<String, ClientAuthContext>();
+        for (ClientAuthContextType clientAuthContextType: clientAuthConfigType.getClientAuthContext()) {
+            if (match(clientAuthContextType, messageLayer, appContext)) {
+                ClientAuthContext clientAuthContext = newClientAuthContext(clientAuthContextType, callbackHandler);
+                String authContextID = clientAuthContextType.getAuthenticationContextID();
+                if (authContextID == null) {
+                    authContextID = clientAuthConfigType.getAuthenticationContextID();
+                }
+                if (!authContextMap.containsKey(authContextID)) {
+                    authContextMap.put(authContextID,  clientAuthContext);
+                }
+            }
+        }
+        return new ClientAuthConfigImpl(clientAuthConfigType, authContextMap);
+    }
+
+    static ClientAuthContext newClientAuthContext(ClientAuthContextType clientAuthContextType, CallbackHandler callbackHandler) throws AuthException {
+        List<ClientAuthModule> clientAuthModules = new ArrayList<ClientAuthModule>();
+        for (AuthModuleType<ClientAuthModule> clientAuthModuleType: clientAuthContextType.getClientAuthModule()) {
+            ClientAuthModule instance = newAuthModule(clientAuthModuleType, callbackHandler);
+            clientAuthModules.add(instance);
+        }
+        return new ClientAuthContextImpl(clientAuthModules);
+    }
+
+    private static boolean match(ClientAuthContextType clientAuthContextType, String messageLayer, String appContext) {
+        if (messageLayer == null) throw new NullPointerException("messageLayer");
+        if (appContext == null) throw new NullPointerException("appContext");
+        if (messageLayer.equals(clientAuthContextType.getMessageLayer())) {
+            return appContext.equals(clientAuthContextType.getAppContext()) || clientAuthContextType.getAppContext() == null;
+        }
+        if (clientAuthContextType.getMessageLayer() == null) {
+            return appContext.equals(clientAuthContextType.getAppContext()) || clientAuthContextType.getAppContext() == null;
+        }
+        return false;
+    }
+
+
+    static ServerAuthConfig newServerAuthConfig(ServerAuthConfigType serverAuthConfigType, String messageLayer, String appContext, CallbackHandler callbackHandler) throws AuthException {
+        Map<String, ServerAuthContext> authContextMap = new HashMap<String, ServerAuthContext>();
+        for (ServerAuthContextType serverAuthContextType: serverAuthConfigType.getServerAuthContext()) {
+            if (match(serverAuthContextType, messageLayer, appContext)) {
+                ServerAuthContext serverAuthContext = newServerAuthContext(serverAuthContextType, callbackHandler);
+                String authContextID = serverAuthContextType.getAuthenticationContextID();
+                if (authContextID == null) {
+                    authContextID = serverAuthConfigType.getAuthenticationContextID();
+                }
+                if (!authContextMap.containsKey(authContextID)) {
+                    authContextMap.put(authContextID,  serverAuthContext);
+                }
+            }
+        }
+        return new ServerAuthConfigImpl(serverAuthConfigType, authContextMap);
+    }
+
+    static ServerAuthContext newServerAuthContext(ServerAuthContextType serverAuthContextType, CallbackHandler callbackHandler) throws AuthException {
+        List<ServerAuthModule> serverAuthModules = new ArrayList<ServerAuthModule>();
+        for (AuthModuleType<ServerAuthModule> serverAuthModuleType: serverAuthContextType.getServerAuthModule()) {
+            ServerAuthModule instance = newAuthModule(serverAuthModuleType, callbackHandler);
+            serverAuthModules.add(instance);
+        }
+        return new ServerAuthContextImpl(serverAuthModules);
+    }
+
+    private static boolean match(ServerAuthContextType serverAuthContextType, String messageLayer, String appContext) {
+        if (messageLayer == null) throw new NullPointerException("messageLayer");
+        if (appContext == null) throw new NullPointerException("appContext");
+        if (messageLayer.equals(serverAuthContextType.getMessageLayer())) {
+            return appContext.equals(serverAuthContextType.getAppContext()) || serverAuthContextType.getAppContext() == null;
+        }
+        if (serverAuthContextType.getMessageLayer() == null) {
+            return appContext.equals(serverAuthContextType.getAppContext()) || serverAuthContextType.getAppContext() == null;
+        }
+        return false;
+    }
+
+    static <T> T newAuthModule(final AuthModuleType authModuleType, final CallbackHandler callbackHandler) throws AuthException {
+        T authModule;
+        try {
+            authModule = java.security.AccessController
+            .doPrivileged(new PrivilegedExceptionAction<T>() {
+                public T run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, AuthException {
+                    Class<? extends T> cl = (Class<? extends T>) ProviderLocator.loadClass(authModuleType.getClassName(), getClass(), Thread.currentThread().getContextClassLoader());
+                    Constructor<? extends T> cnst = cl.getConstructor();
+                    T authModule = cnst.newInstance();
+                    Method m = cl.getMethod("initialize", MessagePolicy.class, MessagePolicy.class, CallbackHandler.class, Map.class);
+                    MessagePolicy reqPolicy = newMessagePolicy(authModuleType.getRequestPolicy());
+                    MessagePolicy respPolicy = newMessagePolicy(authModuleType.getResponsePolicy());
+                    m.invoke(authModule, reqPolicy, respPolicy, callbackHandler, authModuleType.getOptions());
+                    return authModule;
+                }
+            });
+        } catch (PrivilegedActionException e) {
+            Exception inner = e.getException();
+            if (inner instanceof InstantiationException) {
+                throw (AuthException) new AuthException("AuthConfigFactory error:"
+                                + inner.getCause().getMessage()).initCause(inner.getCause());
+            } else {
+                throw (AuthException) new AuthException("AuthConfigFactory error: " + inner).initCause(inner);
+            }
+        } catch (Exception e) {
+            throw (AuthException) new AuthException("AuthConfigFactory error: " + e).initCause(e);
+        }
+        return authModule;
+    }
+
+    private static MessagePolicy newMessagePolicy(MessagePolicyType messagePolicyType) throws AuthException {
+        if (messagePolicyType == null) {
+            return null;
+        }
+        if (messagePolicyType.getTargetPolicy().size() == 0) {
+            return null;
+        }
+        MessagePolicy.TargetPolicy[] targetPolicies = new MessagePolicy.TargetPolicy[messagePolicyType.getTargetPolicy().size()];
+        int i = 0;
+        for (TargetPolicyType targetPolicyType: messagePolicyType.getTargetPolicy()) {
+            targetPolicies[i++] = newTargetPolicy(targetPolicyType);
+        }
+        return new MessagePolicy(targetPolicies, messagePolicyType.isMandatory());
+    }
+
+    private static MessagePolicy.TargetPolicy newTargetPolicy(TargetPolicyType targetPolicyType) throws AuthException {
+        MessagePolicy.Target[] targets = new MessagePolicy.Target[targetPolicyType.getTarget().size()];
+        int i = 0;
+        for (TargetType targetType: targetPolicyType.getTarget()) {
+            targets[i++] = newTarget(targetType);
+        }
+        return new MessagePolicy.TargetPolicy(targets, newProtectionPolicy(targetPolicyType.getProtectionPolicy()));
+    }
+
+    private static MessagePolicy.Target newTarget(final TargetType targetType) throws AuthException {
+        try {
+            return java.security.AccessController
+            .doPrivileged(new PrivilegedExceptionAction<MessagePolicy.Target>() {
+                public MessagePolicy.Target run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
+                    Class<? extends MessagePolicy.Target> cl = ProviderLocator.loadClass(targetType.getClassName(), getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(MessagePolicy.Target.class);
+                    Constructor<? extends MessagePolicy.Target> cnst = cl.getConstructor();
+                    MessagePolicy.Target target = cnst.newInstance();
+                    return target;
+                }
+            });
+        } catch (PrivilegedActionException e) {
+            Exception inner = e.getException();
+            if (inner instanceof InstantiationException) {
+                throw (AuthException) new AuthException("AuthConfigFactory error:"
+                                + inner.getCause().getMessage()).initCause(inner.getCause());
+            } else {
+                throw (AuthException) new AuthException("AuthConfigFactory error: " + inner).initCause(inner);
+            }
+        } catch (Exception e) {
+            throw (AuthException) new AuthException("AuthConfigFactory error: " + e).initCause(e);
+        }
+
+    }
+
+    private static MessagePolicy.ProtectionPolicy newProtectionPolicy(final ProtectionPolicyType protectionPolicyType) throws AuthException {
+        try {
+            return java.security.AccessController
+            .doPrivileged(new PrivilegedExceptionAction<MessagePolicy.ProtectionPolicy>() {
+                public MessagePolicy.ProtectionPolicy run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
+                    Class<? extends MessagePolicy.ProtectionPolicy> cl = ProviderLocator.loadClass(protectionPolicyType.getClassName(), getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(MessagePolicy.ProtectionPolicy.class);
+                    Constructor<? extends MessagePolicy.ProtectionPolicy> cnst = cl.getConstructor();
+                    MessagePolicy.ProtectionPolicy target = cnst.newInstance();
+                    return target;
+                }
+            });
+        } catch (PrivilegedActionException e) {
+            Exception inner = e.getException();
+            if (inner instanceof InstantiationException) {
+                throw (AuthException) new AuthException("AuthConfigFactory error:"
+                                + inner.getCause().getMessage()).initCause(inner.getCause());
+            } else {
+                throw (AuthException) new AuthException("AuthConfigFactory error: " + inner).initCause(inner);
+            }
+        } catch (Exception e) {
+            throw (AuthException) new AuthException("AuthConfigFactory error: " + e).initCause(e);
+        }
+    }
+
+}

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ConfigProviderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ConfigProviderImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ConfigProviderImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthConfigImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthConfigImpl.java?rev=1098801&view=auto
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthConfigImpl.java (added)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthConfigImpl.java Mon May  2 21:43:18 2011
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.components.jaspi.impl;
+
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.MessageInfo;
+import javax.security.auth.message.config.ServerAuthConfig;
+import javax.security.auth.message.config.ServerAuthContext;
+import org.apache.geronimo.components.jaspi.model.ServerAuthConfigType;
+
+/**
+* @version $Rev:$ $Date:$
+*/
+public class ServerAuthConfigImpl implements ServerAuthConfig {
+
+    private final ServerAuthConfigType serverAuthConfigType;
+    private final Map<String, ServerAuthContext> serverAuthContextMap;
+
+    public ServerAuthConfigImpl(ServerAuthConfigType serverAuthConfigType, Map<String, ServerAuthContext> serverAuthContextMap) {
+        this.serverAuthConfigType = serverAuthConfigType;
+        this.serverAuthContextMap = serverAuthContextMap;
+    }
+
+    public ServerAuthContext getAuthContext(String authContextID, Subject serverSubject, Map properties) throws AuthException {
+        return serverAuthContextMap.get(authContextID);
+    }
+
+    public String getAppContext() {
+        return serverAuthConfigType.getAppContext();
+    }
+
+    public String getAuthContextID(MessageInfo messageInfo) throws IllegalArgumentException {
+        return serverAuthConfigType.getAuthContextID(messageInfo);
+    }
+
+    public String getMessageLayer() {
+        return serverAuthConfigType.getMessageLayer();
+    }
+
+    public boolean isProtected() {
+        return serverAuthConfigType.isProtected();
+    }
+
+    public void refresh() throws SecurityException {
+    }
+}

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthConfigImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthConfigImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthConfigImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthContextImpl.java?rev=1098801&view=auto
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthContextImpl.java (added)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthContextImpl.java Mon May  2 21:43:18 2011
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.components.jaspi.impl;
+
+import java.util.List;
+
+import javax.security.auth.Subject;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.AuthStatus;
+import javax.security.auth.message.MessageInfo;
+import javax.security.auth.message.config.ServerAuthContext;
+import javax.security.auth.message.module.ServerAuthModule;
+
+/**
+* @version $Rev:$ $Date:$
+*/
+public class ServerAuthContextImpl implements ServerAuthContext {
+
+    private final List<ServerAuthModule> serverAuthModules;
+
+    public ServerAuthContextImpl(List<ServerAuthModule> serverAuthModules) {
+        this.serverAuthModules = serverAuthModules;
+    }
+
+    public void cleanSubject(MessageInfo messageInfo, Subject subject) throws AuthException {
+        for (ServerAuthModule serverAuthModule : serverAuthModules) {
+            serverAuthModule.cleanSubject(messageInfo, subject);
+        }
+    }
+
+    public AuthStatus secureResponse(MessageInfo messageInfo, Subject serviceSubject) throws AuthException {
+        for (ServerAuthModule serverAuthModule : serverAuthModules) {
+            AuthStatus result = serverAuthModule.secureResponse(messageInfo, serviceSubject);
+
+            //jaspi spec p 86
+            if (result == AuthStatus.SEND_SUCCESS) {
+                continue;
+            }
+            if (result == AuthStatus.SEND_CONTINUE || result == AuthStatus.SEND_FAILURE) {
+                return result;
+            }
+            throw new AuthException("Invalid AuthStatus " + result + " from server auth module secureResponse: " + serverAuthModule);
+        }
+        return AuthStatus.SEND_SUCCESS;
+    }
+
+    public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
+        for (ServerAuthModule serverAuthModule : serverAuthModules) {
+            AuthStatus result = serverAuthModule.validateRequest(messageInfo, clientSubject, serviceSubject);
+
+            //jaspi spec p 88
+            if (result == AuthStatus.SUCCESS) {
+                continue;
+            }
+            if (result == AuthStatus.SEND_SUCCESS || result == AuthStatus.SEND_CONTINUE || result == AuthStatus.FAILURE) {
+                return result;
+            }
+            throw new AuthException("Invalid AuthStatus " + result + " from server auth module validateRequest: " + serverAuthModule);
+        }
+        return AuthStatus.SUCCESS;
+    }
+
+}

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthContextImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/impl/ServerAuthContextImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/AuthModuleType.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/AuthModuleType.java?rev=1098801&r1=1098800&r2=1098801&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/AuthModuleType.java (original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/AuthModuleType.java Mon May  2 21:43:18 2011
@@ -69,6 +69,7 @@ import org.apache.geronimo.osgi.locator.
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "authModuleType", propOrder = {
     "className",
+    "classLoaderName",
     "requestPolicy",
     "responsePolicy",
     "options"
@@ -190,37 +191,4 @@ public class AuthModuleType<T>
         this.classLoaderName = classLoaderName;
     }
 
-    public T newAuthModule(final CallbackHandler callbackHandler) throws AuthException {
-        T authModule;
-        try {
-            authModule = java.security.AccessController
-            .doPrivileged(new PrivilegedExceptionAction<T>() {
-                public T run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, AuthException {
-                    Class<? extends T> cl = (Class<? extends T>) ProviderLocator.loadClass(className, getClass(), Thread.currentThread().getContextClassLoader());
-                    Constructor<? extends T> cnst = cl.getConstructor();
-                    T authModule = cnst.newInstance();
-                    Method m = cl.getMethod("initialize", MessagePolicy.class, MessagePolicy.class, CallbackHandler.class, Map.class);
-                    MessagePolicy reqPolicy = requestPolicy == null? null:requestPolicy.newMessagePolicy();
-                    MessagePolicy respPolicy = responsePolicy == null? null: responsePolicy.newMessagePolicy();
-                    m.invoke(authModule, reqPolicy, respPolicy, callbackHandler, options);
-                    return authModule;
-                }
-            });
-        } catch (PrivilegedActionException e) {
-            Exception inner = e.getException();
-            if (inner instanceof InstantiationException) {
-                throw (AuthException) new AuthException("AuthConfigFactory error:"
-                                + inner.getCause().getMessage()).initCause(inner.getCause());
-            } else {
-                throw (AuthException) new AuthException("AuthConfigFactory error: " + inner).initCause(inner);
-            }
-        } catch (Exception e) {
-            throw (AuthException) new AuthException("AuthConfigFactory error: " + e).initCause(e);
-        }
-
-
-
-        return authModule;
-    }
-
 }

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthConfigType.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthConfigType.java?rev=1098801&r1=1098800&r2=1098801&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthConfigType.java (original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthConfigType.java Mon May  2 21:43:18 2011
@@ -25,11 +25,12 @@
 package org.apache.geronimo.components.jaspi.model;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
-import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.message.AuthException;
 import javax.security.auth.message.MessageInfo;
@@ -38,8 +39,9 @@ import javax.security.auth.message.confi
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.geronimo.components.jaspi.impl.ClientAuthConfigImpl;
 
 
 /**
@@ -64,8 +66,9 @@ import javax.xml.bind.annotation.adapter
  * </pre>
  * 
  * 
- * @version $Rev$ $Date$
+ * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $
  */
+@XmlRootElement(name = "clientAuthConfig", namespace = "http://geronimo.apache.org/xml/ns/geronimo-jaspi")
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "clientAuthConfigType", propOrder = {
     "messageLayer",
@@ -85,8 +88,8 @@ public class ClientAuthConfigType
     @XmlElement(name = "protected")
     protected boolean _protected;
     //TODO go back to a map
-    @XmlJavaTypeAdapter(KeyedObjectMapAdapter.class)
-    protected Map<String, ClientAuthContextType> clientAuthContext;
+//    @XmlJavaTypeAdapter(KeyedObjectMapAdapter.class)
+    protected List<ClientAuthContextType> clientAuthContext;
 
 
     public ClientAuthConfigType() {
@@ -96,7 +99,7 @@ public class ClientAuthConfigType
         this.messageLayer = clientAuthContextType.getMessageLayer();
         this.appContext = clientAuthContextType.getAppContext();
         this.authenticationContextID = clientAuthContextType.getAuthenticationContextID();
-        this.clientAuthContext = Collections.singletonMap(clientAuthContextType.getKey(), clientAuthContextType);
+        this.clientAuthContext = Collections.singletonList(clientAuthContextType);
         this._protected = _protected;
     }
 
@@ -216,11 +219,11 @@ public class ClientAuthConfigType
      *
      * @return map of id to client auth context
      */
-    public Map<String, ClientAuthContextType> getClientAuthContext() {
+    public List<ClientAuthContextType> getClientAuthContext() {
         if (clientAuthContext == null) {
-            clientAuthContext = new HashMap<String, ClientAuthContextType>();
+            clientAuthContext = new ArrayList<ClientAuthContextType>();
         }
-        return this.clientAuthContext;
+        return clientAuthContext;
     }
 
 
@@ -229,7 +232,7 @@ public class ClientAuthConfigType
         if (authenticationContextID != null) {
             return authenticationContextID;
         }
-        for (ClientAuthContextType clientAuthContextType: clientAuthContext.values()) {
+        for (ClientAuthContextType clientAuthContextType: clientAuthContext) {
             String authContextID = clientAuthContextType.getAuthenticationContextID(messageInfo);
             if (authContextID != null) {
                 return authContextID;
@@ -242,61 +245,4 @@ public class ClientAuthConfigType
         return ConfigProviderType.getRegistrationKey(messageLayer, appContext);
     }
 
-    public void initialize(CallbackHandler callbackHandler) throws AuthException {
-    }
-
-    public boolean isPersistent() {
-        return true;
-    }
-
-    public ClientAuthConfig newClientAuthConfig(String messageLayer, String appContext, CallbackHandler callbackHandler) throws AuthException {
-        Map<String, ClientAuthContext> authContextMap = new HashMap<String, ClientAuthContext>();
-        for (ClientAuthContextType clientAuthContextType: getClientAuthContext().values()) {
-            if (clientAuthContextType.match(messageLayer, appContext)) {
-                ClientAuthContext clientAuthContext = clientAuthContextType.newClientAuthContext(callbackHandler);
-                String authContextID = clientAuthContextType.getAuthenticationContextID();
-                if (authContextID == null) {
-                    authContextID = getAuthenticationContextID();
-                }
-                if (!authContextMap.containsKey(authContextID)) {
-                    authContextMap.put(authContextID,  clientAuthContext);
-                }
-            }
-        }
-        return new ClientAuthConfigImpl(this, authContextMap);
-    }
-
-    public static class ClientAuthConfigImpl implements ClientAuthConfig {
-
-        private final ClientAuthConfigType clientAuthConfigType;
-        private final Map<String, ClientAuthContext> clientAuthContextMap;
-
-        public ClientAuthConfigImpl(ClientAuthConfigType clientAuthConfigType, Map<String, ClientAuthContext> clientAuthContextMap) {
-            this.clientAuthConfigType = clientAuthConfigType;
-            this.clientAuthContextMap = clientAuthContextMap;
-        }
-
-        public ClientAuthContext getAuthContext(String authContextID, Subject clientSubject, Map properties) throws AuthException {
-            return clientAuthContextMap.get(authContextID);
-        }
-
-        public String getAppContext() {
-            return clientAuthConfigType.getAppContext();
-        }
-
-        public String getAuthContextID(MessageInfo messageInfo) throws IllegalArgumentException {
-            return clientAuthConfigType.getAuthContextID(messageInfo);
-        }
-
-        public String getMessageLayer() {
-            return clientAuthConfigType.getMessageLayer();
-        }
-
-        public boolean isProtected() {
-            return clientAuthConfigType.isProtected();
-        }
-
-        public void refresh() throws SecurityException {
-        }
-    }
 }

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthContextType.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthContextType.java?rev=1098801&r1=1098800&r2=1098801&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthContextType.java (original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ClientAuthContextType.java Mon May  2 21:43:18 2011
@@ -29,17 +29,17 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.message.AuthException;
-import javax.security.auth.message.AuthStatus;
 import javax.security.auth.message.MessageInfo;
 import javax.security.auth.message.config.ClientAuthContext;
 import javax.security.auth.message.module.ClientAuthModule;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
+import org.apache.geronimo.components.jaspi.impl.ClientAuthContextImpl;
 
 
 /**
@@ -62,8 +62,9 @@ import javax.xml.bind.annotation.XmlType
  * &lt;/complexType>
  * </pre>
  *
- * @version $Rev$ $Date$
+ * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $
  */
+@XmlRootElement(name = "clientAuthContext", namespace = "http://geronimo.apache.org/xml/ns/geronimo-jaspi")
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "clientAuthContextType", propOrder = {
         "messageLayer",
@@ -72,7 +73,7 @@ import javax.xml.bind.annotation.XmlType
         "clientAuthModule"
         })
 public class ClientAuthContextType
-        implements Serializable, KeyedObject {
+        implements Serializable {
 
     private final static long serialVersionUID = 12343L;
     protected String messageLayer;
@@ -186,83 +187,4 @@ public class ClientAuthContextType
     }
 
 
-    public String getKey() {
-        return ConfigProviderType.getRegistrationKey(messageLayer, appContext);
-    }
-
-    public void initialize(CallbackHandler callbackHandler) throws AuthException {
-    }
-
-    public boolean isPersistent() {
-        return true;
-    }
-
-    public ClientAuthContext newClientAuthContext(CallbackHandler callbackHandler) throws AuthException {
-        List<ClientAuthModule> clientAuthModules = new ArrayList<ClientAuthModule>();
-        for (AuthModuleType<ClientAuthModule> clientAuthModuleType: clientAuthModule) {
-            ClientAuthModule instance = clientAuthModuleType.newAuthModule(callbackHandler);
-            clientAuthModules.add(instance);
-        }
-        return new ClientAuthContextImpl(clientAuthModules);
-    }
-
-    public boolean match(String messageLayer, String appContext) {
-        if (messageLayer == null) throw new NullPointerException("messageLayer");
-        if (appContext == null) throw new NullPointerException("appContext");
-        if (messageLayer.equals(this.messageLayer)) {
-            return appContext.equals(this.appContext) || this.appContext == null;
-        }
-        if (this.messageLayer == null) {
-            return appContext.equals(this.appContext) || this.appContext == null;
-        }
-        return false;
-    }
-
-    public static class ClientAuthContextImpl implements ClientAuthContext {
-
-        private final List<ClientAuthModule> clientAuthModules;
-
-        public ClientAuthContextImpl(List<ClientAuthModule> clientAuthModules) {
-            this.clientAuthModules = clientAuthModules;
-        }
-
-        public void cleanSubject(MessageInfo messageInfo, Subject subject) throws AuthException {
-            for (ClientAuthModule clientAuthModule : clientAuthModules) {
-                clientAuthModule.cleanSubject(messageInfo, subject);
-            }
-        }
-
-        public AuthStatus secureRequest(MessageInfo messageInfo, Subject clientSubject) throws AuthException {
-            for (ClientAuthModule clientAuthModule : clientAuthModules) {
-                AuthStatus result = clientAuthModule.secureRequest(messageInfo, clientSubject);
-
-                //jaspi spec p 74
-                if (result == AuthStatus.SUCCESS) {
-                    continue;
-                }
-                if (result == AuthStatus.SEND_CONTINUE || result == AuthStatus.FAILURE) {
-                    return result;
-                }
-                throw new AuthException("Invalid AuthStatus " + result + " from client auth module: " + clientAuthModule);
-            }
-            return AuthStatus.SUCCESS;
-        }
-
-        public AuthStatus validateResponse(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
-            for (ClientAuthModule clientAuthModule : clientAuthModules) {
-                AuthStatus result = clientAuthModule.validateResponse(messageInfo, clientSubject, serviceSubject);
-
-                //jaspi spec p 74
-                if (result == AuthStatus.SUCCESS) {
-                    continue;
-                }
-                if (result == AuthStatus.SEND_CONTINUE || result == AuthStatus.FAILURE) {
-                    return result;
-                }
-                throw new AuthException("Invalid AuthStatus " + result + " from client auth module: " + clientAuthModule);
-            }
-            return AuthStatus.SUCCESS;
-        }
-    }
-
 }

Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderType.java
URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderType.java?rev=1098801&r1=1098800&r2=1098801&view=diff
==============================================================================
--- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderType.java (original)
+++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ConfigProviderType.java Mon May  2 21:43:18 2011
@@ -35,18 +35,17 @@ import java.util.List;
 import java.util.Map;
 
 import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.message.AuthException;
 import javax.security.auth.message.config.AuthConfigFactory;
 import javax.security.auth.message.config.AuthConfigProvider;
-import javax.security.auth.message.config.ClientAuthConfig;
 import javax.security.auth.message.config.RegistrationListener;
-import javax.security.auth.message.config.ServerAuthConfig;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.geronimo.components.jaspi.impl.ConfigProviderImpl;
 import org.apache.geronimo.osgi.locator.ProviderLocator;
 
 
@@ -83,6 +82,7 @@ import org.apache.geronimo.osgi.locator.
  * 
  * 
  */
+@XmlRootElement(name = "configProvider", namespace = "http://geronimo.apache.org/xml/ns/geronimo-jaspi")
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "configProviderType", propOrder = {
     "messageLayer",
@@ -96,7 +96,7 @@ import org.apache.geronimo.osgi.locator.
     "classLoaderName"
 })
 public class ConfigProviderType
-    implements AuthConfigFactory.RegistrationContext, Serializable, KeyedObject
+    implements Serializable
 {
 
     private final static long serialVersionUID = 12343L;
@@ -108,20 +108,11 @@ public class ConfigProviderType
     @XmlElement(required = true)
     @XmlJavaTypeAdapter(StringMapAdapter.class)
     protected Map<String, String> properties;
-    @XmlJavaTypeAdapter(KeyedObjectMapAdapter.class)
-    private Map<String, ClientAuthConfigType> clientAuthConfig;
-    @XmlJavaTypeAdapter(KeyedObjectMapAdapter.class)
-    private Map<String, ServerAuthConfigType> serverAuthConfig;
+    private List<ClientAuthConfigType> clientAuthConfig;
+    private List<ServerAuthConfigType> serverAuthConfig;
     protected Boolean persistent = Boolean.FALSE;
     protected String classLoaderName;
 
-    @XmlTransient
-    private AuthConfigFactory authConfigFactory;
-    @XmlTransient
-    private final List<RegistrationListener> listeners = new ArrayList<RegistrationListener>();
-    @XmlTransient
-    private AuthConfigProvider provider;
-
 
     public ConfigProviderType() {
     }
@@ -130,7 +121,6 @@ public class ConfigProviderType
         this.messageLayer = messageLayer;
         this.appContext = appContext;
         this.persistent = persistent;
-        this.authConfigFactory = authConfigFactory;
     }
 
     /**
@@ -275,11 +265,11 @@ public class ConfigProviderType
      * 
      * @return map of id to client auth config
      */
-    public Map<String, ClientAuthConfigType> getClientAuthConfig() {
+    public List<ClientAuthConfigType> getClientAuthConfig() {
         if (clientAuthConfig == null) {
-            clientAuthConfig = new HashMap<String, ClientAuthConfigType>();
+            clientAuthConfig = new ArrayList<ClientAuthConfigType>();
         }
-        return this.clientAuthConfig;
+        return clientAuthConfig;
     }
 
     /**
@@ -304,11 +294,11 @@ public class ConfigProviderType
      * 
      * @return map of id to server auth config
      */
-    public Map<String, ServerAuthConfigType> getServerAuthConfig() {
+    public List<ServerAuthConfigType> getServerAuthConfig() {
         if (serverAuthConfig == null) {
-            serverAuthConfig = new HashMap<String, ServerAuthConfigType>();
+            serverAuthConfig = new ArrayList<ServerAuthConfigType>();
         }
-        return this.serverAuthConfig;
+        return serverAuthConfig;
     }
 
     /**
@@ -335,18 +325,6 @@ public class ConfigProviderType
         this.persistent = value;
     }
 
-    public List<RegistrationListener> getListeners() {
-        return listeners;
-    }
-
-    public AuthConfigProvider getProvider() {
-        return provider;
-    }
-
-    public void setProvider(AuthConfigProvider provider) {
-        this.provider = provider;
-    }
-
     public String getClassLoaderName() {
         return classLoaderName;
     }
@@ -355,33 +333,6 @@ public class ConfigProviderType
         this.classLoaderName = classLoaderName;
     }
 
-    public void initialize(CallbackHandler callbackHandler) {
-        if (className == null) {
-            provider = new ConfigProviderImpl(getClientAuthConfig(), getServerAuthConfig());
-        } else {
-            try {
-                provider = java.security.AccessController
-                .doPrivileged(new PrivilegedExceptionAction<AuthConfigProvider>() {
-                    public AuthConfigProvider run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
-                        Class<? extends AuthConfigProvider> cl = ProviderLocator.loadClass(className, getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(AuthConfigProvider.class);
-                        Constructor<? extends AuthConfigProvider> cnst = cl.getConstructor(Map.class, AuthConfigFactory.class);
-                        return cnst.newInstance(properties, authConfigFactory);
-                    }
-                });
-            } catch (PrivilegedActionException e) {
-                Exception inner = e.getException();
-                if (inner instanceof InstantiationException) {
-                    throw new SecurityException("AuthConfigFactory error:"
-                                    + inner.getCause().getMessage(), inner.getCause());
-                } else {
-                    throw new SecurityException("AuthConfigFactory error: " + inner, inner);
-                }
-            } catch (Exception e) {
-                throw new SecurityException("AuthConfigFactory error: " + e, e);
-            }
-        }
-    }
-
     public static String getRegistrationKey(String layer, String appContext) {
         return layer + "/" + appContext;
     }
@@ -390,75 +341,4 @@ public class ConfigProviderType
         return getRegistrationKey(getMessageLayer(), getAppContext());
     }
 
-    public static class ConfigProviderImpl implements AuthConfigProvider {
-
-        private final Map<String, ClientAuthConfigType> clientConfigTypeMap;
-        private final Map<String, ServerAuthConfigType> serverAuthConfigMap;
-
-        public ConfigProviderImpl(Map<String, ClientAuthConfigType> clientConfigTypeMap, Map<String, ServerAuthConfigType> serverAuthConfigMap) {
-            this.clientConfigTypeMap = clientConfigTypeMap;
-            this.serverAuthConfigMap = serverAuthConfigMap;
-        }
-
-        /**
-         * spec required constructor
-         * @param properties useless properties map
-         * @param factory useless factory
-         */
-        public ConfigProviderImpl(Map<String, String> properties, AuthConfigFactory factory) {
-            throw new RuntimeException("don't call this");
-        }
-
-        public ClientAuthConfig getClientAuthConfig(String layer, String appContext, CallbackHandler handler) throws AuthException, SecurityException {
-            if (layer == null) {
-                throw new NullPointerException("messageLayer");
-            }
-            if (appContext == null) {
-                throw new NullPointerException("appContext");
-            }
-            ClientAuthConfigType ctx = clientConfigTypeMap.get(getRegistrationKey(layer, appContext));
-            if (ctx == null) {
-                ctx = clientConfigTypeMap.get(getRegistrationKey(null, appContext));
-            }
-            if (ctx == null) {
-                ctx = clientConfigTypeMap.get(getRegistrationKey(layer, null));
-            }
-            if (ctx == null) {
-                ctx = clientConfigTypeMap.get(getRegistrationKey(null, null));
-            }
-            if (ctx != null) {
-                
-                return ctx.newClientAuthConfig(layer, appContext, handler);
-            }
-            throw new AuthException("No suitable ClientAuthConfig");
-        }
-
-        public ServerAuthConfig getServerAuthConfig(String layer, String appContext, CallbackHandler handler) throws AuthException, SecurityException {
-            if (layer == null) {
-                throw new NullPointerException("messageLayer");
-            }
-            if (appContext == null) {
-                throw new NullPointerException("appContext");
-            }
-            ServerAuthConfigType ctx = serverAuthConfigMap.get(getRegistrationKey(layer, appContext));
-            if (ctx == null) {
-                ctx = serverAuthConfigMap.get(getRegistrationKey(null, appContext));
-            }
-            if (ctx == null) {
-                ctx = serverAuthConfigMap.get(getRegistrationKey(layer, null));
-            }
-            if (ctx == null) {
-                ctx = serverAuthConfigMap.get(getRegistrationKey(null, null));
-            }
-            if (ctx != null) {
-
-                return ctx.newServerAuthConfig(layer, appContext, handler);
-            }
-            throw new AuthException("No suitable ServerAuthConfig");
-        }
-
-        public void refresh() throws SecurityException {
-        }
-    }
-
 }



Mime
View raw message