Oracle Entitlements Server for Java API Reference

com.bea.security
Class ContextAuditRecord

java.lang.Object
  |
  +--com.bea.security.NamedObject
        |
        +--com.bea.security.AuditRecord
              |
              +--com.bea.security.ContextAuditRecord

public class ContextAuditRecord
extends AuditRecord

This class allows applications to log events to the audit provider extracting name elements from the event's application context. 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 addition to providing naming services to the audit message, this class uses the application context to populate the message with values according to the formats associated with java.text.MessageFormat. Simply include the field numbers in your message remembering that field {0} will always be the auditbase containing type, severity, and message In the above example, passing in a message of Session failed for session {1} in {2} with a severity of FAILURE and an authority of CUSTOMRECORD and a context that contains the elements sessionid and location would result in an audit record that contains the following name/value pairs: type=CUSTOMRECORD, severity=FAILURE, message=Session Failed for session #124524 in Boston, sessionid=#124524, location=Boston.

Calling toString() on this audit record will produce a string of:
CUSTOMRECORD/FAILURE/Session Failed for session #124524 in Boston.

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

Field Summary
protected  java.lang.String computedMessage
          The computed message associated with this audit record.
protected  java.util.Vector myKeys
          A reference to the vector of key names for this audit record.
protected  java.util.Vector myValues
          A reference to the vector of values for this audit record.
protected  boolean requiresCalc
          Indicates if this object needs to recalculate the message format
 
Fields inherited from class com.bea.security.AuditRecord
AUDIT_FAILURE, ERROR, eventCtx, evtMessage, FAILURE, identityMap, INFORMATIONAL, msgExc, REQUESTOR_ALIAS, severityCode, SUCCESS, WARNING
 
Fields inherited from class com.bea.security.NamedObject
deep, nameAuth, shallow
 
Constructor Summary
ContextAuditRecord(java.lang.String authorityname, int severity, java.lang.Exception exc, AppContext ctx)
          Constructs an audit record with a message contained in an exception and with reference to an application context.
ContextAuditRecord(java.lang.String authorityname, int severity, java.lang.String message, AppContext ctx)
          Constructs an audit record with a string message as a pattern and with reference to an application context.
 
Method Summary
protected  void reCalc()
          Calculates the name/value pairs for this audit message if it requires recalculatoin.
 void setContext(AppContext context)
          Adds an application context to this record.
 void setException(java.lang.Exception exc)
          Sets an Exception object from which the audit message will be derived.
 void setSeverity(int severity)
          Sets the severity level value associated with the ContextAuditRecord, from which the Auditing provider can make the decision whether or not to audit.
 java.lang.String toString()
          Returns this audit record as a string.
 
Methods inherited from class com.bea.security.AuditRecord
getContext, getException, getIdentity, getIdentityAliases, getMessage, getSeverity, setIdentity, setMessage, severityCodeToName, severityNameToCode
 
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

requiresCalc

protected boolean requiresCalc
Indicates if this object needs to recalculate the message format

myKeys

protected java.util.Vector myKeys
A reference to the vector of key names for this audit record.

myValues

protected java.util.Vector myValues
A reference to the vector of values for this audit record.

computedMessage

protected java.lang.String computedMessage
The computed message associated with this audit record. This message is constructed from the audit message as a pattern using the name definition and application context as the fields to fill the pattern.
Constructor Detail

ContextAuditRecord

public ContextAuditRecord(java.lang.String authorityname,
                          int severity,
                          java.lang.String message,
                          AppContext ctx)
Constructs an audit record with a string message as a pattern and with reference to an application context. The audit record object will attempt to populate itself with keys and values from the context as determined by its naming authority's list of attributes.

Parameters:
authorityname - the name of the naming authority for this event record.
severity - the code for the severity of this record.
ctx - an application context to associate with this audit record.

ContextAuditRecord

public ContextAuditRecord(java.lang.String authorityname,
                          int severity,
                          java.lang.Exception exc,
                          AppContext ctx)
Constructs an audit record with a message contained in an exception and with reference to an application context. The audit record object will attempt to populate itself with keys and values from the context as determined by its naming authority's list of attributes.

Parameters:
authorityname - the name of the naming authority for this event record.
severity - the code for the severity of this record.
ctx - an application context to associate with this audit record.
Method Detail

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.
Overrides:
setException in class AuditRecord

setSeverity

public void setSeverity(int severity)
Sets the severity level value associated with the ContextAuditRecord, from which the Auditing provider can make the decision whether or not to audit.

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

Overrides:
setSeverity in class AuditRecord

setContext

public void setContext(AppContext context)
Adds an application context to this record.

The audit record object will attempt to populate itself with key values from the context as determined by its naming authority's list of attributes.

Parameters:
context - an AppContext object containing application context for this record.
Overrides:
setContext in class AuditRecord

toString

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

Returns:
the audit record as a String.
Overrides:
toString in class AuditRecord

reCalc

protected void reCalc()
Calculates the name/value pairs for this audit message if it requires recalculatoin.