While connecting to Weblogic Scripting Tool (WLST) or while running any WLST scripts, we might have used the clear text username and password which could lead us to any potential security threat.
In order to avoid it, Oracle recommends us to use the UserConfigFile and UserKeyFile where ever applicable.
Best example where you can use this keyfile and configfile is while using connect() method to go WLST online
Therefore, Rather using the connect with clear text password like below
you can use
to connect to WLST and in scripts also you can use this connect method, in order to securely connect to AdminServer
How to Create these files in an Easy way
So how to create these files?. There is a built-in method in weblogic named storeUserConfig() you can run in WLST interactive mode (or) scripting mode, in order achieve the same.
As you could see in the preceding command snippet, you could just get the
user config and
user key file created into your home directory by just invoking the
You can mention the path and the file name of the user config and user key files, Like shown below
The Customized WLST Script Way
I have written some script to make your job ease and getting this job done.
There are two flavours of the script, I have written.
- The First one is using
getoptswhere you have to give the details as startup arguments. ( If you are using this script. There are chances, people can get access to your password from the bash history. If you feel that's not a problem you can use this)
- The Second one is using the
properties file,where the script will obtain the username, password and other information from the properties file.
The Default Flag
The script is using a terminology called, Default flag if the default mode/flag is ON . the userConfigFile and userKeyFile will be saved in the default location, which is the home directory of the current user
you can set the default flag to ON using --default startup argument for the first script
you can set the default flag to ON by mentioning defaultflag=ON in the store.properties file
I have given both versions of the scripts below and you can choose any, as per your requirement.
The First one has a good help/usage information, you can get it by passing "help" as a startup argument like shown below.
java weblogic.WLST storeuserconfig.py help
The First One ( Using Startup arguments)
With Default Flag
The Second One ( Using Properties file)
With Default Flag ON
With Default Flag OFF
The Properties File ( For the Second One)
Note*: You must place the properties file in the same directory where you save second python script and the properties file name must be store.properties
Hope this helps.
If you are a Beginner to WLST and weblogic, this scripts could help you learn some new things. There are other articles like this in our site you can refer to.
Weblogic Domain Creation using WLST : http://www.mwinventory.in/blog/weblogic-domain-creation-script-wlst/
Weblogic Server Status using WLST : http://www.mwinventory.in/blog/weblogic-server-status-script-wlst/
There are more such articles here and more scripts still under development and will be published soon. Stay connected
A K S A R A V
Write to us at : [email protected]
Follow us on Facebook
To Join our Community in Whatsapp – Click here