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

Quick Search    Search Deep

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

java.lang.Object
  extended bygnu.javax.security.auth.login.ConfigFileParser

public final class ConfigFileParser
extends java.lang.Object

A parser that knows how to interpret JAAS Login Module Configuration files written in the default syntax which is interpreted as adhering to the following grammar:

   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 parser handles UTF-8 entities when used as APP_NAME and PARAM_VALUE. It also checks for the use of Java identifiers used in MODULE_CLASS, thus minimizing the risks of having java.lang.ClassCastExceptions thrown at runtime due to syntactically invalid names.

In the above context, a JAVA_IDENTIFIER is a sequence of tokens, separated by the character '.'. Each of these tokens obeys the following:

  1. its first character yields true when used as an input to the Character.isJavaIdentifierStart(char)>Character.isJavaIdentifierStart(char) 55 , and
  2. all remaining characters, yield true when used as an input to Character.isJavaIdentifierPart(char)>Character.isJavaIdentifierPart(char) 55 .


Field Summary
private  ConfigFileTokenizer cft
           
private static boolean DEBUG
           
private  java.util.Map map
           
 
Constructor Summary
ConfigFileParser()
           
 
Method Summary
private  void abort(java.lang.String m)
           
private static void debug(java.lang.String m)
           
private  java.lang.String expandParamValue(java.lang.String s)
          The documentation of the javax.security.auth.login.Configuration states that: "...If a String in the form, ${system.property}, occurs in the value, it will be expanded to the value of the system property.".
 java.util.Map getLoginModulesMap()
          Returns the parse result as a java.util.Map where the keys are application names, and the entries are java.util.Lists of javax.security.auth.login.AppConfigurationEntry entries, one for each login module entry, in the order they were encountered, for that application name in the just parsed configuration file.
private  void initParser(java.io.Reader r)
           
 void parse(java.io.Reader r)
          Parses the java.io.Reader's contents assuming it is in the default syntax.
private  boolean parseACE(java.util.List listOfACEs)
           
private  boolean parseAppOrOtherEntry()
           
private  java.lang.String validateClassName(java.lang.String cn)
           
 
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

cft

private ConfigFileTokenizer cft

map

private java.util.Map map
Constructor Detail

ConfigFileParser

public ConfigFileParser()
Method Detail

debug

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

getLoginModulesMap

public java.util.Map getLoginModulesMap()
Returns the parse result as a java.util.Map where the keys are application names, and the entries are java.util.Lists of javax.security.auth.login.AppConfigurationEntry entries, one for each login module entry, in the order they were encountered, for that application name in the just parsed configuration file.


parse

public void parse(java.io.Reader r)
           throws java.io.IOException
Parses the java.io.Reader's contents assuming it is in the default syntax.


initParser

private void initParser(java.io.Reader r)
                 throws java.io.IOException

parseAppOrOtherEntry

private boolean parseAppOrOtherEntry()
                              throws java.io.IOException

parseACE

private boolean parseACE(java.util.List listOfACEs)
                  throws java.io.IOException

abort

private void abort(java.lang.String m)
            throws java.io.IOException

validateClassName

private java.lang.String validateClassName(java.lang.String cn)
                                    throws java.io.IOException

expandParamValue

private java.lang.String expandParamValue(java.lang.String s)
The documentation of the javax.security.auth.login.Configuration states that: "...If a String in the form, ${system.property}, occurs in the value, it will be expanded to the value of the system property.". This method ensures this is the case. If such a string can not be expanded then it is left AS IS, assuming the LoginModule knows what to do with it.

IMPORTANT: This implementation DOES NOT handle embedded ${} constructs.