blob: 23117567614f1938fed3db5e0ad940d8003dd047 [file] [log] [blame]
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1.5-b01-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.07.15 at 04:13:34 PM PDT
//
package org.apache.geronimo.components.jaspi.model;
import java.io.Serializable;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Constructor;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.security.auth.message.config.AuthConfigFactory;
import javax.security.auth.message.config.RegistrationListener;
import javax.security.auth.message.config.AuthConfigProvider;
import javax.security.auth.message.config.ClientAuthConfig;
import javax.security.auth.message.config.ServerAuthConfig;
import javax.security.auth.message.AuthException;
import javax.security.auth.callback.CallbackHandler;
import org.apache.geronimo.components.jaspi.ClassLoaderLookup;
/**
* <p>Java class for configProviderType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="configProviderType">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="messageLayer" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="appContext" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;choice>
* &lt;sequence>
* &lt;element name="className" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="properties" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;sequence>
* &lt;element name="clientAuthConfig" type="{http://geronimo.apache.org/xml/ns/geronimo-jaspi}clientAuthConfigType" maxOccurs="unbounded" minOccurs="0"/>
* &lt;element name="serverAuthConfig" type="{http://geronimo.apache.org/xml/ns/geronimo-jaspi}serverAuthConfigType" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/choice>
* &lt;element name="persistent" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
* &lt;element name="classLoaderName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "configProviderType", propOrder = {
"messageLayer",
"appContext",
"description",
"className",
"properties",
"clientAuthConfig",
"serverAuthConfig",
"persistent",
"classLoaderName"
})
public class ConfigProviderType
implements AuthConfigFactory.RegistrationContext, Serializable, KeyedObject
{
private final static long serialVersionUID = 12343L;
protected String messageLayer;
protected String appContext;
protected String description;
protected String className;
@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;
protected Boolean persistent = Boolean.FALSE;
protected String classLoaderName;
@XmlTransient
private final List<RegistrationListener> listeners = new ArrayList<RegistrationListener>();
@XmlTransient
private AuthConfigProvider provider;
public ConfigProviderType() {
}
public ConfigProviderType(String messageLayer, String appContext, boolean persistent) {
this.messageLayer = messageLayer;
this.appContext = appContext;
this.persistent = persistent;
}
/**
* Gets the value of the messageLayer property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessageLayer() {
return messageLayer;
}
/**
* Sets the value of the messageLayer property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessageLayer(String value) {
this.messageLayer = value;
}
/**
* Gets the value of the appContext property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAppContext() {
return appContext;
}
/**
* Sets the value of the appContext property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAppContext(String value) {
this.appContext = value;
}
/**
* Gets the value of the description property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getDescription() {
return description;
}
/**
* Sets the value of the description property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDescription(String value) {
this.description = value;
}
/**
* Gets the value of the className property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getClassName() {
return className;
}
/**
* Sets the value of the className property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setClassName(String value) {
this.className = value;
}
/**
* Gets the value of the properties property.
*
* @return
* possible object is
* {@link String }
*
*/
public Map<String, String> getProperties() {
return properties;
}
/**
* Sets the value of the properties property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setProperties(Map<String, String> value) {
this.properties = value;
}
/**
* Gets the value of the clientAuthConfig property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the clientAuthConfig property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getClientAuthConfig().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link ClientAuthConfigType }
*
*
*/
public Map<String, ClientAuthConfigType> getClientAuthConfig() {
if (clientAuthConfig == null) {
clientAuthConfig = new HashMap<String, ClientAuthConfigType>();
}
return this.clientAuthConfig;
}
/**
* Gets the value of the serverAuthConfig property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the serverAuthConfig property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getServerAuthConfig().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link ServerAuthConfigType }
*
*
*/
public Map<String, ServerAuthConfigType> getServerAuthConfig() {
if (serverAuthConfig == null) {
serverAuthConfig = new HashMap<String, ServerAuthConfigType>();
}
return this.serverAuthConfig;
}
/**
* Gets the value of the persistent property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public boolean isPersistent() {
return persistent;
}
/**
* Sets the value of the persistent property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setPersistent(boolean value) {
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;
}
public void setClassLoaderName(String classLoaderName) {
this.classLoaderName = classLoaderName;
}
public void initialize(ClassLoaderLookup classLoaderLookup, CallbackHandler callbackHandler) throws AuthException {
if (className == null) {
provider = new ConfigProviderImpl(this, classLoaderLookup);
} else {
final ClassLoader classLoader = classLoaderLookup.getClassLoader(classLoaderName);
try {
provider = java.security.AccessController
.doPrivileged(new PrivilegedExceptionAction<AuthConfigProvider>() {
public AuthConfigProvider run() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
Class<? extends AuthConfigProvider> cl = (Class<? extends AuthConfigProvider>) Class.forName(className, true, classLoader);
Constructor<? extends AuthConfigProvider> cnst = cl.getConstructor(Map.class);
return cnst.newInstance(properties);
}
});
} 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);
}
}
}
public static String getRegistrationKey(String layer, String appContext) {
return layer + "/" + appContext;
}
public String getKey() {
return getRegistrationKey(getMessageLayer(), getAppContext());
}
public static class ConfigProviderImpl implements AuthConfigProvider {
private final ConfigProviderType configProviderType;
private final ClassLoaderLookup classLoaderLookup;
public ConfigProviderImpl(ConfigProviderType configProviderType, ClassLoaderLookup classLoaderLookup) {
this.configProviderType = configProviderType;
this.classLoaderLookup = classLoaderLookup;
}
/**
* spec required constructor
* @param properties
* @param 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");
}
final Map<String, ClientAuthConfigType> configTypeMap = configProviderType.getClientAuthConfig();
ClientAuthConfigType ctx = configTypeMap.get(getRegistrationKey(layer, appContext));
if (ctx == null) {
ctx = configTypeMap.get(getRegistrationKey(null, appContext));
}
if (ctx == null) {
ctx = configTypeMap.get(getRegistrationKey(layer, null));
}
if (ctx == null) {
ctx = configTypeMap.get(getRegistrationKey(null, null));
}
if (ctx != null) {
return ctx.newClientAuthConfig(layer, appContext, classLoaderLookup, 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 = configProviderType.getServerAuthConfig().get(getRegistrationKey(layer, appContext));
if (ctx == null) {
ctx = configProviderType.getServerAuthConfig().get(getRegistrationKey(null, appContext));
}
if (ctx == null) {
ctx = configProviderType.getServerAuthConfig().get(getRegistrationKey(layer, null));
}
if (ctx == null) {
ctx = configProviderType.getServerAuthConfig().get(getRegistrationKey(null, null));
}
if (ctx != null) {
return ctx.newServerAuthConfig(layer, appContext, classLoaderLookup, handler);
}
throw new AuthException("No suitable ServerAuthConfig");
}
public void refresh() throws AuthException, SecurityException {
}
}
}