Decryption of OIM Password in 11GR2PS3
The below code is used to decrypt the user password in OIM 11GR2PS3.
I tried to decrypt using standalone code in JDeveloper and came to know its not possible using standalone code.
So please create a scheduler to decrypt the password.
package com.ghr;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import oracle.iam.platform.Platform;
import oracle.iam.scheduler.vo.TaskSupport;
import tc.idm.common.utils.TSLogger;
import com.thortech.xl.crypto.*;
public class DecryptOIMUserPassword extends TaskSupport {
public static final String TS_SCHEDULER_LOGGER = "TC.SCHEDULER";
TSLogger logger = new TSLogger(TS_SCHEDULER_LOGGER);
private String className = this.getClass().getName();
public void execute(HashMap taskParams) throws Exception {
String methodName = "execute";
logger.setMethodStartLog(className, methodName);
String encryptedPassword = null;
String decryptedPassword = null;
String userTSID = (String)taskParams.get("UserTSID");
logger.info(className, methodName, "User ID: "+userTSID);
Connection connection = Platform.getOperationalDS().getConnection();
String sql = "select USR_PASSWORD from usr where usr_login = ?";
PreparedStatement stmt=connection.prepareStatement(sql);
stmt.setString(1, userTSID);
ResultSet rs = stmt.executeQuery();
if(rs.next()){
encryptedPassword = rs.getString("USR_PASSWORD");
}
logger.info(className, methodName, "Encrypted password: "+encryptedPassword);
if(encryptedPassword != null){
decryptedPassword = tcCryptoUtil.decrypt(encryptedPassword, "DBSecretKey");
}
logger.info(className, methodName, "Decrypted password: "+decryptedPassword);
logger.setMethodFinishLog(className, methodName);
}
public HashMap getAttributes() {
return new HashMap();
}
public void setAttributes() {
}
}
Comments
Post a Comment