I am trying to store password in an Oracle Wallet file which I will retrieve from the code and use.
I tried to create a wallet and save a credential there:-
$ mkstore -wrl <wallet_location> -createCredential sid scott tiger
Oracle Secret Store Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
Enter wallet password:
Create credential oracle.security.client.connect_string1
The creation does not give any error but when I try to list the credential, I don’t get anything.
$ mkstore -wrl -listCredential
Oracle Secret Store Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved
Also, how to retrieve this password using java?
For connecting the Oracle DB using wallet requires the following changes.
you need to create a wallet store, you need to also choose a password for the wallet and you need to use this password while modifying the wallet
e.g. C:\Oracle_11.2.0\product\client_1\bin\mkstore -wrl C:\Users\sample\app\wallet
you need to add the tns entries in tnsnames.ora (OracleClientHome/network/admin/tnsnames.ora) and same tns entry name will be used us wallet connect string
e.g. C:\Oracle_11.2.0\product\client_1\network\admin\tnsnames.ora
you need to create wallet entry for the above tns entry with credentials, you also need to provide the wallet password which you have given while creating the wallet.
e.g. C:\Oracle_11.2.0\product\client_1\bin\mkstore -wrl C:\Users\sample\app\wallet -createCredential SAMPLEDB_RO sample sample
you need to add the sqlnet.ora file to update the wallet location and wallet override flag to true
e.g.
test the db connection using wallet and oracle client to make sure the wallet configurations are correct
OracleClientHome/bin/sqlplus /nolog
connect DB_Username/DB_Password@TNS_Entry_Name
e.g.
you need to make the java application ready to use the wallet and run the java program with the below JVM Parameters
OracleClientHome/jlib/osdt_core.jar
e.g.
C:\Oracle_11.2.0\product\client_1\jlib\osdt_core.jar
Change application configuration thin url to use the wallet
jdbc:oracle:thin:/@TNS_Entry_Name/Wallet_Entry_name
e.g.
jdbc:oracle:thin:/@SAMPLEDB_RO
Also add the following properties as JVM Parameters, this help the library to find the oracle wallet
-Doracle.net.tns_admin=OracleClientHome/network/admin -Doracle.net.wallet_location=Where you want to store your wallet
e.g. -Doracle.net.tns_admin=C:\Oracle_11.2.0\product\client_1\network\admin -Doracle.net.wallet_location=C:\Users\sample\app\wallet
You are all set!!
OracleClientHome/bin/mkstore -wrl Where you want to store your wallet -listCredential
e.g. C:\Oracle_11.2.0\product\client_1\bin\mkstore -wrl C:\Users\sample\app\wallet -listCredential
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With