APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.security.auth.login

public abstract Class Configuration

extends Object
Class Inheritance
Known Direct Subclasses
javax.security.auth.login.Configuration.ConfigDelegate, sun.security.provider.ConfigFile
Imports
java.security.NoSuchAlgorithmException, .NoSuchProviderException, .Provider, .Security, java.util.Objects, sun.security.jca.GetInstance

A Configuration object is responsible for specifying which LoginModules should be used for a particular application, and in what order the LoginModules should be invoked.

A login configuration contains the following information. Note that this example only represents the default syntax for the Configuration. Subclass implementations of this class may implement alternative syntaxes and may retrieve the Configuration from any source such as files, databases, or servers.

     Name {
           ModuleClass  Flag    ModuleOptions;
           ModuleClass  Flag    ModuleOptions;
           ModuleClass  Flag    ModuleOptions;
     };
     Name {
           ModuleClass  Flag    ModuleOptions;
           ModuleClass  Flag    ModuleOptions;
     };
     other {
           ModuleClass  Flag    ModuleOptions;
           ModuleClass  Flag    ModuleOptions;
     };

Each entry in the Configuration is indexed via an application name, Name, and contains a list of LoginModules configured for that application. Each LoginModule is specified via its fully qualified class name. Authentication proceeds down the module list in the exact order specified. If an application does not have a specific entry, it defaults to the specific entry for "other".

The Flag value controls the overall behavior as authentication proceeds down the stack. The following represents a description of the valid values for Flag and their respective semantics:

     1) Required     - The LoginModule is required to succeed.
                     If it succeeds or fails, authentication still continues
                     to proceed down the LoginModule list.

     2) Requisite    - The LoginModule is required to succeed.
                     If it succeeds, authentication continues down the
                     LoginModule list.  If it fails,
                     control immediately returns to the application
                     (authentication does not proceed down the
                     LoginModule list).

     3) Sufficient   - The LoginModule is not required to
                     succeed.  If it does succeed, control immediately
                     returns to the application (authentication does not
                     proceed down the LoginModule list).
                     If it fails, authentication continues down the
                     LoginModule list.

     4) Optional     - The LoginModule is not required to
                     succeed.  If it succeeds or fails,
                     authentication still continues to proceed down the
                     LoginModule list.

The overall authentication succeeds only if all Required and Requisite LoginModules succeed. If a Sufficient LoginModule is configured and succeeds, then only the Required and Requisite LoginModules prior to that Sufficient LoginModule need to have succeeded for the overall authentication to succeed. If no Required or Requisite LoginModules are configured for an application, then at least one Sufficient or Optional LoginModule must succeed.

ModuleOptions is a space separated list of LoginModule-specific values which are passed directly to the underlying LoginModules. Options are defined by the LoginModule itself, and control the behavior within it. For example, a LoginModule may define options to support debugging/testing capabilities. The correct way to specify options in the Configuration is by using the following key-value pairing: debug="true". The key and value should be separated by an 'equals' symbol, and the value should be surrounded by double quotes. If a String in the form, ${system.property}, occurs in the value, it will be expanded to the value of the system property. Note that there is no limit to the number of options a LoginModule may define.

The following represents an example Configuration entry based on the syntax above:

Login {
  com.sun.security.auth.module.UnixLoginModule required;
  com.sun.security.auth.module.Krb5LoginModule optional
                  useTicketCache="true"
                  ticketCache="${user.home}${/}tickets";
};

This Configuration specifies that an application named, "Login", requires users to first authenticate to the com.sun.security.auth.module.UnixLoginModule, which is required to succeed. Even if the UnixLoginModule authentication fails, the com.sun.security.auth.module.Krb5LoginModule still gets invoked. This helps hide the source of failure. Since the Krb5LoginModule is Optional, the overall authentication succeeds only if the UnixLoginModule (Required) succeeds.

Also note that the LoginModule-specific options, useTicketCache="true" and ticketCache=${user.home}${/}tickets", are passed to the Krb5LoginModule. These options instruct the Krb5LoginModule to use the ticket cache at the specified location. The system properties, user.home and / (file.separator), are expanded to their respective values.

There is only one Configuration object installed in the runtime at any given time. A Configuration object can be installed by calling the setConfiguration method. The installed Configuration object can be obtained by calling the getConfiguration method.

If no Configuration object has been installed in the runtime, a call to getConfiguration installs an instance of the default Configuration implementation (a default subclass implementation of this abstract class). The default Configuration implementation can be changed by setting the value of the login.configuration.provider security property to the fully qualified name of the desired Configuration subclass implementation.

Application code can directly subclass Configuration to provide a custom implementation. In addition, an instance of a Configuration object can be constructed by invoking one of the getInstance factory methods with a standard type. The default policy type is "JavaLoginConfig". See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.

Since
1.4
External Specification
Java Security Standard Algorithm Names
See Also
javax.security.auth.login.LoginContext, security properties

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Configuration.ConfigDelegate

This subclass is returned by the getInstance calls.

public static interface
Configuration.Parameters

This represents a marker interface for Configuration parameters.

Field Summary

Modifier and TypeField and Description
private static Configuration

Constructor Summary

AccessConstructor and Description
protected
Configuration()

Sole constructor.

Method Summary

Modifier and TypeMethod and Description
public abstract AppConfigurationEntry[]

Returns:

an array of AppConfigurationEntries for the specified name from this Configuration, or null if there are no entries for the specified name
getAppConfigurationEntry
(String
the name used to index the Configuration.
name
)

Retrieve the AppConfigurationEntries for the specified name from this Configuration.

public static Configuration

Returns:

the login Configuration. If a Configuration object was set via the Configuration.setConfiguration method, then that object is returned. Otherwise, a default Configuration object is returned.
getConfiguration
()

Get the installed login Configuration.

public static Configuration

Returns:

the new Configuration object
getInstance
(String
the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.
type
,
Configuration.Parameters
parameters for the Configuration, which may be null.
params
)

Returns a Configuration object of the specified type.

public static Configuration

Returns:

the new Configuration object
getInstance
(String
the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.
type
,
Configuration.Parameters
parameters for the Configuration, which may be null.
params
,
String
the provider.
provider
)

Returns a Configuration object of the specified type.

public static Configuration

Returns:

the new Configuration object
getInstance
(String
the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.
type
,
Configuration.Parameters
parameters for the Configuration, which may be null.
params
,
Provider
the Provider.
provider
)

Returns a Configuration object of the specified type.

public Configuration.Parameters

Returns:

Configuration parameters, or null.
getParameters
()

Return Configuration parameters.

public Provider

Returns:

the Provider of this Configuration, or null.
getProvider
()

Return the Provider of this Configuration.

public String

Returns:

the type of this Configuration, or null.
getType
()

Return the type of this Configuration.

private static Configuration
public void
refresh()

Refresh and reload the Configuration.

public static void
setConfiguration(Configuration
the new Configuration
configuration
)

Set the login Configuration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configurationback to summary
private static Configuration configuration

Constructor Detail

Configurationback to summary
protected Configuration()

Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Detail

getAppConfigurationEntryback to summary
public abstract AppConfigurationEntry[] getAppConfigurationEntry(String name)

Retrieve the AppConfigurationEntries for the specified name from this Configuration.

Parameters
name:String

the name used to index the Configuration.

Returns:AppConfigurationEntry[]

an array of AppConfigurationEntries for the specified name from this Configuration, or null if there are no entries for the specified name

getConfigurationback to summary
public static Configuration getConfiguration()

Get the installed login Configuration.

Returns:Configuration

the login Configuration. If a Configuration object was set via the Configuration.setConfiguration method, then that object is returned. Otherwise, a default Configuration object is returned.

See Also
setConfiguration
getInstanceback to summary
public static Configuration getInstance(String type, Configuration.Parameters params) throws NoSuchAlgorithmException

Returns a Configuration object of the specified type.

This method traverses the list of registered security providers, starting with the most preferred Provider. A new Configuration object encapsulating the ConfigurationSpi implementation from the first Provider that supports the specified type is returned.

Note that the list of registered providers may be retrieved via the Security.getProviders() method.

Implementation Note

The JDK Reference Implementation additionally uses the jdk.security.provider.preferred Security property to determine the preferred provider order for the specified algorithm. This may be different from the order of providers returned by Security.getProviders().

Parameters
type:String

the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.

params:Configuration.Parameters

parameters for the Configuration, which may be null.

Returns:Configuration

the new Configuration object

Exceptions
NoSuchAlgorithmException:
if no Provider supports a ConfigurationSpi implementation for the specified type
IllegalArgumentException:
if the specified parameters are not understood by the ConfigurationSpi implementation from the selected Provider
NullPointerException:
if type is null
Since
1.6
External Specification
Java Security Standard Algorithm Names
See Also
Provider
getInstanceback to summary
public static Configuration getInstance(String type, Configuration.Parameters params, String provider) throws NoSuchProviderException, NoSuchAlgorithmException

Returns a Configuration object of the specified type.

A new Configuration object encapsulating the ConfigurationSpi implementation from the specified provider is returned. The specified provider must be registered in the provider list.

Note that the list of registered providers may be retrieved via the Security.getProviders() method.

Parameters
type:String

the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.

params:Configuration.Parameters

parameters for the Configuration, which may be null.

provider:String

the provider.

Returns:Configuration

the new Configuration object

Exceptions
NoSuchProviderException:
if the specified provider is not registered in the security provider list
NoSuchAlgorithmException:
if the specified provider does not support a ConfigurationSpi implementation for the specified type
IllegalArgumentException:
if the specified provider is null or empty, or if the specified parameters are not understood by the ConfigurationSpi implementation from the specified provider
NullPointerException:
if type is null
Since
1.6
External Specification
Java Security Standard Algorithm Names
See Also
Provider
getInstanceback to summary
public static Configuration getInstance(String type, Configuration.Parameters params, Provider provider) throws NoSuchAlgorithmException

Returns a Configuration object of the specified type.

A new Configuration object encapsulating the ConfigurationSpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.

Parameters
type:String

the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.

params:Configuration.Parameters

parameters for the Configuration, which may be null.

provider:Provider

the Provider.

Returns:Configuration

the new Configuration object

Exceptions
NoSuchAlgorithmException:
if the specified Provider does not support a ConfigurationSpi implementation for the specified type
IllegalArgumentException:
if the specified Provider is null, or if the specified parameters are not understood by the ConfigurationSpi implementation from the specified Provider
NullPointerException:
if type is null
Since
1.6
External Specification
Java Security Standard Algorithm Names
See Also
Provider
getParametersback to summary
public Configuration.Parameters getParameters()

Return Configuration parameters.

This Configuration instance will only have parameters if it was obtained via a call to Configuration.getInstance. Otherwise, this method returns null.

Returns:Configuration.Parameters

Configuration parameters, or null.

Since
1.6
getProviderback to summary
public Provider getProvider()

Return the Provider of this Configuration.

This Configuration instance will only have a Provider if it was obtained via a call to Configuration.getInstance. Otherwise, this method returns null.

Returns:Provider

the Provider of this Configuration, or null.

Since
1.6
getTypeback to summary
public String getType()

Return the type of this Configuration.

This Configuration instance will only have a type if it was obtained via a call to Configuration.getInstance. Otherwise, this method returns null.

Returns:String

the type of this Configuration, or null.

Since
1.6
handleExceptionback to summary
private static Configuration handleException(NoSuchAlgorithmException nsae) throws NoSuchAlgorithmException
refreshback to summary
public void refresh()

Refresh and reload the Configuration.

This method causes this Configuration object to refresh/reload its contents in an implementation-dependent manner. For example, if this Configuration object stores its entries in a file, calling refresh may cause the file to be re-read.

The default implementation of this method does nothing. This method should be overridden if a refresh operation is supported by the implementation.

setConfigurationback to summary
public static void setConfiguration(Configuration configuration)

Set the login Configuration.

Parameters
configuration:Configuration

the new Configuration

See Also
getConfiguration
javax.security.auth.login back to summary

private Class Configuration.ConfigDelegate

extends Configuration
Class Inheritance

This subclass is returned by the getInstance calls. All Configuration calls are delegated to the underlying ConfigurationSpi.

Field Summary

Modifier and TypeField and Description
private final Provider
p

private final Configuration.Parameters
private final ConfigurationSpi
private final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public AppConfigurationEntry[]
getAppConfigurationEntry(String name)

Implements abstract javax.security.auth.login.Configuration.getAppConfigurationEntry.

Retrieve the AppConfigurationEntries for the specified name from this Configuration.

public Configuration.Parameters
getParameters()

Overrides javax.security.auth.login.Configuration.getParameters.

Return Configuration parameters.

public Provider
getProvider()

Overrides javax.security.auth.login.Configuration.getProvider.

Return the Provider of this Configuration.

public String
getType()

Overrides javax.security.auth.login.Configuration.getType.

Return the type of this Configuration.

public void
refresh()

Overrides javax.security.auth.login.Configuration.refresh.

Refresh and reload the Configuration.

Inherited from javax.security.auth.login.Configuration:
getConfigurationgetInstancegetInstancegetInstancesetConfiguration

Field Detail

pback to summary
private final Provider p
paramsback to summary
private final Configuration.Parameters params
spiback to summary
private final ConfigurationSpi spi
typeback to summary
private final String type

Constructor Detail

ConfigDelegateback to summary
private ConfigDelegate(ConfigurationSpi spi, Provider p, String type, Configuration.Parameters params)

Method Detail

getAppConfigurationEntryback to summary
public AppConfigurationEntry[] getAppConfigurationEntry(String name)

Implements abstract javax.security.auth.login.Configuration.getAppConfigurationEntry.

Doc from javax.security.auth.login.Configuration.getAppConfigurationEntry.

Retrieve the AppConfigurationEntries for the specified name from this Configuration.

getParametersback to summary
public Configuration.Parameters getParameters()

Overrides javax.security.auth.login.Configuration.getParameters.

Doc from javax.security.auth.login.Configuration.getParameters.

Return Configuration parameters.

This Configuration instance will only have parameters if it was obtained via a call to Configuration.getInstance. Otherwise, this method returns null.

getProviderback to summary
public Provider getProvider()

Overrides javax.security.auth.login.Configuration.getProvider.

Doc from javax.security.auth.login.Configuration.getProvider.

Return the Provider of this Configuration.

This Configuration instance will only have a Provider if it was obtained via a call to Configuration.getInstance. Otherwise, this method returns null.

getTypeback to summary
public String getType()

Overrides javax.security.auth.login.Configuration.getType.

Doc from javax.security.auth.login.Configuration.getType.

Return the type of this Configuration.

This Configuration instance will only have a type if it was obtained via a call to Configuration.getInstance. Otherwise, this method returns null.

refreshback to summary
public void refresh()

Overrides javax.security.auth.login.Configuration.refresh.

Doc from javax.security.auth.login.Configuration.refresh.

Refresh and reload the Configuration.

This method causes this Configuration object to refresh/reload its contents in an implementation-dependent manner. For example, if this Configuration object stores its entries in a file, calling refresh may cause the file to be re-read.

The default implementation of this method does nothing. This method should be overridden if a refresh operation is supported by the implementation.

javax.security.auth.login back to summary

public Interface Configuration.Parameters

Known Direct Implementers
java.security.URIParameter

This represents a marker interface for Configuration parameters.
Since
1.6