6 Replies Latest reply: Jul 18, 2013 9:11 PM by user8757340 RSS

    How to create a variable within <sql:setDataSource> for database password

    user8757340

      Hi there,

       

      I hope someone can enlighten me on this.

       

      I'm trying to create a jsp page which uses JSTL to access the database. Regulation in my company requires me to use encrypted database password.

       

      Below is the snippet of my codes. The error I receive is the password="${decryptedPassword}" never work. However, it could print out the password correctly using "System.out.println("Password is "+decryptedPassword);" How should I pass the variable "decryptedPassword" into the password??

       

      Thanks alot!

      Steve

       

      <%
              //System.setProperty("oracle.net.tns_admin", "C:/NEW PC BACKUP/oracle/product/10.2.0/client_1/NETWORK/ADMIN");
              System.setProperty("oracle.net.tns_admin", "/usr/local/oracle/10.2.0.3/network/admin");
              String decryptedPassword = "";

              //logger.info("PLANNER_REPORT_EDOW_PSWD_ENCRYPT_KEY=<"+ keyAlias+">");
              //logger.info("PLANNER_REPORT_EDOW_PSWD_KEY_STORE=<"+keyStoreFile+">");

              FileBasedKeyStore fStore = new FileBasedKeyStore("/usr/local/scripts/keystorefile/key.dat", null);
              if (fStore == null) System.out.println("KeyStore is null");
              Key key = (Key) fStore.getKey("citos");
              if (key == null) System.out.println("key is null");
              decryptedPassword = new String(CryptoUtil.decryptFromBase64("Oci/n5asIP6CDR01WwvXtw==", key));
              System.out.println("Password is "+decryptedPassword);
              %>

       

              <sql:setDataSource var="snapshot" driver="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@cngd" user="citosapp"  password="${decryptedPassword}"/>