Top Description Inners Fields Constructors Methods
javax.security.auth.message.config

public abstract Class AuthConfigFactory

extends Object
Class Inheritance
Imports
java.security.Permission, .Security, .SecurityPermission, java.util.Map, .Properties

This class is used to obtain AuthConfigProvider objects that can be used to obtain authentication context configuration objects, that is, ClientAuthConfig and ServerAuthConfig objects.

Authentication context configuration objects are used to obtain authentication context objects. Authentication context objects, that is, ClientAuthContext and ServerAuthContex objects, encapsulate authentication modules. Authentication modules are pluggable components that perform security-related processing of request and response messages.

Callers do not operate on modules directly. Instead they rely on an authentication context to manage the invocation of modules. A caller obtains an authentication context by calling the getAuthContext method on a ClientAuthConfig or ServerAuthConfig obtained from an AuthConfigProvider.

The following represents a typical sequence of calls for obtaining a client authentication context, and then using it to secure a request.

  1. AuthConfigFactory factory = AuthConfigFactory.getFactory();
  2. AuthConfigProvider provider = factory.getConfigProvider(layer,appID,listener);
  3. ClientAuthConfig config = provider.getClientAuthConfig(layer,appID,cbh)
  4. String authContextID = config.getAuthContextID(messageInfo);
  5. ClientAuthContext context = config.getAuthContext(authContextID,subject,properties);
  6. context.secureRequest(messageInfo,subject);

A system-wide AuthConfigFactory implementation can be set by invoking setFactory, and retrieved using getFactory.

Every implementation of this abstract class must offer a public, zero argument constructor. This constructor must support the construction and registration (including self-registration) of AuthConfigProviders from a persistent declarative representation. For example, a factory implementation class could interpret the contents of a file containing a sequence of configuration entries, with one entry per AuthConfigProvider, and with each entry representing:

Any provider initialization properties must be specified in a form that can be passed to the provider constructor within a Map of key, value pairs, and where all keys and values within the Map are of type String.

The entry syntax must also provide for the optional inclusion of information sufficient to define a RegistrationContext. This information would only be present when the factory will register the provider. For example, each entry could provide for the inclusion of one or more RegistrationContext objects of the following form:

When a RegistrationContext is not included, the factory must make it convenient for the provider to self-register with the factory during the provider construction (see registerConfigProvider(AuthConfigProvider provider, ...)).

An AuthConfigFactory implementation is free to choose is own persistent declarative syntax as long as it conforms to the requirements defined by this class.

See Also
ClientAuthContext, ServerAuthContext, ClientAuthConfig, ServerAuthConfig, Properties

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
AuthConfigFactory.RegistrationContext

Represents the layer identifier, application context identifier, and description components of an AuthConfigProvider registration at the factory.

Field Summary

Modifier and TypeField and Description
public static final String
DEFAULT_FACTORY_SECURITY_PROPERTY

The name of the Security property used to define the default AuthConfigFactory implementation class.

private static AuthConfigFactory
public static final String
GET_FACTORY_PERMISSION_NAME

The name of the SecurityPermission required to call getFactory

public static final SecurityPermission
getFactorySecurityPermission

The SecurityPermission, with name GET_FACTORY_PERMISSION_NAME, that is used to authorize access to the getFactory method.

public static final String
PROVIDER_REGISTRATION_PERMISSION_NAME

The name of the SecurityPermission to be used to authorize access to the update methods of the factory implementation class.

private static final String
PROVIDER_SECURITY_PROPERTY

The name of the Security property used to control operations within the factory.

public static final SecurityPermission
providerRegistrationSecurityPermission

An instance of the SecurityPermission (with name PROVIDER_REGISTRATION_PERMISSION_NAME) for use in authorizing access to the update methods of the factory implementation class.

public static final String
SET_FACTORY_PERMISSION_NAME

The name of the SecurityPermission required to call setFactory

public static final SecurityPermission
setFactorySecurityPermission

The SecurityPermission, with name SET_FACTORY_PERMISSION_NAME, that is used to authorize access to the setFactory method.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
checkPermission(Permission p)

utility method to check for permission to operate on the factory.

public abstract String[]

Returns:

An array of String values where each value identifies a provider registration from which the listener was removed. This method never returns null; it returns an empty array if the listener was not removed from any registrations.
detachListener
(RegistrationListener
The RegistrationListener to be detached.
listener
,
String
A String identifying the message layer or null.
layer
,
String
A String value identifying the application context or null.
appContext
)

Disassociate the listener from all the provider registrations whose layer and appContext values are matched by the corresponding arguments to this method.

public abstract AuthConfigProvider

Returns:

The implementation of the AuthConfigProvider interface registered at the factory for the layer and appContext, or null if no AuthConfigProvider is selected. An argument listener is attached even if the return value is null.
getConfigProvider
(String
A String identifying the message layer for which the registered AuthConfigProvider is to be returned. The value of this argument may be null.
layer
,
String
A String that identifies the application messaging context for which the registered AuthConfigProvider is to be returned. The value of this argument may be null.
appContext
,
RegistrationListener
The RegistrationListener whose notify method is to be invoked if the corresponding registration is unregistered or replaced. The value of this argument may be null.
listener
)

Get a registered AuthConfigProvider from the factory.

public static synchronized AuthConfigFactory

Returns:

The non-null system-wide AuthConfigFactory instance set at the time of the call, or if that value was null, the value of the system-wide factory instance established by this method. This method returns null when the system-wide factory was not defined when this method was called and no default factory name was defined via the security property.
getFactory
()

Get the system-wide AuthConfigFactory implementation.

public abstract AuthConfigFactory.RegistrationContext

Returns:

A RegistrationContext or null. When a Non-null value is returned, it is a copy of the registration context corresponding to the registration. Null is returned when the registration identifier does not correspond to an active registration
getRegistrationContext
(String
A String that identifies a provider registration at the factory
registrationID
)

Get the the registration context for the identified registration.

public abstract String[]

Returns:

An array of String values where each value identifies a provider registration at the factory. This method never returns null; it returns an empty array when there are no registrations at the factory for the identified provider.
getRegistrationIDs
(AuthConfigProvider
The AuthConfigurationProvider whose registration identifiers are to be returned. This argument may be null, in which case it indicates that the IDs of all active registrations within the factory are to be returned.
provider
)

Get the registration identifiers for all registrations of the provider instance at the factory.

public abstract void
refresh()

Cause the factory to reprocess its persistent declarative representation of provider registrations.

public abstract String

Returns:

A String identifier assigned by the factory to the provider registration, and that may be used to remove the registration from the factory.
registerConfigProvider
(String
The fully qualified name of an AuthConfigProvider implementation class (or null). Calling this method with a null value for this parameter shall cause getConfigProvider to return null when it is called with layer and appContext values for which the resulting registration is the best match.
className
,
Map<K, V>
A Map object containing the initialization properties to be passed to the properties argument of the provider constructor. This argument may be null. When this argument is not null, all the values and keys occurring in the Map must be of type String.
properties
,
String
A String identifying the message layer for which the provider will be registered at the factory. A null value may be passed as an argument for this parameter, in which case the provider is registered at all layers.
layer
,
String
A String value that may be used by a runtime to request a configuration object from this provider. A null value may be passed as an argument for this parameter, in which case the provider is registered for all configuration ids (at the indicated layers).
appContext
,
String
A text String describing the provider. This value may be null.
description
)

Registers within the factory and records within the factory's persistent declarative representation of provider registrations a provider of ServerAuthConfig and/or ClientAuthConfig objects for a message layer and application context identifier.

public abstract String

Returns:

A String identifier assigned by the factory to the provider registration, and that may be used to remove the registration from the factory.
registerConfigProvider
(AuthConfigProvider
The AuthConfigProvider to be registered at the factory (or null). Calling this method with a null value for this parameter shall cause getConfigProvider to return null when it is called with layer and appContext values for which the resulting registration is the best match.
provider
,
String
A String identifying the message layer for which the provider will be registered at the factory. A null value may be passed as an argument for this parameter, in which case the provider is registered at all layers.
layer
,
String
A String value that may be used by a runtime to request a configuration object from this provider. A null value may be passed as an argument for this parameter, in which case the provider is registered for all configuration ids (at the indicated layers).
appContext
,
String
A text String describing the provider. This value may be null.
description
)

Registers within the (in-memory) factory, a provider of ServerAuthConfig and/or ClientAuthConfig objects for a message layer and application context identifier.

public abstract boolean

Returns:

True if there was a registration with the specified identifier and it was removed. Return false if the registrationID was invalid.
removeRegistration
(String
A String that identifies a provider registration at the factory
registrationID
)

Remove the identified provider registration from the factory (and from the persistent declarative representation of provider registrations, if appropriate) and invoke any listeners associated with the removed registration.

public static synchronized void
setFactory(AuthConfigFactory
The AuthConfigFactory instance, which may be null.
factory
)

Set the system-wide AuthConfigFactory implementation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FACTORY_SECURITY_PROPERTYback to summary
public static final String DEFAULT_FACTORY_SECURITY_PROPERTY

The name of the Security property used to define the default AuthConfigFactory implementation class.

factoryback to summary
private static AuthConfigFactory factory
GET_FACTORY_PERMISSION_NAMEback to summary
public static final String GET_FACTORY_PERMISSION_NAME

The name of the SecurityPermission required to call getFactory

getFactorySecurityPermissionback to summary
public static final SecurityPermission getFactorySecurityPermission

The SecurityPermission, with name GET_FACTORY_PERMISSION_NAME, that is used to authorize access to the getFactory method.

PROVIDER_REGISTRATION_PERMISSION_NAMEback to summary
public static final String PROVIDER_REGISTRATION_PERMISSION_NAME

The name of the SecurityPermission to be used to authorize access to the update methods of the factory implementation class.

PROVIDER_SECURITY_PROPERTYback to summary
private static final String PROVIDER_SECURITY_PROPERTY

The name of the Security property used to control operations within the factory.

providerRegistrationSecurityPermissionback to summary
public static final SecurityPermission providerRegistrationSecurityPermission

An instance of the SecurityPermission (with name PROVIDER_REGISTRATION_PERMISSION_NAME) for use in authorizing access to the update methods of the factory implementation class.

SET_FACTORY_PERMISSION_NAMEback to summary
public static final String SET_FACTORY_PERMISSION_NAME

The name of the SecurityPermission required to call setFactory

setFactorySecurityPermissionback to summary
public static final SecurityPermission setFactorySecurityPermission

The SecurityPermission, with name SET_FACTORY_PERMISSION_NAME, that is used to authorize access to the setFactory method.

Constructor Detail

AuthConfigFactoryback to summary
public AuthConfigFactory()

Method Detail

checkPermissionback to summary
private static void checkPermission(Permission p) throws SecurityException

utility method to check for permission to operate on the factory.

Exceptions
SecurityException:
if the SecurityManager is enabled and the calling access control context has not been granted the argument permission.
detachListenerback to summary
public abstract String[] detachListener(RegistrationListener listener, String layer, String appContext)

Disassociate the listener from all the provider registrations whose layer and appContext values are matched by the corresponding arguments to this method.

Factories should periodically notify Listeners to effectively detach listeners that are no longer in use.

When a SecurityManager is enabled, and before making any changes to the factory, this method must confirm that the calling access control context has been granted the providerRegistrationSecurityPermission

Parameters
listener:RegistrationListener

The RegistrationListener to be detached.

layer:String

A String identifying the message layer or null.

appContext:String

A String value identifying the application context or null.

Returns:String[]

An array of String values where each value identifies a provider registration from which the listener was removed. This method never returns null; it returns an empty array if the listener was not removed from any registrations.

Exceptions
SecurityException:
If the caller does not have permission to detach the listener from the factory.
getConfigProviderback to summary
public abstract AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener)

Get a registered AuthConfigProvider from the factory. Get the provider of ServerAuthConfig and ClientAuthConfig objects registered for the identified message layer and application context.

All factories shall employ the following precedence rules to select the registered AuthConfigProvider that matches the layer and appContext arguments:

  • The provider specifically registered for the values passed as the layer and appContext arguments shall be selected.
  • If no provider is selected according to the preceding rule, the provider specifically registered for the value passed as the appContext argument and for all (that is, null) layers shall be selected.
  • If no provider is selected according to the preceding rules, the provider specifically registered for the value passed as the layer argument and for all (that is, null) appContexts shall be selected.
  • If no provider is selected according to the preceding rules, the provider registered for all (that is, null) layers and for all (that is, null) appContexts shall be selected.
  • If no provider is selected according to the preceding rules, the factory shall terminate its search for a registered provider.

The above precedence rules apply equivalently to registrations created with a null or non-null className argument.

Parameters
layer:String

A String identifying the message layer for which the registered AuthConfigProvider is to be returned. The value of this argument may be null.

appContext:String

A String that identifies the application messaging context for which the registered AuthConfigProvider is to be returned. The value of this argument may be null.

listener:RegistrationListener

The RegistrationListener whose notify method is to be invoked if the corresponding registration is unregistered or replaced. The value of this argument may be null.

Returns:AuthConfigProvider

The implementation of the AuthConfigProvider interface registered at the factory for the layer and appContext, or null if no AuthConfigProvider is selected. An argument listener is attached even if the return value is null.

getFactoryback to summary
public static synchronized AuthConfigFactory getFactory()

Get the system-wide AuthConfigFactory implementation.

If a non-null system-wide factory instance is defined at the time of the call, for example, with setFactory, it will be returned. Otherwise, an attempt will be made to construct an instance of the default AuthConfigFactory implementation class. The fully qualified class name of the default factory implementation class is obtained from the value of the DEFAULT_FACTORY_SECURITY_PROPERTY security property. When an instance of the default factory implementation class is successfully constructed by this method, this method will set it as the system-wide factory instance.

The absolute pathname of the Java security properties file is JAVA_HOME/lib/security/java.security, where JAVA_HOME refers to the directory where the JDK was installed.

When a SecurityManager is enabled, the getFactorySecurityPermission will be required to call this method. If at the time of the call, a system-wide factory instance has not already been defined, then the setFactorySecurityPermission will also be required.

Returns:AuthConfigFactory

The non-null system-wide AuthConfigFactory instance set at the time of the call, or if that value was null, the value of the system-wide factory instance established by this method. This method returns null when the system-wide factory was not defined when this method was called and no default factory name was defined via the security property.

Exceptions
SecurityException:
If the caller does not have permission to retrieve the factory, or set it as the system-wide instance. Also thrown if an exception was thrown during the class loading, or construction of the default AuthConfigFactory implementation class; in which case the SecurityException will contain the root Exception as its cause.
getRegistrationContextback to summary
public abstract AuthConfigFactory.RegistrationContext getRegistrationContext(String registrationID)

Get the the registration context for the identified registration.

Parameters
registrationID:String

A String that identifies a provider registration at the factory

Returns:AuthConfigFactory.RegistrationContext

A RegistrationContext or null. When a Non-null value is returned, it is a copy of the registration context corresponding to the registration. Null is returned when the registration identifier does not correspond to an active registration

getRegistrationIDsback to summary
public abstract String[] getRegistrationIDs(AuthConfigProvider provider)

Get the registration identifiers for all registrations of the provider instance at the factory.

Parameters
provider:AuthConfigProvider

The AuthConfigurationProvider whose registration identifiers are to be returned. This argument may be null, in which case it indicates that the IDs of all active registrations within the factory are to be returned.

Returns:String[]

An array of String values where each value identifies a provider registration at the factory. This method never returns null; it returns an empty array when there are no registrations at the factory for the identified provider.

refreshback to summary
public abstract void refresh()

Cause the factory to reprocess its persistent declarative representation of provider registrations.

A factory should only replace an existing registration when a change of provider implementation class or initialization properties has occurred.

When a SecurityManager is enabled, and before the point where this method could have caused any changes to the factory, this method must confirm that the calling access control context has been granted the providerRegistrationSecurityPermission

Exceptions
SecurityException:
If the caller does not have permission to refresh the factory, or if an error occurred during the reinitialization.
registerConfigProviderback to summary
public abstract String registerConfigProvider(String className, Map<K, V> properties, String layer, String appContext, String description)

Registers within the factory and records within the factory's persistent declarative representation of provider registrations a provider of ServerAuthConfig and/or ClientAuthConfig objects for a message layer and application context identifier. This method typically constructs an instance of the provider before registering it with the factory. Factories may extend or modify the persisted registrations of existing provider instances, if those instances were registered with ClassName and properties arguments equivalent to those passed in the current call.

This method employs the two argument constructor required to be supported by every implementation of the AuthConfigProvider interface, and this method must pass a null value for the factory argument of the constructor. AuthConfigProviderImpl AuthConfigProviderImpl(Map properties, AuthConfigFactory factory).

At most one registration may exist within the factory for a given combination of message layer and appContext. Any pre-existing registration with identical values for layer and appContext is replaced by a subsequent registration. When replacement occurs, the registration identifier, layer, and appContext identifier remain unchanged, and the AuthConfigProvider (with initialization properties) and description are replaced.

Within the lifetime of its Java process, a factory must assign unique registration identifiers to registrations, and must never assign a previously used registration identifier to a registration whose message layer and or appContext identifier differ from the previous use.

Programmatic registrations performed by using this method must update (according to the replacement rules described above) the persistent declarative representation of provider registrations employed by the factory constructor.

When a SecurityManager is enabled, before loading the argument provider, and before making any changes to the factory, this method must confirm that the calling access control context has been granted the providerRegistrationSecurityPermission

Parameters
className:String

The fully qualified name of an AuthConfigProvider implementation class (or null). Calling this method with a null value for this parameter shall cause getConfigProvider to return null when it is called with layer and appContext values for which the resulting registration is the best match.

properties:Map<K, V>

A Map object containing the initialization properties to be passed to the properties argument of the provider constructor. This argument may be null. When this argument is not null, all the values and keys occurring in the Map must be of type String.

layer:String

A String identifying the message layer for which the provider will be registered at the factory. A null value may be passed as an argument for this parameter, in which case the provider is registered at all layers.

appContext:String

A String value that may be used by a runtime to request a configuration object from this provider. A null value may be passed as an argument for this parameter, in which case the provider is registered for all configuration ids (at the indicated layers).

description:String

A text String describing the provider. This value may be null.

Returns:String

A String identifier assigned by the factory to the provider registration, and that may be used to remove the registration from the factory.

Exceptions
SecurityException:
If the caller does not have permission to register a provider at the factory, or if the the provider construction (given a non-null className) or registration fails.
registerConfigProviderback to summary
public abstract String registerConfigProvider(AuthConfigProvider provider, String layer, String appContext, String description)

Registers within the (in-memory) factory, a provider of ServerAuthConfig and/or ClientAuthConfig objects for a message layer and application context identifier. This method does NOT effect the factory's persistent declarative representation of provider registrations, and is intended to be used by providers to perform self-Registration.

At most one registration may exist within the factory for a given combination of message layer and appContext. Any pre-existing registration with identical values for layer and appContext is replaced by a subsequent registration. When replacement occurs, the registration identifier, layer, and appContext identifier remain unchanged, and the AuthConfigProvider (with initialization properties) and description are replaced.

Within the lifetime of its Java process, a factory must assign unique registration identifiers to registrations, and must never assign a previously used registration identifier to a registration whose message layer and or appContext identifier differ from the previous use.

When a SecurityManager is enabled, and before making any changes to the factory, this method must confirm that the calling access control context has been granted the providerRegistrationSecurityPermission

Parameters
provider:AuthConfigProvider

The AuthConfigProvider to be registered at the factory (or null). Calling this method with a null value for this parameter shall cause getConfigProvider to return null when it is called with layer and appContext values for which the resulting registration is the best match.

layer:String

A String identifying the message layer for which the provider will be registered at the factory. A null value may be passed as an argument for this parameter, in which case the provider is registered at all layers.

appContext:String

A String value that may be used by a runtime to request a configuration object from this provider. A null value may be passed as an argument for this parameter, in which case the provider is registered for all configuration ids (at the indicated layers).

description:String

A text String describing the provider. This value may be null.

Returns:String

A String identifier assigned by the factory to the provider registration, and that may be used to remove the registration from the factory.

Exceptions
SecurityException:
If the caller does not have permission to register a provider at the factory, or if the provider registration fails.
removeRegistrationback to summary
public abstract boolean removeRegistration(String registrationID)

Remove the identified provider registration from the factory (and from the persistent declarative representation of provider registrations, if appropriate) and invoke any listeners associated with the removed registration.

When a SecurityManager is enabled, and before making any changes to the factory, this method must confirm that the calling access control context has been granted the providerRegistrationSecurityPermission

Parameters
registrationID:String

A String that identifies a provider registration at the factory

Returns:boolean

True if there was a registration with the specified identifier and it was removed. Return false if the registrationID was invalid.

Exceptions
SecurityException:
If the caller does not have permission to unregister the provider at the factory.
setFactoryback to summary
public static synchronized void setFactory(AuthConfigFactory factory)

Set the system-wide AuthConfigFactory implementation.

If an implementation was set previously, it will be replaced.

Listeners are not notified of a change to the registered factory.

Parameters
factory:AuthConfigFactory

The AuthConfigFactory instance, which may be null.

Exceptions
SecurityException:
If the caller does not have permission to set the factory.
javax.security.auth.message.config back to summary

public Interface AuthConfigFactory.RegistrationContext


Represents the layer identifier, application context identifier, and description components of an AuthConfigProvider registration at the factory.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

A String identifying the application context for which the AuthConfigProvider was registered. The returned value may be null.
getAppContext
()

Get the application context identifier from the registration context

public String

Returns:

The description String from the registration, or null if no description string was included in the registration.
getDescription
()

Get the description from the registration context

public String

Returns:

A String identifying the message layer for which the AuthConfigProvider was registered. The returned value may be null.
getMessageLayer
()

Get the layer name from the registration context

public boolean

Returns:

A boolean indicating whether the registration is the result of a className based registration, or an instance-based (for example, self-) registration. Only registrations performed using the five argument registerConfigProvider method are persistent.
isPersistent
()

Get the persisted status from the registration context.

Method Detail

getAppContextback to summary
public String getAppContext()

Get the application context identifier from the registration context

Returns:String

A String identifying the application context for which the AuthConfigProvider was registered. The returned value may be null.

getDescriptionback to summary
public String getDescription()

Get the description from the registration context

Returns:String

The description String from the registration, or null if no description string was included in the registration.

getMessageLayerback to summary
public String getMessageLayer()

Get the layer name from the registration context

Returns:String

A String identifying the message layer for which the AuthConfigProvider was registered. The returned value may be null.

isPersistentback to summary
public boolean isPersistent()

Get the persisted status from the registration context.

Returns:boolean

A boolean indicating whether the registration is the result of a className based registration, or an instance-based (for example, self-) registration. Only registrations performed using the five argument registerConfigProvider method are persistent.