Store the Oracle Credentials in a Wallet
Last modified by Eleni Cojocariu on 2026/11/25 14:49
Content
Steps
Store the database credentials in an Oracle Wallet for the JDBC driver to read, instead of the clear-text password WEB-INF/hibernate.cfg.xml carries, starting from a wiki configured on Oracle.
- Create a wallet on the machine running Oracle.
mkstore -wrl /opt/oracle/wallet -create - Add the XWiki database credentials to the wallet, keyed by the connect string XWiki uses.
mkstore -wrl /opt/oracle/wallet -createCredential localhost:1521/xwiki xwiki <password> - Copy the wallet's cwallet.sso and ewallet.p12 files to the machine running XWiki, into a directory that only the servlet container's user can read.
- Download the full Oracle JDBC package and copy its oraclepki.jar file into the XWiki web application's WEB-INF/lib directory, next to the Oracle JDBC driver.
- Replace the connection URL in the "Oracle configuration" section of WEB-INF/hibernate.cfg.xml with a wallet one, which carries a / before the @ and names no user.
<property name="hibernate.connection.url">jdbc:oracle:thin:/@localhost:1521/xwiki</property> - Empty the hibernate.connection.username and hibernate.connection.password properties of the same section, or remove them.
- Add the wallet directory to the Java options of the servlet container that runs XWiki.
-Doracle.net.wallet_location=/opt/xwiki/wallet - Restart XWiki and open your wiki in a browser. It serves pages as before, and WEB-INF/hibernate.cfg.xml no longer carries the database password.
FAQ
Do I still need osdt_core.jar and osdt_cert.jar?
No. Oracle publishes no osdt JAR past the 21c drivers, and its JDBC guide asks only for oraclepki.jar on the classpath.
Where do I set the system property?
Wherever the servlet container takes its Java options, such as JAVA_OPTS in Tomcat's setenv.sh file. See Configure a Servlet Container.
Can one wallet serve several XWiki instances?
Yes, as long as it holds a credential for each connect string in use. The driver looks the credential up by the connect string of the connection URL.