- java.lang.Object
- 
- javax.security.auth.login.Configuration
 
- 
- Direct Known Subclasses:
- ConfigFile
 
 public abstract class Configuration extends Object 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 theConfigurationfrom 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 Configurationis indexed via an application name, Name, and contains a list of LoginModules configured for that application. EachLoginModuleis 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 - TheLoginModuleis required to succeed. If it succeeds or fails, authentication still continues to proceed down theLoginModulelist. 2) Requisite - TheLoginModuleis required to succeed. If it succeeds, authentication continues down theLoginModulelist. If it fails, control immediately returns to the application (authentication does not proceed down theLoginModulelist). 3) Sufficient - TheLoginModuleis not required to succeed. If it does succeed, control immediately returns to the application (authentication does not proceed down theLoginModulelist). If it fails, authentication continues down theLoginModulelist. 4) Optional - TheLoginModuleis not required to succeed. If it succeeds or fails, authentication still continues to proceed down theLoginModulelist.The overall authentication succeeds only if all Required and Requisite LoginModules succeed. If a Sufficient LoginModuleis configured and succeeds, then only the Required and Requisite LoginModules prior to that SufficientLoginModuleneed 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 OptionalLoginModulemust succeed.ModuleOptions is a space separated list of LoginModule-specific values which are passed directly to the underlying LoginModules. Options are defined by theLoginModuleitself, and control the behavior within it. For example, aLoginModulemay define options to support debugging/testing capabilities. The correct way to specify options in theConfigurationis 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 aLoginModulemay define.The following represents an example Configurationentry 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 Configurationspecifies 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 setConfigurationmethod. The installed Configuration object can be obtained by calling thegetConfigurationmethod.If no Configuration object has been installed in the runtime, a call to getConfigurationinstalls 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 thelogin.configuration.providersecurity 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 getInstancefactory 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
- See Also:
- LoginContext,- security properties
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceConfiguration.ParametersThis represents a marker interface for Configuration parameters.
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedConfiguration()Sole constructor.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AppConfigurationEntry[]getAppConfigurationEntry(String name)Retrieve the AppConfigurationEntries for the specifiednamefrom this Configuration.static ConfigurationgetConfiguration()Get the installed login Configuration.static ConfigurationgetInstance(String type, Configuration.Parameters params)Returns a Configuration object of the specified type.static ConfigurationgetInstance(String type, Configuration.Parameters params, String provider)Returns a Configuration object of the specified type.static ConfigurationgetInstance(String type, Configuration.Parameters params, Provider provider)Returns a Configuration object of the specified type.Configuration.ParametersgetParameters()Return Configuration parameters.ProvidergetProvider()Return the Provider of this Configuration.StringgetType()Return the type of this Configuration.voidrefresh()Refresh and reload the Configuration.static voidsetConfiguration(Configuration configuration)Set the loginConfiguration.
 
- 
- 
- 
Method Detail- 
getConfigurationpublic static Configuration getConfiguration() Get the installed login Configuration.- Returns:
- the login Configuration.  If a Configuration object was set
          via the Configuration.setConfigurationmethod, then that object is returned. Otherwise, a default Configuration object is returned.
- Throws:
- SecurityException- if the caller does not have permission to retrieve the Configuration.
- See Also:
- setConfiguration(javax.security.auth.login.Configuration)
 
 - 
setConfigurationpublic static void setConfiguration(Configuration configuration) Set the loginConfiguration.- Parameters:
- configuration- the new- Configuration
- Throws:
- SecurityException- if the current thread does not have Permission to set the- Configuration.
- See Also:
- getConfiguration()
 
 - 
getInstancepublic 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.preferredSecurityproperty to determine the preferred provider order for the specified algorithm. This may be different than the order of providers returned bySecurity.getProviders().
- Parameters:
- type- the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.
- params- parameters for the Configuration, which may be null.
- Returns:
- the new Configurationobject
- Throws:
- IllegalArgumentException- if the specified parameters are not understood by the- ConfigurationSpiimplementation from the selected- Provider
- NoSuchAlgorithmException- if no- Providersupports a- ConfigurationSpiimplementation for the specified type
- NullPointerException- if- typeis- null
- SecurityException- if the caller does not have permission to get a- Configurationinstance for the specified type
- Since:
- 1.6
- See Also:
- Provider
 
 - 
getInstancepublic 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- the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.
- params- parameters for the Configuration, which may be null.
- provider- the provider.
- Returns:
- the new Configurationobject
- Throws:
- IllegalArgumentException- if the specified provider is- nullor empty, or if the specified parameters are not understood by the- ConfigurationSpiimplementation from the specified provider
- NoSuchProviderException- if the specified provider is not registered in the security provider list
- NoSuchAlgorithmException- if the specified provider does not support a- ConfigurationSpiimplementation for the specified type
- NullPointerException- if- typeis- null
- SecurityException- if the caller does not have permission to get a- Configurationinstance for the specified type
- Since:
- 1.6
- See Also:
- Provider
 
 - 
getInstancepublic 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- the specified Configuration type. See the Configuration section in the Java Security Standard Algorithm Names Specification for a list of standard Configuration types.
- params- parameters for the Configuration, which may be null.
- provider- the Provider.
- Returns:
- the new Configurationobject
- Throws:
- IllegalArgumentException- if the specified- Provideris- null, or if the specified parameters are not understood by the- ConfigurationSpiimplementation from the specified Provider
- NoSuchAlgorithmException- if the specified- Providerdoes not support a- ConfigurationSpiimplementation for the specified type
- NullPointerException- if- typeis- null
- SecurityException- if the caller does not have permission to get a- Configurationinstance for the specified type
- Since:
- 1.6
- See Also:
- Provider
 
 - 
getProviderpublic 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:
- the Provider of this Configuration, or null.
- Since:
- 1.6
 
 - 
getTypepublic 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:
- the type of this Configuration, or null.
- Since:
- 1.6
 
 - 
getParameterspublic 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, or null.
- Since:
- 1.6
 
 - 
getAppConfigurationEntrypublic abstract AppConfigurationEntry[] getAppConfigurationEntry(String name) Retrieve the AppConfigurationEntries for the specifiednamefrom this Configuration.- Parameters:
- name- the name used to index the Configuration.
- Returns:
- an array of AppConfigurationEntries for the specified namefrom this Configuration, or null if there are no entries for the specifiedname
 
 - 
refreshpublic 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 refreshmay 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. - Throws:
- SecurityException- if the caller does not have permission to refresh its Configuration.
 
 
- 
 
-