org.aselect.system.logging
Class AuthenticationLogger

java.lang.Object
  extended by org.aselect.system.logging.AuthenticationLogger
Direct Known Subclasses:
ASelectAuthenticationLogger, AuthSPAuthenticationLogger

public class AuthenticationLogger
extends java.lang.Object

Authentication logger.

Description:
This class implements a logger with the purpose of logging authentication message to a system logger or a database.

Concurrency issues:
This class is thread-safe.

This class only writes log items and can therefore use one resource (e.g. database connection).

Author:
Alfa & Ariss

Constructor Summary
AuthenticationLogger()
          Create a new default instance.
 
Method Summary
 void closeHandlers()
          Cleanup logger resources.
 void init(java.lang.String sComponent, ConfigManager oConfigManager, java.lang.Object oLogTargetConfig, SystemLogger oSystemLogger)
          Initializes the Authentication logger with a database back-end.
 void init(java.lang.String sComponent, java.lang.String sLogFileNamePrefix, java.lang.String sLoggerNamespace, ConfigManager oConfigManager, java.lang.Object oLogTargetConfig, SystemLogger oSystemLogger, java.lang.String sWorkingDir)
          Initializes the Authentication logger with a file back-end.
 void log(java.lang.Object[] oLogFields)
          Logs all objects in the supplied object array to the logging target.
 void log(java.lang.String sMessage)
          Log a message.
 void log(java.lang.String sAction, java.lang.String sUser, java.lang.String sIP, java.lang.String sAppID, java.lang.String sMessage)
          Write a log item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthenticationLogger

public AuthenticationLogger()
Create a new default instance.

Description:
Creates a new AuthenticationLogger. If you use this constructor you'll need to call one of the init() methods.

Method Detail

init

public void init(java.lang.String sComponent,
                 java.lang.String sLogFileNamePrefix,
                 java.lang.String sLoggerNamespace,
                 ConfigManager oConfigManager,
                 java.lang.Object oLogTargetConfig,
                 SystemLogger oSystemLogger,
                 java.lang.String sWorkingDir)
          throws ASelectException
Initializes the Authentication logger with a file back-end.

Description:
  • Reads configuration
  • Sets the _bLogToDatabase to FALSE
  • Creates a new SystemLogger object and initializes it with the configuration.


  • Concurrency issues:
    -

    Preconditions:
  • oConfigManager must be initialized
  • oSystemLogger must be initialized
  • oConfigManager may not be null
  • oLogTargetConfig may not be null
  • oSystemLogger may not be null
  • sComponent may not be null


  • Postconditions:
    Sets _systemLogger class vairable and initializes it.

    Parameters:
    sComponent - The name of the A-Select component for which the authentication logger is used
    sLogFileNamePrefix - The log file name prefix (".log" is appended).
    sLoggerNamespace - The namespace of this system logger.
    oConfigManager - The config manager used to retrieve the configuration from
    oLogTargetConfig - The 'target' config section containing the file configuration
    oSystemLogger - The back-up logger that must be used to log any errors if database logging failed
    sWorkingDir - The workingdir that must be used when no directory is configured
    Throws:
    ASelectException - if initializing failed (missing config items)

    init

    public void init(java.lang.String sComponent,
                     ConfigManager oConfigManager,
                     java.lang.Object oLogTargetConfig,
                     SystemLogger oSystemLogger)
              throws ASelectException
    Initializes the Authentication logger with a database back-end.

    Description:
  • Reads configuration
  • Tries to connect to the database
  • Retrieves the column types of the database columns that are configured
  • Creates the query for the PreparedStatement that is used by logging
  • Sets the _bLogToDatabase to TRUE


  • Concurrency issues:
    -

    Preconditions:
  • oConfigManager must be initialized
  • oSystemLogger must be initialized
  • oConfigManager may not be null
  • oLogTargetConfig may not be null
  • oSystemLogger may not be null


  • Postconditions:
    -

    Parameters:
    sComponent - The name of the A-Select component for which the authentication logger is used
    oConfigManager - The config manager used to retrieve the configuration from
    oLogTargetConfig - The 'target' config section containing the configuration
    oSystemLogger - The back-up logger that must be used to log any errors if database logging failed
    Throws:
    ASelectException - if initializing failed (missing config items)

    log

    public void log(java.lang.String sAction,
                    java.lang.String sUser,
                    java.lang.String sIP,
                    java.lang.String sAppID,
                    java.lang.String sMessage)
    Write a log item.

    Description:
    Write a log item with detailed information.

    Concurrency issues:
    -

    Preconditions:
    The AuthenticationLogger is initialized.

    Postconditions:
    -

    Parameters:
    sAction - The action that should be logged.
    sUser - The user that should be logged.
    sIP - The remote IP address.
    sAppID - The application id.
    sMessage - The log message.

    log

    public void log(java.lang.String sMessage)
    Log a message.

    Description:
    Logs a simple log message.

    Concurrency issues:
    -

    Preconditions:
    The AuthenticationLogger is initialized.

    Postconditions:
    -

    Parameters:
    sMessage - The message to be logged.

    log

    public void log(java.lang.Object[] oLogFields)
    Logs all objects in the supplied object array to the logging target.

    Description:
  • If the target is a file, all objects in the supplied array will be concat with '::' to one String and the string will be logged to a file.
  • If the target is a database, every object in the supplied array will be stored in a column of the configured database table.

  • Within A-Select components (UDB Connectors and AuthSP Handlers) the following components sequence will be used.
  • A-Select component. (e.g. A-Select Server)
  • Action (MODULE.method())
  • IP (Users IP address)
  • User (A-Select user id)
  • Organization (The A-Select organization)
  • APP ID (A-Select app_id for which the user will be authenticated)
  • Message (The log message)


  • Concurrency issues:
    -

    Preconditions:
    -

    Postconditions:
    -

    Parameters:
    oLogFields - All objects that should be logged

    closeHandlers

    public void closeHandlers()
    Cleanup logger resources.

    Description:
    Closes all openend log handlers. Disconnects the database connection if applicable.

    Concurrency issues:
    -

    Preconditions:
    -

    Postconditions:

    See Also:
    SystemLogger.closeHandlers()


    Copyright © 2008 SURFnet BV. All Rights Reserved.