gnu.javax.security.auth.login

Class GnuConfiguration


public final class GnuConfiguration
extends Configuration

An implementation of the 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 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.

    • 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.
    • 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.

    Constructor Summary

    GnuConfiguration()
    Trivial 0-arguments Constructor.

    Method Summary

    AppConfigurationEntry[]
    getAppConfigurationEntry(String appName)
    void
    refresh()
    Refreshes and reloads this Configuration.

    Methods inherited from class javax.security.auth.login.Configuration

    getAppConfigurationEntry, getConfiguration, refresh, setConfiguration

    Methods inherited from class java.lang.Object

    clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

    Constructor Details

    GnuConfiguration

    public GnuConfiguration()
    Trivial 0-arguments Constructor.

    Method Details

    getAppConfigurationEntry

    public AppConfigurationEntry[] getAppConfigurationEntry(String appName)
    Overrides:
    getAppConfigurationEntry in interface Configuration

    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.

    Overrides:
    refresh in interface Configuration
    Throws:
    SecurityException - if the caller does not have an AuthPermission for the action named refreshLoginConfiguration.

    GnuConfiguration.java -- GNU Classpath implementation of JAAS Configuration Copyright (C) 2006, 2010 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.