aspose file tools
The moose likes JDBC and Relational Databases and the fly likes Retrieve DB2 credentials configured on websphere Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Retrieve DB2 credentials configured on websphere" Watch "Retrieve DB2 credentials configured on websphere" New topic
Author

Retrieve DB2 credentials configured on websphere

Natraj Muthu
Greenhorn

Joined: Jul 07, 2011
Posts: 2
Hi,

i have a java batch client ( Application client) that reads the DB2 user Id and Password from the property file and establishes the connection to perform database operations.
I have been requested not to put the user id and password explicitly on the property file for security purpose. So, i have to find a way to retrieve the credentials from the websphere. I tried the follwoing 2 options

1. Trying to read the jaasAliasName and get teh user id and Password, But we got an exception while running it . This is not helping me. Looks like the jaasAlias name is not visible to the application client.

com.ibm.ws.security.core.SecurityConfig securityConfig = com.ibm.ws.security.core.SecurityConfig.getConfig();
Properties authProperties = securityConfig.getAuthData("jaasAliasName");
String id= authProperties.getProperty("username");
String pwd= authProperties.getProperty("password")

2. Tried adding the credential details under datasource custom properties in admin console. Not sure how to retrieve this from application client.

Can someone suggest me a best way to read it though application client?
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19659
    
  10

No, that's not what you want to do. Configure the credentials in Websphere, yes. Retrieve the credentials in your application, no. Instead, configure a data source in Websphere, have it use those credentials, and then use the data source in your application.
Natraj Muthu
Greenhorn

Joined: Jul 07, 2011
Posts: 2
Paul,
My batch program uses hiberante to for DB2. It needs the user id and password to make a connectivity at runtime( when run though a launch client approach). Right now my program reads the user id and password from the property file and dose the connection.

// Reading from the property file
String userName = SPMUWPropertyProvider.getProperty("sp.muw.sics.hibernate.connection.username");
String password = SPMUWPropertyProvider.getProperty("sp.muw.sics.hibernate.connection.password");

// Setting user id and pass to the hibernate config
cfg.setProperty("hibernate.connection.username",userName);
cfg.setProperty("hibernate.connection.password",password);

sessionFactory = cfg.buildSessionFactory();

In websphere, under datasource ( Resources--> jdbc provide --> datasource), i have created a data source and provide a jndi name. I was thinking, if there is a way to retrive the user id and password from the datasource configured on the websphere so that i can pass it to the above block of code.

Is it possible?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieve DB2 credentials configured on websphere
 
It's not a secret anymore!