10-4 Developing Security Providers for Oracle WebLogic Server
10.3 Implementing the ContextHandler MBean
The ContextHandlerMBean, weblogic.management.security.audit.ContextHandler, provides a set of
attributes for ContextHandler support. You use this interface to manage audit providers that support context handler entries in a standard way.
An Auditor provider MBean can optionally implement the ContextHandlerMBean MBean. The Auditor provider can then use the MBean to determine the supported and
active ContextHandler entries.
The WebLogic Server Administration Console detects when an Auditor provider implements this MBean and automatically provides a tab for using these attributes.
10.3.1 ContextHandlerMBean Methods
The ContextHandlerMBean interface implements the following methods:
■
getActiveContextHandlerEntries public String[] getActiveContextHandlerEntries
Returns the ContextHandler entries that the Audit provider is currently configured to process.
■
getSupportedContextHandlerEntries public String[] getSupportedContextHandlerEntries
Returns the list of all ContextHandler entries supported by the auditor.
■
setActiveContextHandlerEntries public void setActiveContextHandlerEntriesString[] types throws
InvalidAttributeValueException Sets the ContextHandler entries that the Audit provider will process. The entries
you specify must be listed in the Audit providers SupportedContextHandlerEntries attribute.
Note: The ContextHandler entries associated with the
ContextHandlerMBean are not related to, nor do they affect, the contents of an AuditEvent that is passed to the Audit providers. An
AuditEvent received by a provider may or may not include a ContextHandler with ContextElements. If a ContextHandler is
included, an Audit provider can get the ContextHandler from the AuditEvent, regardless of whether you implemented the
ContextHandlerMBean management interface. In particular, the AuditContext getContext method returns a
weblogic.security.service.ContextHandler interface that is independent of the context handler implemented by the
ContextHandlerMBean.
You can choose to implement the ContextHandlerMBean context handler in a manner that compliments the AuditContext getContext
method. The SimpleSampleAuditProviderImpl.java sample takes this approach. However, there is no requirement that you do so.
Auditing Providers 10-5
10.3.2 Example: Implementing the ContextHandlerMBean
Example 10–5 shows the SimpleSampleAuditProviderImpl.java class, which is
the runtime class for the sample Auditing provider. This sample Auditing provider has been enhanced to implement the ContextHandlerMBean.
An MBean Definition File MDF is an XML file used by the WebLogic MBeanMaker utility to generate the Java files that comprise an MBean type. All MDFs must extend a
required SSPI MBean that is specific to the type of the security provider you have created, and can implement optional SSPI MBeans.
Example 10–1 shows the key sections of the MDF for the sample Auditing provider,
which implements the optional ContexthandlerMBean.
Example 10–1 Example: SimpleSampleAuditor.xml
MBeanType Name = SimpleSampleAuditor
DisplayName = SimpleSampleAuditor Package = examples.security.providers.audit.simple
Extends = weblogic.management.security.audit.Auditor Implements = weblogic.management.security.audit.ContextHandler
PersistPolicy = OnUpdate ...
MBeanAttribute Name = SupportedContextHandlerEntries
Type = java.lang.String[] Writeable = false
Default = new String[] { quot;com.bea.contextelement.servlet.HttpServletRequestquot; }
Description = List of all ContextHandler entries supported by the auditor.
10.3.3 Extend weblogic.management.security.audit.ContextHandlerImpl