weblogic java code to get weblogic credentials

Submitted by code_admin on Mon, 07/23/2018 - 09:34

weblogic username
weblogic1
getWeblogicPassword()[0] = username = weblogic
getWeblogicPassword()[1] = password = weblogic1

  1.     private static String[] getWeblogicPassword() throws Exception {
  2.         String PREFIX = "{AES}";
  3.         String ret[] = new String[2];
  4.         String dname = System.getenv("DOMAIN_HOME");
  5.         if (dname==null) throw new Exception("Enviroment variable DOMAIN_HOME not set");
  6.         String fname = dname + "/../../aserver/soa_domain/servers/AdminServer/security/boot.properties";
  7.         ClearOrEncryptedService ClrOrEncSvc = new ClearOrEncryptedService(SerializedSystemIni.getEncryptionService(new File(dname).getAbsolutePath()));
  8.         Properties properties = new Properties();
  9.         properties.load(new FileInputStream(fname));
  10.         for (Map.Entry p : properties.entrySet()) {
  11.            if (p.getValue().toString().startsWith(PREFIX)) {
  12.               //System.out.println("key: \"" + ClrOrEncSvc.decrypt((String)p.getKey()) + "\"");
  13.               if (ClrOrEncSvc.decrypt((String)p.getKey()).equals("username")) {
  14.                    //System.out.println("UserName: " + ClrOrEncSvc.decrypt((String)p.getValue()));
  15.                    ret[0] = ClrOrEncSvc.decrypt((String)p.getValue());
  16.               }
  17.               else {
  18.                    // System.out.println("UserPass: " + ClrOrEncSvc.decrypt((String)p.getValue()));
  19.                    ret[1] = ClrOrEncSvc.decrypt((String)p.getValue());
  20.               }
  21.             }
  22.          }
  23.        
  24.         return ret;
  25.     }
RJM Article Type
Quick Reference