We can use the ‘storeUserConfig’ command to create a user configuration file that contains your credentials in an encrypted form and a key file that Weblogic Server uses to unencrypted credentials.
And on subsequent WLST sessions (or in WLST scripts), supply the name of the user configuration file and key file instead of entering the credentials on the command line. This option is recommended if you use WLST in script mode because it prevents you from storing unencrypted user credentials in your scripts.
## This script creates a user config file
wls:/offline> connect('weblogic','weblogic',url='10.10.71.94:7001')
wls:/Distributed_Domain/serverConfig> storeUserConfig('d:/DeeptiPY/Unni-WebLogicConfig.properties', 'd:/DeeptiPY/Unni-WebLogicKey.properties')
## This will create two files 'Unni-WebLogicConfig.properties' and 'Unni-WebLogicKey.properties'
## WebLogicConfig has the encrypted username and password, WebLogicKey has the logic to decrypt them
## End the current WLST session
wls:/Distributed_Domain/serverConfig> exit()
-
## Sample Script to monitor state of the server:
## This demonstrates how we can connect to a server without using clear text credentials
wls:/offline> connect(userConfigFile='d:/DeeptiPY/Unni-WebLogicConfig.properties',userKeyFile='d:/DeeptiPY/Unni-WebLogicKey.properties',url='t3://10.10.71.94:7001')
wls:/Distributed_Domain/serverConfig> state('MSLocal')
Current state of 'MSLocal' : RUNNING
Cheers:)
Unni