Read AUD_JMS data : ReadDataFromAUD_JMSTable

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.massiveGaze.auditMessage;
/*
 * 
 classpath:
   xlAPI.jar
   xlAuditor.jar
   JDBC driver
   iam-platform-utils.jar
   xlLogger.jar
   xlVO.jar
   xlCrypto.jar
 * 
 * 
 */
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Iterator;
import java.util.List;

import com.massiveGaze.connection.DataSource;
import com.thortech.xl.audit.engine.AuditDelta;
import com.thortech.xl.audit.engine.AuditDelta.Attribute;
import com.thortech.xl.audit.engine.AuditDelta.ForeignAttribute;
import com.thortech.xl.audit.engine.AuditDelta.XMLNodeTag;
import com.thortech.xl.audit.engine.AuditMessage;

public class ReadDataFromAUD_JMSTable {
 public static void main(String[] args) throws Exception {

  long audJmsKey = 6002; 
  Connection con = DataSource.getConnection();

  Statement stmt = con.createStatement();
  String query = "select aud_jms_key, aud_class, identifier, delay, "
    + "failed, create_date, update_date, jms_value from aud_jms where aud_jms_key = "
    + audJmsKey;
  ResultSet rs = stmt.executeQuery(query);

  if (rs.next()) {
   // Blob b = rs.getBlob("jms_value");
   // byte[] byteArray = b.getBytes((long)1, (int)b.length());

   System.out.println("Dump of Audit Message having aud_jms_key: "
     + audJmsKey);
   System.out.println("Aud Class: " + rs.getString("aud_class"));
   System.out.println("Identifier: " + rs.getString("identifier"));
   System.out.println("Delay: " + rs.getShort("delay"));
   System.out.println("Failed: " + rs.getString("failed"));
   System.out.println("Create Date: " + rs.getDate("create_date"));
   System.out.println("Update Date: " + rs.getDate("update_date"));
   System.out.println("Contents of JMS Message:");

   ByteArrayInputStream bais = new ByteArrayInputStream(
     rs.getBytes("jms_value"));
   ObjectInputStream oip = new ObjectInputStream(bais);

   Object o = oip.readObject();

   AuditMessage msg = (AuditMessage) o;

   System.out.println("(Audit message) API: " + msg.getAPI());
   System.out.println("(Audit message) Auditor Name: "   + msg.getAuditorName());
   System.out.println("(Audit message) Method: "    + msg.getMethod());
   System.out.println("(Audit message) User Name: "  + msg.getUsername());
   System.out.println("(Audit message) Audit Epoch: "  + msg.getAuditEpoch());
   List lst = msg.getAuditDeltas();
   Iterator it = lst.listIterator();
   System.out.println();

   while (it.hasNext()) {
    AuditDelta delta = (AuditDelta) it.next();
    System.out.println("(Audit message Delta) XML Action: " + delta.getXMLAction());
    System.out.println("(Audit message Delta) Auditee ID: " + delta.getAuditeeID());
    System.out.println("(Audit message Delta) Change reason: " + delta.getChangeReason());
    System.out.println("(Audit message Delta) Change reason Key: "+ delta.getChangeReasonKey()); 
    System.out.println("");
    List lst1 = delta.getAttributes();
    Iterator it1 = lst1.listIterator();

    while (it1.hasNext()) {
     Attribute attr = (Attribute) it1.next();
     System.out.println("");
     System.out.println("(Audit message Attribute): " + attr.toString());      
       System.out.println("(Audit message Attribute) Name: " +     attr.getName());
       System.out.println("(Audit message Attribute) newvalue: "     + attr.getNewValue());
       System.out.println("(Audit message Attribute) oldvalue: "     + attr.getOldValue());
       System.out.println("(Audit message Attribute) encrypted: "    + attr.isEncrypted());
       System.out.println("(Audit message Attribute) password: "     + attr.isPassword());
       System.out.println("");
    }

    lst1 = delta.getForeignAttributes();
    it1 = lst1.listIterator();
    System.out.println();

    while (it1.hasNext()) {
     ForeignAttribute attr = (ForeignAttribute) it1.next();
     System.out.println("(Audit message ForeignAttribute): "       + attr.toString());     
       System.out.println("(Audit message ForeignAttribute) Name: "     + attr.getName());
       System.out.println("(Audit message ForeignAttribute) value: "     + attr.getValue()); 
       System.out.println( "(Audit message ForeignAttribute) track changes: "  + attr.isTrackChanges()); 
       System.out.println( "(Audit message ForeignAttribute) changes tracked implicitly: "    + attr.isChangesTrackedImplicitly());
      
    }

    lst1 = delta.getTargetXMLNodePath();
    it1 = lst1.listIterator();

    while (it1.hasNext()) {
     XMLNodeTag attr = (XMLNodeTag) it1.next();
     System.out.println("(Audit message XMLNodeTag): "
       + attr.toString());
    }
   }
  } else {
   System.out
     .println("There is no data in AUD_JMS for the given AUD_JMS_KEY "
       + audJmsKey);
  }

  stmt.close();
  rs.close();
  con.close();

  System.exit(0);

 }
}

No comments:

Post a Comment

About OIM

Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...

Popular Posts