I am looking for advice on the best way to supply an Oracle password at
run-time. When our application connects to Oracle it uses a password that is
provided from a password store. The password itself is updated every 60
days.

My current WEB-INF/resources.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
  <Resource id="ID" type="javax.sql.DataSource">
      JdbcDriver = oracle.jdbc.OracleDriver
      JdbcUrl = jdbc:oracle:thin:@HOST:PORT:DBNAME
      JtaManaged = true
      UserName = TheUserId
      Password = PlainTextPassword
  </Resource>
</resources>


My test.jsp test harness within my .war file looks like this:

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql"; prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>

<sql:query var="rs" dataSource="ID">
select col1, col2 from schema.table where id > 3081915
</sql:query>

<html>
  <head>
    <title>DB Test</title>
  </head>
  <body>

<c:forEach var="row" items="${rs.rows}">
    row.col1=${row.col1}<br/>
    row.col2=${row.col2}<br/>
</c:forEach>

  </body>
</html>

This all works. What I now need to do is supply the value of
PlainTextPassword dynamically at run-time. I have added code to test.jsp
that demonstrates my ability to retrieve the password from our custom
password store. Alas, I am unsure how to apply it to the dataSource.

Reading through the TomEE documentation suggests I need to understand how to
use JNDI to access the dataSource resource. Then I should be able to
dynamically provide the password. I will begin to push in that direction.

Thanks in advance to any who respond. If my research lands on a solution I
will drop by and document what I find.

Version info (from catalina.out):

Server version: Apache Tomcat (TomEE)/9.0.12 (8.0.0-M2)
Server built:   Sep 4 2018 22:13:41 UTC
Server number:  9.0.12.0
OS Name:        Linux
OS Version:     3.10.0-1062.1.2.el7.x86_64
Architecture:   amd64
Java Home:      /path-on-host/jdk-11.0.2
JVM Version:    11.0.2+7

Kind regards,
-Randy Galbraith




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html

Reply via email to