Oracle Entitlements Server for Java API Reference

com.bea.security
Class AuditRecord

java.lang.Object
  |
  +--com.bea.security.NamedObject
        |
        +--com.bea.security.AuditRecord
Direct Known Subclasses:
ContextAuditRecord

public class AuditRecord
extends NamedObject

This class allows applications to log events to the audit provider. The naming authority used with these events must be based upon the AUDITBASE naming format. The AUDITBASE naming convention is defined as "TYPE/SEVERITY/MESSAGE".

The simplest way to use this class is to add a MULTI_VALUE_PREFIX attribute referencing the "AUDITBASE" naming authority as the first attribute in your own name. For example:

   <AuthorityDefinition name="CUSTOMRECORD" delimiters=":">
       <Attribute name="auditbase" type="MULTI_VALUE_PREFIX" authority="AUDITBASE" />
       <Attribute name="sessionid" type="SINGLE_VALUE_PREFIX" />
       <Attribute name="location" type="SINGLE_VALUE_TERMINAL" />
   </AuthorityDefinition>
 

In the above example, passing in a message of Session failed:#124524:Boston with a severity of FAILURE and an authority of CUSTOMRECORD would result in an audit record that contains the following name/value pairs: type=CUSTOMRECORD, severity=FAILURE, message=Session Failed, sessionid=#124524, location=Boston

Author:
Copyright © 2004-2008, Oracle and/or its affiliates. All rights reserved.

Field Summary
static int AUDIT_FAILURE
          AUDIT_FAILURE severity.
static int ERROR
          ERROR severity.
protected  HashMapContext eventCtx
          A reference to the cloned context of the application at the time of this event.
protected  java.lang.String evtMessage
          A reference to the message associated with this event.
static int FAILURE
          FAILURE severity.
protected  java.util.Map identityMap
          A map of aliases to identies.
static int INFORMATIONAL
          INFORMATIONAL severity.
protected  java.lang.Exception msgExc
          A reference to the exception associated with this event.
static java.lang.String REQUESTOR_ALIAS
          The alias that should be used to store the identity that audited the event.
protected  int severityCode
          A reference to the severity of this event.
static int SUCCESS
          SUCCESS severity.
static int WARNING
          WARNING severity.
 
Fields inherited from class com.bea.security.NamedObject
deep, nameAuth, shallow
 
Constructor Summary
AuditRecord(java.lang.String authorityname, int severity, java.lang.Exception exc)
          Construct an audit message with an exception message associated with a naming authority.
AuditRecord(java.lang.String authorityname, int severity, java.lang.Exception exc, AppContext ctx)
          Construct an audit message with an exception message associated with a naming authority.
AuditRecord(java.lang.String authorityname, int severity, java.lang.String message)
          Construct an audit message with a message associated with a naming authority.
AuditRecord(java.lang.String authorityname, int severity, java.lang.String message, AppContext ctx)
          Construct an audit message with a message associated with a naming authority and a context.
 
Method Summary
 AppContext getContext()
          Gets the context associated with this audit record.
 java.lang.Exception getException()
          Gets the exception associated with this audit record.
 AuthenticIdentity getIdentity(java.lang.String alias)
          Returns the identity associated with the given alias.
 java.util.Enumeration getIdentityAliases()
          Lists all the identity alias names of this audit record.
 java.lang.String getMessage()
          Gets the audit message.
 int getSeverity()
          Gets the severity level associated with this audit record.
 void setContext(AppContext context)
          Associates an application context with this audit record.
 void setException(java.lang.Exception exc)
          Sets an Exception object from which the audit message will be derived.
 void setIdentity(java.lang.String alias, AuthenticIdentity identity)
          Associates the given identity with the supplied alias.
 void setMessage(java.lang.String message)
          Sets the audit message.
 void setSeverity(int severity)
          Sets the severity level value associated with the AuditRecord.
static java.lang.String severityCodeToName(int severitycode)
          Converts from severity codes (int) to severity names (String).
static int severityNameToCode(java.lang.String severityname)
          Converts from severity names (String) to severity codes (int).
 java.lang.String toString()
          Returns this audit event as a string.
 
Methods inherited from class com.bea.security.NamedObject
chop, getAuthorityName, getDeepEnumeration, getEnumeration, getID, getNamingAuthority
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INFORMATIONAL

public static final int INFORMATIONAL
INFORMATIONAL severity. Identifies a record as merely informational in nature.

WARNING

public static final int WARNING
WARNING severity. Identifies a record as an warning. A warning occurs when there is an indication that an error might be occuring or about to occur.

ERROR

public static final int ERROR
ERROR severity. Identifies a record as an error. An error occurs when the normal course of an application is prevented from occuring.

SUCCESS

public static final int SUCCESS
SUCCESS severity. Identifies a record as indicating the success of some event.

FAILURE

public static final int FAILURE
FAILURE severity. Identifies a record as indicating the failure of some event.

AUDIT_FAILURE

public static final int AUDIT_FAILURE
AUDIT_FAILURE severity. Identifies a record as indicating the failure of one or more audit providers.

REQUESTOR_ALIAS

public static final java.lang.String REQUESTOR_ALIAS
The alias that should be used to store the identity that audited the event.

msgExc

protected java.lang.Exception msgExc
A reference to the exception associated with this event.

severityCode

protected int severityCode
A reference to the severity of this event.

evtMessage

protected java.lang.String evtMessage
A reference to the message associated with this event.

eventCtx

protected HashMapContext eventCtx
A reference to the cloned context of the application at the time of this event.

identityMap

protected java.util.Map identityMap
A map of aliases to identies.
Constructor Detail

AuditRecord

public AuditRecord(java.lang.String authorityname,
                   int severity,
                   java.lang.String message)
Construct an audit message with a message associated with a naming authority.

Parameters:
authorityname - the name of the naming authority defined by this message.
severity - the severity of this message. One of INFORMATIONAL, WARNING, ERROR, SUCCESS, FAILURE, or AUDIT_FAILURE.
message - the message for this audit record.

AuditRecord

public AuditRecord(java.lang.String authorityname,
                   int severity,
                   java.lang.String message,
                   AppContext ctx)
Construct an audit message with a message associated with a naming authority and a context.

Parameters:
authorityname - the name of the naming authority defined by this message.
severity - the severity of this message. One of INFORMATIONAL, WARNING, ERROR, SUCCESS, FAILURE, or AUDIT_FAILURE.
message - the message for this audit record.
ctx - an application context to be recorded with this audit record.

AuditRecord

public AuditRecord(java.lang.String authorityname,
                   int severity,
                   java.lang.Exception exc)
Construct an audit message with an exception message associated with a naming authority.

Parameters:
authorityname - the name of the naming authority defined by this message.
severity - the severity of this message. One of INFORMATIONAL, WARNING, ERROR, SUCCESS, FAILURE, or AUDIT_FAILURE.
exc - an exception associated with this audit record. The message of this audit record is taken from the exception.

AuditRecord

public AuditRecord(java.lang.String authorityname,
                   int severity,
                   java.lang.Exception exc,
                   AppContext ctx)
Construct an audit message with an exception message associated with a naming authority.

Parameters:
authorityname - the name of the naming authority defined by this message.
severity - the severity of this message. One of INFORMATIONAL, WARNING, ERROR, SUCCESS, FAILURE, or AUDIT_FAILURE.
exc - an exception associated with this audit record. The message of this audit record is taken from the exception.
ctx - an application context to be recorded with this audit record.
Method Detail

severityCodeToName

public static java.lang.String severityCodeToName(int severitycode)
Converts from severity codes (int) to severity names (String).

Parameters:
severitycode - a severity code as an int.
Returns:
the name of the severity level associated with the code. One of INFORMATIONAL, WARNING, ERROR, SUCCESS, FAILURE, or AUDIT_FAILURE.

severityNameToCode

public static int severityNameToCode(java.lang.String severityname)
Converts from severity names (String) to severity codes (int). This conversion is case insensitive.

Parameters:
severityname - a severity name as a String.
Returns:
the severity code for the given name as an int.

setException

public void setException(java.lang.Exception exc)
Sets an Exception object from which the audit message will be derived.

Parameters:
exc - an Exception object containing additonal information associated with this record.

getException

public java.lang.Exception getException()
Gets the exception associated with this audit record.

Returns:
an Exception associated with this audit record or null if one does not exist.

setSeverity

public void setSeverity(int severity)
Sets the severity level value associated with the AuditRecord. The auditing provider decides whether or not to log this record depending upon the severity.

Parameters:
severity - a severity code as an int.
Severities include:
1 INFORMATIONAL
2 WARNING
3 ERROR
4 SUCCESS
5 FAILURE
6 AUDIT_FAILURE

getSeverity

public int getSeverity()
Gets the severity level associated with this audit record.

Returns:
the severity code as an int.

setMessage

public void setMessage(java.lang.String message)
Sets the audit message.

Parameters:
message - a message for this audit record.

getMessage

public java.lang.String getMessage()
Gets the audit message.

Returns:
the message associated with this audit record.

setContext

public void setContext(AppContext context)
Associates an application context with this audit record. The audit record object will preserve the application context for use by the auditing provider.

Parameters:
context - an object with a AppContext interface containing application context for this event.

getContext

public AppContext getContext()
Gets the context associated with this audit record.

Returns:
an AppContext containing application context relevent to with audit record.

toString

public java.lang.String toString()
Returns this audit event as a string.

Returns:
this audit event as a String.
Overrides:
toString in class NamedObject

getIdentity

public AuthenticIdentity getIdentity(java.lang.String alias)
Returns the identity associated with the given alias.

Parameters:
alias - the alias name
Returns:
the identity associated with the given alias.

setIdentity

public void setIdentity(java.lang.String alias,
                        AuthenticIdentity identity)
Associates the given identity with the supplied alias. Multiple identities may be contained in an audit event, but only a single identity can be associated with a given alias.

Parameters:
alias - the alias name
identity - the identity to assoicate with the given alias

getIdentityAliases

public java.util.Enumeration getIdentityAliases()
Lists all the identity alias names of this audit record. The getIdentity(String alias) method can be used to retrieve the identity associated with each alias.

Returns:
an enumeration of all alias names