Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.javax.security.auth.login
Class GnuConfiguration  view GnuConfiguration download GnuConfiguration.java

java.lang.Object
  extended byjavax.security.auth.login.Configuration
      extended bygnu.javax.security.auth.login.GnuConfiguration

public final class GnuConfiguration
extends javax.security.auth.login.Configuration

An implementation of the javax.security.auth.login.Configuration class which interprets JAAS Login Configuration files written in the default syntax described in the publicly available documentation of that class. A more formal definition of this syntax is as follows:

   CONFIG              ::= APP_OR_OTHER_ENTRY+
   APP_OR_OTHER_ENTRY  ::= APP_NAME_OR_OTHER JAAS_CONFIG_BLOCK
   APP_NAME_OR_OTHER   ::= APP_NAME
                         | 'other'
   JAAS_CONFIG_BLOCK   ::= '{' (LOGIN_MODULE_ENTRY ';')+ '}' ';'
   LOGIN_MODULE_ENTRY  ::= MODULE_CLASS FLAG MODULE_OPTION* ';'
   FLAG                ::= 'required'
                         | 'requisite'
                         | 'sufficient'
                         | 'optional'
   MODULE_OPTION       ::= PARAM_NAME '=' PARAM_VALUE

   APP_NAME     ::= JAVA_IDENTIFIER
   MODULE_CLASS ::= JAVA_IDENTIFIER ('.' JAVA_IDENTIFIER)*
   PARAM_NAME   ::= STRING
   PARAM_VALUE  ::= '"' STRING '"' | ''' STRING ''' | STRING
 

This implementation will specifically attempt to process one or more Login Configuration files in the following locations, and when found parse them and merge their contents. The locations, and the order in which they are investigated, follows:

  1. If the following Security properties: java.security.auth.login.config.url.N, where N is a digit, from 1 to an arbitrary number, are defined, then the value of each of those properties will be considered as a JAAS Login Configuration file written in the default syntax. This implementation will attempt parsing all such files.

    It is worth noting the following:

    • The GNU Classpath security file, named classpath.security, where all Security properties are encoded, is usually located in /usr/local/classpath/lib/security folder.
    • The numbers used in the properties java.security.auth.login.config.url.N MUST be sequential, with no breaks in-between.

    If at least one of the designated Configuration files was found, and was parsed correctly, then no other location will be inspected.

  2. If the System property named java.security.auth.login.config is not null or empty, its contents are then interpreted as a URL to a JAAS Login Configuration file written in the default syntax.

    If this System property is defined, and the file it refers to was parsed correctly, then no other location will be inspected.

  3. If a file named .java.login.config or java.login.config (in that order) is found in the location referenced by the value of the System property user.home, then that file is parsed as a JAAS Login Configuration written in the default syntax.
  4. If none of the above resulted in a correctly parsed JAAS Login Configuration file, then this implementation will install a Null Configuration which basically does not recognize any Application.


Field Summary
private  ConfigFileParser cp
          Our reference to our default syntax parser.
private static boolean DEBUG
           
private  java.util.Map loginModulesMap
          The internal map of login modules keyed by application name.
 
Fields inherited from class javax.security.auth.login.Configuration
 
Constructor Summary
GnuConfiguration()
          Trivial 0-arguments Constructor.
 
Method Summary
private static void debug(java.lang.String m)
           
 javax.security.auth.login.AppConfigurationEntry[] getAppConfigurationEntry(java.lang.String appName)
           
private  java.io.File getConfigFromUserHome(java.io.File userHome, java.lang.String fileName)
           
private  java.io.InputStream getInputStreamFromURL(java.lang.String s)
          Attempts to open a designated string as a well-formed java.net.URL.
private  java.io.File getUserHome()
           
private  void init()
          Attempts to find and parse JAAS Login Configuration file(s) written in the default syntax.
private  void mergeLoginModules(java.util.Map otherLoginModules)
           
private  void parseConfig(java.io.InputStream configStream)
           
private  boolean processSecurityProperties()
          Attempts to locate and parse one or more JAAS Login Configuration files defined as the values of the Security properties java.security.auth.login.config.url.N.
private  boolean processSystemProperty()
          Attempts to locate and parse a JAAS Login Configuration file defined as the value of the System property java.security.auth.login.config.
private  boolean processUserHome()
          Attempts to locate and parse a JAAS Login Configuration file named either as .java.login.config or java.login.config (without the leading dot) in the folder referenced by the System property user.home.
 void refresh()
          Refreshes and reloads this Configuration.
 
Methods inherited from class javax.security.auth.login.Configuration
getConfiguration, setConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

loginModulesMap

private java.util.Map loginModulesMap
The internal map of login modules keyed by application name. Each entry in this map is a java.util.List of javax.security.auth.login.AppConfigurationEntrys for that application name.


cp

private ConfigFileParser cp
Our reference to our default syntax parser.

Constructor Detail

GnuConfiguration

public GnuConfiguration()
Trivial 0-arguments Constructor.

Method Detail

debug

private static final void debug(java.lang.String m)

getAppConfigurationEntry

public javax.security.auth.login.AppConfigurationEntry[] getAppConfigurationEntry(java.lang.String appName)

refresh

public void refresh()
Refreshes and reloads this Configuration.

This method causes this Configuration object to refresh / reload its contents following the locations and logic described above in the class documentation section.


init

private void init()
Attempts to find and parse JAAS Login Configuration file(s) written in the default syntax. The locations searched are as descibed in the class documentation.


processSecurityProperties

private boolean processSecurityProperties()
Attempts to locate and parse one or more JAAS Login Configuration files defined as the values of the Security properties java.security.auth.login.config.url.N.


getInputStreamFromURL

private java.io.InputStream getInputStreamFromURL(java.lang.String s)
                                           throws java.io.IOException
Attempts to open a designated string as a well-formed java.net.URL. If a java.net.MalformedURLException occurs, this method then tries to open that string as a java.io.File (with the same name). If it succeeds, an java.io.InputStream is constructed and returned.


processSystemProperty

private boolean processSystemProperty()
Attempts to locate and parse a JAAS Login Configuration file defined as the value of the System property java.security.auth.login.config.


processUserHome

private boolean processUserHome()
Attempts to locate and parse a JAAS Login Configuration file named either as .java.login.config or java.login.config (without the leading dot) in the folder referenced by the System property user.home.


parseConfig

private void parseConfig(java.io.InputStream configStream)
                  throws java.io.IOException

mergeLoginModules

private void mergeLoginModules(java.util.Map otherLoginModules)

getUserHome

private java.io.File getUserHome()

getConfigFromUserHome

private java.io.File getConfigFromUserHome(java.io.File userHome,
                                           java.lang.String fileName)