- Notifications
You must be signed in to change notification settings - Fork 856
Iam auth #184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Iam auth #184
Changes from 1 commit
Commits
Show all changes
9 commits Select commit Hold shift + click to select a range
19c34f2
Add files via upload
nsundara 7440e19
Update JDBCDBTokenSample.java
nsundara b9945af
Add files via upload
nsundara dc25b2c
Update UCPDBTokenSample.java
nsundara 24e9f34
Update UCPDBTokenSample.java
nsundara be6367e
Update JDBCDBTokenSample.java
nsundara 82c595f
Update UCPDBTokenSample.java
nsundara 6c4e763
Update UCPDBTokenSample.java
nsundara 8858d91
Update JDBCDBTokenSample.java
nsundara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update JDBCDBTokenSample.java
- Loading branch information
commit be6367e92a563da27095817df6ef21dcc3663e96
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
| @@ -3,19 +3,16 @@ | |
/* | ||
DESCRIPTION | ||
The code sample shows how to use the JDBC driver to establish a connection | ||
to the Autonomous Database (ADB) using database token | ||
to the Autonomous Database (ADB) using access token | ||
issued by the OCI Identity service. | ||
| ||
You need to use either JDBC driver to use | ||
database token authenticatio. | ||
| ||
Step 1: Enter the DB_URL to pointing to your Autonomous Database (ADB) | ||
Step 2: Make sure to have either 21.4.0.0.1 or 19.13.0.0.1 JDBC driver | ||
in the classpath. | ||
Step 2: Compile and Run the sample JDBCDBTokenSample | ||
Step 1: Enter the DB_URL to pointing to your Autonomous Database (ADB) | ||
Step 2: Make sure to have either 21.4.0.0.1 or 19.13.0.0.1 JDBC driver | ||
in the classpath. | ||
Step 3: Compile and run the sample JDBCDBTokenSample | ||
| ||
NOTES | ||
Use JDK 1.7 and above | ||
Use JDK8 and above | ||
MODIFIED (MM/DD/YY) | ||
nbsundar 1/7/21 - Creation | ||
*/ | ||
| @@ -38,26 +35,25 @@ public class JDBCDBTokenSample { | |
// Download the wallet zip file and provide the path to the zip file as TNS_ADMIN | ||
// Note that you need to pass the property oracle.jdbc.tokenAuthentication=OCI_TOKEN for token authentication | ||
final static String DB_URL="jdbc:oracle:thin:@dbname_high?TNS_ADMIN=/Users/user/wallet/Wallet_dbname&oracle.jdbc.tokenAuthentication=OCI_TOKEN"; | ||
// If mutla TLS(mTLS) is disabled then, ADB connection does not require wallets. | ||
// If mutual TLS(mTLS) is disabled then, ADB connection does not require wallets. | ||
// Copy the connection string from "DB Connection" tab from "Connection Strings" section choosing "TLS" in the dropdown | ||
//final static String DB_URL="jdbc:oracle:thin:@(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=gebqqeredfsozhjbqbs_dbname_medium.adb.oraclecloud.com)))?oracle.jdbc.tokenAuthentication=OCI_TOKEN"; | ||
// Another way to enable token authentication in the long form connection string. | ||
final static String DB_URL="jdbc:oracle:thin:@(description=" | ||
+ "(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=adb.us-phoenix-1.oraclecloud.com))" | ||
+ "(security=(token_auth=OCI_TOKEN))" | ||
+ "(connect_data=(service_name=gebqqeredfsozhjbqbs_dbname_medium.adb.oraclecloud.com)))?oracle.jdbc.tokenAuthentication=OCI_TOKEN"; | ||
| ||
| ||
| ||
public static void main(String args[]) throws SQLException { | ||
| ||
// For more connection related properties. Refer to | ||
// the OracleConnection interface. | ||
Properties properties = new Properties(); | ||
| ||
properties.put(OracleConnection.CONNECTION_PROPERTY_DEFAULT_ROW_PREFETCH, "20"); | ||
properties.put(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CHECKSUM_TYPES, | ||
"(MD5,SHA1,SHA256,SHA384,SHA512)"); | ||
properties.put(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CHECKSUM_LEVEL, | ||
"REQUIRED"); | ||
// Connection property to enable database token authentication. | ||
| ||
//Connection property to enable IAM token authentication. | ||
// properties.put(OracleConnection.CONNECTION_PROPERTY_TOKEN_AUTHENTICATION, "OCI_TOKEN"); | ||
| ||
| ||
| ||
OracleDataSource ods = new OracleDataSource(); | ||
ods.setURL(DB_URL); | ||
ods.setConnectionProperties(properties); | ||
|
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this example URL, it is using a TNS descriptor format. The descriptor format supports a "TOKEN_AUTH" parameter that has the same effect as the "oracle.jdbc.tokenAuthentication" property.
It would be nice to show this TOKEN_AUTH parameter in the example, rather than the oracle.jdbc.tokenAuthentication property.
Note that I've added in line breaks as well, these will improve the readability of the long form descriptor string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good to know, but, I prefer not to use this as customers need to add in the middle of the connection string. It is easy to use EZConnect and pass this additional parameter. We can add it as a comment to show the possibility though.