How to Develop Weblogic Custom Audit Provider

Through this post I will be providing the steps to develop a sample custom Weblogic Audit Provider.

Following files are required for this sample tutorial:

SimpleSampleAuditProviderImpl : This is a sample runtime class implementing the AuditProvider and AuditChannel.

SimpleSampleAuditorImpl : This is a sample class that extends the ContextHandlerImpl class to get the supported ActiveContextHandlerEntries

SimpleSampleAuditor : This is a sample Audit configuration Mbean Configuration file used to instantiate the Custome Audit Provider Mbean Type.

We will be following the link give below:

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/dvspisec/aud.html

We will have to do the following things to create the Custom Audit Provider:

  1. So First we will create a runtime class using the appropriate SSPI’s:

Implement the AuditProvider SSPI:

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/javadocs/weblogic/security/spi/AuditProvider.html

weblogic.security.spi Interface AuditProvider.

Implement the AuditChannel SSPI:

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/javadocs/weblogic/security/spi/AuditChannel.html

weblogic.security.spi Interface AuditChannel.

 

Please use the source file provided as a sample with this post.

File Name: SimpleSampleAuditProviderImpl.java

 

  1. Then we will be creating a SimpleSampleAuditorImpl.java file which extends ContextHandlerImpl class.

It is needed to inherit the ContextHandlerMBean’s ActiveContextHandlerEntries  attribute validator that ensures that the ActiveContextHandlerEntries  attribute only contains values from the SupportedContextHandlerEntries attribute.

  1. Then we will be creating a SimpleSampleAuditor.xml file which specifies the Mbean Type that needs to be instantiated for this Custom Audit Provider.
  1. Then Using the Source files provided with this post we will generate the Mbean Type and the Mbean Jar file for the Audit Provider using the Weblogic MbeanMaker Utility.

Steps To Follow:

1: Download the Sample Source code provided with at the top of the Post.

2: Then create a directory  called Providers and within this directory create another dir called src and place all the provided files in this directory, i.e. :

SimpleSampleAuditProviderImpl.java
SimpleSampleAuditorImpl.java
SimpleSampleAuditor.xml

3: Also create the directories called providerjar and created_files within the Providers directory.

So with the directory structure will become like below:

C:/Providers
C:/Providers/src
C:/Providers/providersjar
C:/Providers/created_files

4: Now open a command prompt and set the environment by executing the setWLSEnv.cmd file on this command prompt:

C:/Providers/src> %WLS_HOME%/wlserver/server/bin/setWLSEnv.cmd ( For windows)
homeProviderssrc$ . ./%WLS_HOME%/wlserver/server/bin/setWLSEnv.sh (for Linux)

5: Then execute the following command on the same prompt:
java -Dfiles=C:/Providers/created_files -DMDF=C:/Providers/src/SimpleSampleAuditor.xml -DMJF=C:/Providers/providersjar/SimpleSampleAuditor.jar -DtargetNameSpace=http://xmlns.oracle.com/oracleas/schema/11/adf/sampleapp/weblogic/providers -DpreserveStubs=true -DcreateStubs=true weblogic.management.commo.WebLogicMBeanMaker

6: With the above command a jar file with name SimpleSampleAuditor.jar will be created in the directory: C:/Providers/providersjar.

7: Place this created Jar file in the %BEA_HOME%wlserver_10.3serverlibmbeantypes directory of WLS installation.

8: Start the Admin Server of your domain and access the Admin Server Console with the browser.
9: Go to : Security realm>>>> myrealm >>> Providers >>> Audit Provider .
Click new tab:
Enter name: MyTestAuditprovider.
Type:        SimpleSampleAuditor

Click save.

10: Restart the Admin Server.
11: Now you will be able to use the Custom Audit Provider with this Domain.

If you are facing any issues and errors while developing Custom Security provider then you can post the errors here.

Please follow and like us:

3 Comments

  1. Jayesh January 15, 2011
  2. Jon December 22, 2010
  3. validateActiveContextHandlerEntries error June 7, 2010

Please add your comments here