OIM API to Decryption Password


  1. package com.oimacademy.password;
  2. import Thor.API.Security.XLClientSecurityAssociation;
  3. import com.oimacademy.connection.OIMConnection;
  4. import com.thortech.xl.dataaccess.tcDataBaseClient;
  5. import com.thortech.xl.dataaccess.tcDataProvider;
  6. import com.thortech.xl.dataaccess.tcDataSet;
  7. import com.thortech.xl.dataaccess.tcDataSetException;
  8. import java.util.Hashtable;
  9. import java.util.logging.Level;
  10. import java.util.logging.Logger;
  11. /**
  12.  * This class gets the OIM Client and uses that to establish a
  13.  * connection to the OIM Schema. You can query the USR table and
  14.  * get the password in plain text. 
  15.  * NOTE: The administrator credential must be used for the OIM Client. 
  16.  */
  17. public class DecryptedOIMPassword 
  18. {
  19.     public static void main(String[] args)
  20.     {
  21.         tcDataProvider dbProvider = null;
  22.         try
  23.         { 
  24.             XLClientSecurityAssociation.setClientHandle(OIMConnection.getConnection());//Needed for database client
  25.             dbProvider = new tcDataBaseClient(); //Connection to OIM Schema
  26.             tcDataSet dataSet = new tcDataSet(); //Stores the result set of an executed query
  27.             String query = "SELECT * FROM USR"; //Query Users table
  28.             //String query = "SELECT * FROM PCQ"; //Query Users Challenge Question
  29.             dataSet.setQuery(dbProvider, query); //Set query and database provider
  30.             dataSet.executeQuery(); //execute query and store results into dataSet object
  31.             int records = dataSet.getTotalRowCount(); //Get total records from result set 
  32.             for(int i = 0; i < records; i++)
  33.             {
  34.                 dataSet.goToRow(i); //move pointer to next record
  35.                 String plainTextPassword = dataSet.getString("USR_PASSWORD");
  36.                 String userLogin = dataSet.getString("USR_LOGIN");
  37.                 String userStatus = dataSet.getString("USR_STATUS");
  38.                 System.out.printf("User Login: %s\nStatus: %s\nPassword: %s\n\n", userLogin, userStatus, plainTextPassword);   
  39.                 //Getting user challenge questions and answers
  40.                 //String usrKey = dataSet.getString("USR_KEY");
  41.                 //String question = dataSet.getString("PCQ_QUESTION");
  42.                 //String answer = dataSet.getString("PCQ_ANSWER");
  43.                 //System.out.printf("USR_KEY: %s\nQuestion: %s\nAnswer: %s\n", usrKey, question, answer);
  44.             }
  45.         }  
  46.         catch (tcDataSetException ex) 
  47.         { 
  48.       Logger.getLogger(DecryptedOIMPassword.class.getName()).log(Level.SEVERE, null, ex);
  49.         }
  50.         finally
  51.         {
  52.             //close connections
  53.             try{dbProvider.close();} catch(Exception e){}
  54.             try{XLClientSecurityAssociation.clearThreadLoginSession();} catch(Exception e){}
  55.            
  56.         }     
  57.     }//end main method   
  58. }//end class

1 comment:

  1. Hi,
    nice blog good for learning and resolving encryption type of issue, can you please list down jar files need to be added in project?

    Thanks,

    ReplyDelete