Steps to use userconfig file and userkey file

First create the user config file and the key file with the following method (Alternatively Weblogic Admin utility can be used to create the user config files).

storeUserConfig(‘C:/bea922/user_projects/domains/config-file’,'C:/bea922/user_projects/domains/keyfile’)

You can connect to the nodemanger using the userKeyFile and userConfigFile :
nmConnect(userConfigFile=’C:/bea922/user_projects/domains/config-file’,userKeyFile=’C:/bea922/user_projects/domains/keyfile’, host=’10.10.71.79′, port=’5556′, domainName=’SAML_SOURCE’, domainDir=’C:/bea922/user_projects/domains/SAML_SOURCE’, nmType=’plain’)

Similarly you can connect to the server:
connect(userConfigFile=’C:/bea922/user_projects/domains/config-file’,userKeyFile=’C:/bea922/user_projects/domains/keyfile’,url=’t3://10.10.71.79:7001′)
Note: I have tested in WLS 9.2.

The username and password stored in the config files can be read from the JAVA code in the following way.

import weblogic.security.UserConfigFileManager;
import weblogic.security.UsernameAndPassword;

UsernameAndPassword usernameAndPassword=UserConfigFileManager.getUsernameAndPassword(“C:/bea922/user_projects/domains/config-file”,”C:/bea922/user_projects/domains/keyfile”,”weblogic.management”);

String username=new String(usernameAndPassword.getUsername());
String password=new String(usernameAndPassword.getPassword());

Leave a Reply

Post Navigation