Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D1CC23CBE for ; Mon, 2 May 2011 21:43:48 +0000 (UTC) Received: (qmail 44125 invoked by uid 500); 2 May 2011 21:43:48 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 44076 invoked by uid 500); 2 May 2011 21:43:48 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 44069 invoked by uid 99); 2 May 2011 21:43:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2011 21:43:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2011 21:43:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D145E2388A19; Mon, 2 May 2011 21:43:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1098801 [2/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 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110502214319.D145E2388A19@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiType.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiType.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiType.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiType.java Mon May 2 21:43:18 2011 @@ -25,7 +25,9 @@ package org.apache.geronimo.components.jaspi.model; import java.io.Serializable; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.xml.bind.annotation.XmlAccessType; @@ -52,7 +54,7 @@ import javax.xml.bind.annotation.adapter * * * - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "jaspiType", propOrder = { @@ -63,9 +65,9 @@ public class JaspiType { private final static long serialVersionUID = 12343L; - - @XmlJavaTypeAdapter(KeyedObjectMapAdapter.class) - protected Map configProvider; + protected List configProvider; +// @XmlJavaTypeAdapter(KeyedObjectMapAdapter.class) +// protected Map configProvider; /** * Gets the value of the configProvider property. @@ -88,11 +90,11 @@ public class JaspiType * {@link ConfigProviderType } * * - * @return map of id to Config Provider + * @return list of Config Provider */ - public Map getConfigProvider() { + public List getConfigProvider() { if (configProvider == null) { - configProvider = new HashMap(); + configProvider = new ArrayList(); } return this.configProvider; } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiUtil.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiUtil.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiUtil.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiUtil.java Mon May 2 21:43:18 2011 @@ -21,16 +21,18 @@ package org.apache.geronimo.components.jaspi.model; import java.util.Collections; +import java.util.List; import java.util.Map; import javax.security.auth.message.AuthException; import javax.security.auth.message.config.AuthConfigProvider; import javax.security.auth.message.module.ClientAuthModule; import javax.security.auth.message.module.ServerAuthModule; +import org.apache.geronimo.components.jaspi.impl.ConfigProviderImpl; /** * Convenience methods to wrap various jaspi objects into AuthConfigProvider instances, ready to be registered. - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ public class JaspiUtil { @@ -38,12 +40,12 @@ public class JaspiUtil { } public static AuthConfigProvider wrapAuthConfigProvider(ConfigProviderType configProviderType) { - return new ConfigProviderType.ConfigProviderImpl(configProviderType.getClientAuthConfig(), configProviderType.getServerAuthConfig()); + return new ConfigProviderImpl(configProviderType.getClientAuthConfig(), configProviderType.getServerAuthConfig()); } public static AuthConfigProvider wrapClientAuthConfig(ClientAuthConfigType clientAuthConfigType) throws AuthException { - Map clientAuthConfig = Collections.singletonMap(clientAuthConfigType.getKey(), clientAuthConfigType); - return new ConfigProviderType.ConfigProviderImpl(clientAuthConfig, Collections.emptyMap()); + List clientAuthConfig = Collections.singletonList(clientAuthConfigType); + return new ConfigProviderImpl(clientAuthConfig, Collections.emptyList()); } public static AuthConfigProvider wrapClientAuthContext(ClientAuthContextType clientAuthContextType, boolean _protected) throws AuthException { @@ -58,8 +60,8 @@ public class JaspiUtil { public static AuthConfigProvider wrapServerAuthConfig(ServerAuthConfigType serverAuthConfigType) throws AuthException { - Map serverAuthConfig = Collections.singletonMap(serverAuthConfigType.getKey(), serverAuthConfigType); - return new ConfigProviderType.ConfigProviderImpl(Collections.emptyMap(), serverAuthConfig); + List serverAuthConfig = Collections.singletonList(serverAuthConfigType); + return new ConfigProviderImpl(Collections.emptyList(), serverAuthConfig); } public static AuthConfigProvider wrapServerAuthContext(ServerAuthContextType serverAuthContextType, boolean _protected) throws AuthException { Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/JaspiXmlUtil.java Mon May 2 21:43:18 2011 @@ -23,7 +23,6 @@ package org.apache.geronimo.components.j import java.io.IOException; import java.io.Reader; import java.io.Writer; -import java.util.Collections; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.message.module.ClientAuthModule; @@ -40,7 +39,7 @@ import javax.xml.stream.XMLStreamReader; import org.xml.sax.SAXException; /** - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ public class JaspiXmlUtil { public static final XMLInputFactory XMLINPUT_FACTORY = XMLInputFactory.newInstance(); @@ -49,8 +48,8 @@ public class JaspiXmlUtil { static { try { -// JASPI_CONTEXT = JAXBContext.newInstance(JaspiType.class); - JASPI_CONTEXT = com.envoisolutions.sxc.jaxb.JAXBContextImpl.newInstance(new Class[] {JaspiType.class, ConfigProviderType.class, ClientAuthConfigType.class, ClientAuthContextType.class, ServerAuthConfigType.class, ServerAuthContextType.class, AuthModuleType.class}, Collections.singletonMap("com.envoisolutions.sxc.generate", "false")); + JASPI_CONTEXT = JAXBContext.newInstance(JaspiType.class, ConfigProviderType.class, ClientAuthConfigType.class, ClientAuthContextType.class, ServerAuthConfigType.class, ServerAuthContextType.class, AuthModuleType.class); +// JASPI_CONTEXT = com.envoisolutions.sxc.jaxb.JAXBContextImpl.newInstance(new Class[] {JaspiType.class, ConfigProviderType.class, ClientAuthConfigType.class, ClientAuthContextType.class, ServerAuthConfigType.class, ServerAuthContextType.class, AuthModuleType.class}, Collections.singletonMap("com.envoisolutions.sxc.generate", "false")); } catch (JAXBException e) { throw new RuntimeException("Could not create jaxb contexts for plugin types", e); Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObject.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObject.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObject.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObject.java Mon May 2 21:43:18 2011 @@ -24,10 +24,8 @@ import javax.security.auth.callback.Call import javax.security.auth.message.AuthException; /** - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ public interface KeyedObject { String getKey(); - void initialize(CallbackHandler callbackHandler) throws AuthException; - boolean isPersistent(); } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObjectMapAdapter.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObjectMapAdapter.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObjectMapAdapter.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/KeyedObjectMapAdapter.java Mon May 2 21:43:18 2011 @@ -30,47 +30,43 @@ import javax.security.auth.callback.Call import javax.xml.bind.annotation.adapters.XmlAdapter; /** - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ -public class KeyedObjectMapAdapter extends XmlAdapter> { +public class KeyedObjectMapAdapter extends XmlAdapter, Map> { public static CallbackHandler staticCallbackHandler; private final CallbackHandler callbackHandler; - private final Class type; +// private final Class type; - public KeyedObjectMapAdapter(CallbackHandler callbackHandler, Class type) { + public KeyedObjectMapAdapter(CallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; - this.type = type; +// this.type = type; } - public KeyedObjectMapAdapter(Class type) { - this(staticCallbackHandler, type); + public KeyedObjectMapAdapter() { + this(staticCallbackHandler); } - public Map unmarshal(T[] configProviderTypes) throws Exception { + public Map unmarshal(List configProviderTypes) throws Exception { Map map = new HashMap(); if (configProviderTypes != null) { for (T configProviderType : configProviderTypes) { if (configProviderType != null) { String key = configProviderType.getKey(); map.put(key, configProviderType); - configProviderType.initialize(callbackHandler); } } } return map; } - public T[] marshal(Map stringConfigProviderTypeMap) throws Exception { + public ArrayList marshal(Map stringConfigProviderTypeMap) throws Exception { if (stringConfigProviderTypeMap == null) { return null; } - List list = new ArrayList(); + ArrayList list = new ArrayList(); for (T configProviderType : stringConfigProviderTypeMap.values()) { - if (configProviderType.isPersistent()) { - list.add(configProviderType); - } + list.add(configProviderType); } - T[] array = (T[]) Array.newInstance(type, list.size()); - return list.toArray(array); + return list; } } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/MessagePolicyType.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/MessagePolicyType.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/MessagePolicyType.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/MessagePolicyType.java Mon May 2 21:43:18 2011 @@ -55,7 +55,7 @@ import javax.xml.bind.annotation.XmlType * * * - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "messagePolicyType", propOrder = { @@ -124,16 +124,5 @@ public class MessagePolicyType this.mandatory = value; } - public MessagePolicy newMessagePolicy() throws AuthException { - if (targetPolicy == null || targetPolicy.size() == 0) { - return null; - } - MessagePolicy.TargetPolicy[] targetPolicies = new MessagePolicy.TargetPolicy[targetPolicy.size()]; - int i = 0; - for (TargetPolicyType targetPolicyType: targetPolicy) { - targetPolicies[i++] = targetPolicyType.newTargetPolicy(); - } - return new MessagePolicy(targetPolicies, mandatory); - } } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ProtectionPolicyType.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ProtectionPolicyType.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ProtectionPolicyType.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ProtectionPolicyType.java Mon May 2 21:43:18 2011 @@ -57,7 +57,7 @@ import org.apache.geronimo.osgi.locator. * * * - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "protectionPolicyType", propOrder = { @@ -95,27 +95,4 @@ public class ProtectionPolicyType this.className = value; } - public MessagePolicy.ProtectionPolicy newProtectionPolicy() throws AuthException { - try { - return java.security.AccessController - .doPrivileged(new PrivilegedExceptionAction() { - public MessagePolicy.ProtectionPolicy run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { - Class cl = ProviderLocator.loadClass(className, getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(MessagePolicy.ProtectionPolicy.class); - Constructor 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); - } - } } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthConfigType.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthConfigType.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthConfigType.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthConfigType.java Mon May 2 21:43:18 2011 @@ -25,8 +25,10 @@ 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; @@ -39,7 +41,7 @@ import javax.xml.bind.annotation.XmlAcce import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.apache.geronimo.components.jaspi.impl.ServerAuthConfigImpl; /** @@ -64,7 +66,7 @@ import javax.xml.bind.annotation.adapter * * * - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "serverAuthConfigType", propOrder = { @@ -84,8 +86,8 @@ public class ServerAuthConfigType protected String authenticationContextID; @XmlElement(name = "protected") protected boolean _protected; - @XmlJavaTypeAdapter(KeyedObjectMapAdapter.class) - protected Map serverAuthContext; +// @XmlJavaTypeAdapter(KeyedObjectMapAdapter.class) + protected List serverAuthContext; public ServerAuthConfigType() { } @@ -94,7 +96,7 @@ public class ServerAuthConfigType this.messageLayer = serverAuthContextType.getMessageLayer(); this.appContext = serverAuthContextType.getAppContext(); this.authenticationContextID = serverAuthContextType.getAuthenticationContextID(); - this.serverAuthContext = Collections.singletonMap(serverAuthContextType.getKey(), serverAuthContextType); + this.serverAuthContext = Collections.singletonList(serverAuthContextType); this._protected = _protected; } @@ -138,7 +140,7 @@ public class ServerAuthConfigType if (authenticationContextID != null) { return authenticationContextID; } - for (ServerAuthContextType serverAuthContextType: serverAuthContext.values()) { + for (ServerAuthContextType serverAuthContextType: serverAuthContext) { String authContextID = serverAuthContextType.getAuthenticationContextID(messageInfo); if (authContextID != null) { return authContextID; @@ -227,81 +229,15 @@ public class ServerAuthConfigType * * @return map of id to Server auth config */ - public Map getServerAuthContext() { + public List getServerAuthContext() { if (serverAuthContext == null) { - serverAuthContext = new HashMap(); + serverAuthContext = new ArrayList(); } - return this.serverAuthContext; + return serverAuthContext; } - public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map properties) throws AuthException { - //see page 136 We are going to ignore the clientSubject and properties for now. - for (ServerAuthContextType serverAuthContext: getServerAuthContext().values()) { - if (serverAuthContext.getAuthenticationContextID().equals(authContextID)) { - return serverAuthContext.getServerAuthContext(); - } - } - return null; - } public String getKey() { return ConfigProviderType.getRegistrationKey(messageLayer, appContext); } - public void initialize(CallbackHandler callbackHandler) throws AuthException { - } - - public boolean isPersistent() { - return true; - } - - public ServerAuthConfig newServerAuthConfig(String messageLayer, String appContext, CallbackHandler callbackHandler) throws AuthException { - Map authContextMap = new HashMap(); - for (ServerAuthContextType serverAuthContextType: getServerAuthContext().values()) { - if (serverAuthContextType.match(messageLayer, appContext)) { - ServerAuthContext serverAuthContext = serverAuthContextType.newServerAuthContext(callbackHandler); - String authContextID = serverAuthContextType.getAuthenticationContextID(); - if (authContextID == null) { - authContextID = getAuthenticationContextID(); - } - if (!authContextMap.containsKey(authContextID)) { - authContextMap.put(authContextID, serverAuthContext); - } - } - } - return new ServerAuthConfigImpl(this, authContextMap); - } - - public static class ServerAuthConfigImpl implements ServerAuthConfig { - - private final ServerAuthConfigType serverAuthConfigType; - private final Map serverAuthContextMap; - - public ServerAuthConfigImpl(ServerAuthConfigType serverAuthConfigType, Map 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 { - } - } } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthContextType.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthContextType.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthContextType.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/ServerAuthContextType.java Mon May 2 21:43:18 2011 @@ -29,10 +29,8 @@ 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.ServerAuthContext; import javax.security.auth.message.module.ServerAuthModule; @@ -40,6 +38,7 @@ import javax.xml.bind.annotation.XmlAcce import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlType; +import org.apache.geronimo.components.jaspi.impl.ServerAuthContextImpl; /** @@ -63,7 +62,7 @@ import javax.xml.bind.annotation.XmlType * * * - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "serverAuthContextType", propOrder = { @@ -73,7 +72,7 @@ import javax.xml.bind.annotation.XmlType "serverAuthModule" }) public class ServerAuthContextType - implements Serializable, KeyedObject { + implements Serializable { private final static long serialVersionUID = 12343L; protected String messageLayer; @@ -81,10 +80,6 @@ public class ServerAuthContextType protected String authenticationContextID; protected List> serverAuthModule; - @XmlTransient - private ServerAuthContext serverAuthContext; - - public ServerAuthContextType() { } @@ -187,94 +182,4 @@ public class ServerAuthContextType return this.serverAuthModule; } - public String getKey() { - return ConfigProviderType.getRegistrationKey(messageLayer, appContext); - } - - public void initialize(CallbackHandler callbackHandler) throws AuthException { - List serverAuthModules = new ArrayList(); - for (AuthModuleType serverAuthModuleType: serverAuthModule) { - ServerAuthModule instance = serverAuthModuleType.newAuthModule(callbackHandler); - serverAuthModules.add(instance); - } - serverAuthContext = new ServerAuthContextImpl(serverAuthModules); - } - - public boolean isPersistent() { - return true; - } - - public ServerAuthContext getServerAuthContext() { - return serverAuthContext; - } - - public ServerAuthContext newServerAuthContext(CallbackHandler callbackHandler) throws AuthException { - List serverAuthModules = new ArrayList(); - for (AuthModuleType serverAuthModuleType: serverAuthModule) { - ServerAuthModule instance = serverAuthModuleType.newAuthModule(callbackHandler); - serverAuthModules.add(instance); - } - return new ServerAuthContextImpl(serverAuthModules); - } - - 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 ServerAuthContextImpl implements ServerAuthContext { - - private final List serverAuthModules; - - public ServerAuthContextImpl(List 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; - } - - } - } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/StringMapAdapter.java Mon May 2 21:43:18 2011 @@ -31,7 +31,7 @@ import javax.xml.bind.annotation.adapter /** * jaxb helper class for maps * - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ public class StringMapAdapter extends XmlAdapter> { public Map unmarshal(String s) throws Exception { Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetPolicyType.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetPolicyType.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetPolicyType.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetPolicyType.java Mon May 2 21:43:18 2011 @@ -55,7 +55,7 @@ import javax.xml.bind.annotation.XmlType * * * - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "targetPolicyType", propOrder = { @@ -125,12 +125,4 @@ public class TargetPolicyType return this.target; } - public MessagePolicy.TargetPolicy newTargetPolicy() throws AuthException { - MessagePolicy.Target[] targets = new MessagePolicy.Target[getTarget().size()]; - int i = 0; - for (TargetType targetType: getTarget()) { - targets[i++] = targetType.newTarget(); - } - return new MessagePolicy.TargetPolicy(targets, protectionPolicy.newProtectionPolicy()); - } } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetType.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetType.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetType.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/TargetType.java Mon May 2 21:43:18 2011 @@ -57,7 +57,7 @@ import org.apache.geronimo.osgi.locator. * * * - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "targetType", propOrder = { @@ -95,29 +95,4 @@ public class TargetType this.className = value; } - public MessagePolicy.Target newTarget() throws AuthException { - try { - return java.security.AccessController - .doPrivileged(new PrivilegedExceptionAction() { - public MessagePolicy.Target run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { - Class cl = ProviderLocator.loadClass(className, getClass(), Thread.currentThread().getContextClassLoader()).asSubclass(MessagePolicy.Target.class); - Constructor 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); - } - - } - } Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/package-info.java URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/package-info.java?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/package-info.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/java/org/apache/geronimo/components/jaspi/model/package-info.java Mon May 2 21:43:18 2011 @@ -21,7 +21,7 @@ // Generated on: 2008.07.15 at 04:13:34 PM PDT // /** - * @version $Rev$ $Date$ + * @version $Rev: 680565 $ $Date: 2008-07-28 16:33:51 -0700 (Mon, 28 Jul 2008) $ */ @javax.xml.bind.annotation.XmlSchema(namespace = "http://geronimo.apache.org/xml/ns/geronimo-jaspi", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.apache.geronimo.components.jaspi.model; Modified: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/META-INF/sun-jaxb.episode URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/META-INF/sun-jaxb.episode?rev=1098801&r1=1098800&r2=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/META-INF/sun-jaxb.episode (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/META-INF/sun-jaxb.episode Mon May 2 21:43:18 2011 @@ -1,36 +1,47 @@ - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copied: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/geronimo-jaspi.xsd (from r1096035, geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/xsd/geronimo-jaspi.xsd) URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/geronimo-jaspi.xsd?p2=geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/geronimo-jaspi.xsd&p1=geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/xsd/geronimo-jaspi.xsd&r1=1096035&r2=1098801&rev=1098801&view=diff ============================================================================== (empty) Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/geronimo-jaspi.xsd ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/geronimo-jaspi.xsd ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/main/resources/geronimo-jaspi.xsd ------------------------------------------------------------------------------ svn:mime-type = text/xml Copied: geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/JaxbTest.java (from r1096035, geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java) URL: http://svn.apache.org/viewvc/geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/JaxbTest.java?p2=geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/JaxbTest.java&p1=geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java&r1=1096035&r2=1098801&rev=1098801&view=diff ============================================================================== --- geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/model/JaxbTest.java (original) +++ geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/JaxbTest.java Mon May 2 21:43:18 2011 @@ -18,16 +18,13 @@ */ -package org.apache.geronimo.components.jaspi.model; +package org.apache.geronimo.components.jaspi.impl; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStreamWriter; import java.io.Reader; import java.io.File; -import java.io.UnsupportedEncodingException; import java.io.Writer; import java.io.FileWriter; import java.io.FileReader; @@ -46,11 +43,18 @@ import javax.security.auth.message.AuthE import javax.security.auth.message.module.ClientAuthModule; import javax.security.auth.callback.CallbackHandler; +import org.apache.geronimo.components.jaspi.AuthConfigFactoryImpl; +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.JaspiType; +import org.apache.geronimo.components.jaspi.model.JaspiXmlUtil; import org.testng.annotations.Test; import org.xml.sax.SAXException; /** - * @version $Rev$ $Date$ + * @version $Rev: 939768 $ $Date: 2010-04-30 11:26:46 -0700 (Fri, 30 Apr 2010) $ */ public class JaxbTest { @@ -66,7 +70,7 @@ public class JaxbTest { JaspiType jaspi1 = loadJaspi(file); if (jaspi1.getConfigProvider().size() != count) throw new Exception("expected " + count + " configprovider, not this: " + jaspi1.getConfigProvider()); File newFile = getWriteFile(file); - Writer writer = getWriter(newFile); + Writer writer = new FileWriter(newFile); JaspiXmlUtil.writeJaspi(jaspi1, writer); JaspiType jaspi2 = JaspiXmlUtil.loadJaspi(new FileReader(newFile)); if (jaspi2.getConfigProvider().size() != count) throw new Exception("expected " + count + " configprovider, not this: " + jaspi2.getConfigProvider()); @@ -78,12 +82,15 @@ public class JaxbTest { JaspiType jaspi1 = loadJaspi(file); if (jaspi1.getConfigProvider().size() != count) throw new Exception("expected " + count + " configprovider, not this: " + jaspi1.getConfigProvider()); File newFile = getWriteFile(file); - Writer writer = getWriter(newFile); + Writer writer = new FileWriter(newFile); JaspiXmlUtil.writeJaspi(jaspi1, writer); JaspiType jaspi2 = JaspiXmlUtil.loadJaspi(new FileReader(newFile)); if (jaspi2.getConfigProvider().size() != count) throw new Exception("expected " + count + " configprovider, not this: " + jaspi2.getConfigProvider()); - AuthConfigProvider configProvider = jaspi1.getConfigProvider().get(ConfigProviderType.getRegistrationKey("Http", "test-app1")).getProvider(); + AuthConfigFactoryImpl authConfigFactory = new AuthConfigFactoryImpl(jaspi1, callbackHandler); + + AuthConfigProvider configProvider = authConfigFactory.getConfigProvider("Http", "test-app1", null); +// adapter.unmarshal(jaspi1.getConfigProvider()).get(ConfigProviderType.getRegistrationKey("Http", "test-app1")).getProvider(); checkConfigProvider(configProvider); } @@ -93,9 +100,9 @@ public class JaxbTest { return rbac; } - private Reader getReader(String file) throws UnsupportedEncodingException { + private Reader getReader(String file) { InputStream in = getClass().getClassLoader().getResourceAsStream("test-" + file + ".xml"); - Reader reader = new InputStreamReader(in, "UTF-8"); + Reader reader = new InputStreamReader(in); return reader; } @@ -110,13 +117,13 @@ public class JaxbTest { String file = "config-provider"; Reader reader = getReader(file); ConfigProviderType jaspi1 = JaspiXmlUtil.loadConfigProvider(reader); - jaspi1.initialize(callbackHandler); +// jaspi1.initialize(callbackHandler); File newFile = getWriteFile(file); - Writer writer = getWriter(newFile); + Writer writer = new FileWriter(newFile); JaspiXmlUtil.writeConfigProvider(jaspi1, writer); ConfigProviderType jaspi2 = JaspiXmlUtil.loadConfigProvider(new FileReader(newFile)); - AuthConfigProvider configProvider = jaspi1.getProvider(); + AuthConfigProvider configProvider = ConfigProviderImpl.newConfigProvider(null, jaspi1); checkConfigProvider(configProvider); } @@ -125,13 +132,13 @@ public class JaxbTest { String file = "client-auth-config"; Reader reader = getReader(file); ClientAuthConfigType jaspi1 = JaspiXmlUtil.loadClientAuthConfig(reader); - jaspi1.initialize(callbackHandler); +// jaspi1.initialize(callbackHandler); File newFile = getWriteFile(file); - Writer writer = getWriter(newFile); + Writer writer = new FileWriter(newFile); JaspiXmlUtil.writeClientAuthConfig(jaspi1, writer); ClientAuthConfigType jaspi2 = JaspiXmlUtil.loadClientAuthConfig(new FileReader(newFile)); - ClientAuthConfig clientAuthConfig = jaspi1.newClientAuthConfig("Http", "app", callbackHandler); + ClientAuthConfig clientAuthConfig = ConfigProviderImpl.newClientAuthConfig(jaspi1, "Http", "app", callbackHandler); checkClientAuthConfig(clientAuthConfig); } @@ -141,30 +148,25 @@ public class JaxbTest { Reader reader = getReader(file); ClientAuthContextType jaspi1 = JaspiXmlUtil.loadClientAuthContext(reader); File newFile = getWriteFile(file); - Writer writer = getWriter(newFile); + Writer writer = new FileWriter(newFile); JaspiXmlUtil.writeClientAuthContext(jaspi1, writer); ClientAuthContextType jaspi2 = JaspiXmlUtil.loadClientAuthContext(new FileReader(newFile)); - ClientAuthContext clientAuthConfig = jaspi1.newClientAuthContext(callbackHandler); + ClientAuthContext clientAuthConfig = ConfigProviderImpl.newClientAuthContext(jaspi1, callbackHandler); clientAuthConfig.secureRequest(null, null); } - private Writer getWriter(File newFile) throws IOException { - FileOutputStream out = new FileOutputStream(newFile); - return new OutputStreamWriter(out, "UTF-8");//new FileWriter(newFile); - } - @Test public void testClientAuthModule() throws Exception { String file = "client-auth-module"; Reader reader = getReader(file); AuthModuleType jaspi1 = JaspiXmlUtil.loadClientAuthModule(reader); File newFile = getWriteFile(file); - Writer writer = getWriter(newFile); + Writer writer = new FileWriter(newFile); JaspiXmlUtil.writeClientAuthModule(jaspi1, writer); AuthModuleType jaspi2 = JaspiXmlUtil.loadClientAuthModule(new FileReader(newFile)); - ClientAuthModule clientAuthConfig = jaspi1.newAuthModule(callbackHandler); + ClientAuthModule clientAuthConfig =ConfigProviderImpl.newAuthModule(jaspi1, callbackHandler); clientAuthConfig.secureRequest(null, null); } Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/JaxbTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/JaxbTest.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/components/jaspi/trunk/geronimo-jaspi/src/test/java/org/apache/geronimo/components/jaspi/impl/JaxbTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain