Showing posts with label password. Show all posts
Showing posts with label password. Show all posts

Monday, December 17, 2012

How To Encrypt Clear Text Passwords With WebLogic Server

WebLogic Server encrypts all the plain text passwords stored in its domain configuration XML file(s). This is to prevent access to sensitive information. When passwords are entered using administration console or scripting tools, it will automatically get encrypted before they are stored in the configuration XML files(s).

Prior to WebLogic Server 9.0

If those passwords need to be reset either the configuration tools (Console or scripting tools) can be used which will automatically re-encrypt the passwords or by directly changing the configuration files using a text editor. When files are directly modified using a text editor the passwords will get encrypted during the subsequent restart.

Starting from WebLogic Server 9.0

Using clear text passwords in the configuration files are supported only for Development domain and it will not re-encrypt the passwords. If the domain is a Production domain then you cannot set the passwords in clear text. You have to either use a dedicated command-line utility or WLST to encrypt the clear text passwords. If the server encounters a clear text password when parsing the configuration file(s) while starting in Production Mode, then you will get an error similar to the following:

<Oct 20, 2008 9:05:35 PM EDT> <Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason: [Management:141266]Parsing Failure in config.xml: java.lang.IllegalArgumentException: In production mode, it's not allowed to set a clear text value to the property: PasswordEncrypted of ServerStartMBean>


Depending on the configuration the MBean name value of the error message may change. In this case the ServerStartMBean has clear text value for a password property. Either the dedicated Java utility to encrypt clear text values can be used or WLST cant be used to re-encrypt. To run the encrypt utility follow the instructions below:


  1. Change directory to your domain's bin folder (For Eg. cd c:\bea\user_projects\domains\mydomain\bin)
  2. Execute the setDomainEnv script (For Eg. setDomainEnv.cmd)
  3. Execute java weblogic.security.Encrypt which will prompt for the password and will print the encrypted value in stdout.
The following are some sample output from running the utility

C:\bea\user_projects\domains\mydomain>java weblogic.security.Encrypt
Password:
{3DES}9HWsf87pJTw=

You should execute this utility from the domain folder as it requires the domain's password salt file (SerializedSystemIni.dat) for encrypting the clear text string. You can also pass the clear text string as an argument

C:\bea\user_projects\domains\mydomain>java weblogic.security.Encrypt testpwd
{3DES}9HWsf87pJTw=


You can also use WLST to encrypt clear text strings as below:

C:\bea\user_projects\domains\mydomain>java weblogic.WLST

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline> es = encrypt('testpwd')
wls:/offline> print es
{3DES}9HWsf87pJTw=
wls:/offline>

When running WLST from a location different than the domain folder you can pass in an argument to specify the domain directory. Once you have the encrypted value, the configuration files can be modified to include this encrypte value instead of clear text passwords. These features will make your domain to operate when resetting the encrypted passwords on a Production domain's configuration XML files. These methods not only can be used to encrypt configuration XML (config.xml) but also the JDBC or JMS descriptor XML files.

Steps to reset console password in WLS 9x and above :


In previous post only we reset the password in WLS8X
In the example below we are creating a new user name and password in WLS 10.3x :
.
Below are the steps for password recovery  :
STEP 1 :  Firstly, Stop the server if running and make sure that weblogic.jar is in the classpath.
STEP 2 : Open a command prompt and navigate to your Domain directory’s bin folder and run “setDomainEnv.cmd “
STEP 3 : Now run the following command :
“Java weblogic.security.utils.AdminAccount NewAdminUser NewAdminPassword . “
where ” NewAdminUser ” and ” NewAdminPassword ” are the new user and password you would like to create.
Note : The “ . “ (period) at the end of the command is very important..!! as it tells the command that this should be run in the domain directory.
STEP 4 : The above command creates a file “ DefaultAuthenticatorInit.ldift “ in the domain directory. ( as shown below )
.
STEP 5 :  Now copy the newly created “DefaultAuthenticatorInit.ldift “ to “C:\bea10.3\user_projects\domains\change_password\security “
Note : You can take a backup or delete  “DefaultAuthenticatorInit.ldift “ which is already present in the security folder
STEP 6 :  Now edit the boot.properties file ( located in “ C:\bea10.3\user_projects\domains\change_password\servers\AdminServer\security  “ ) with the new user name and password that we created ( i.e NewAdminUser  and NewAdminPassword ) ( as shown below )
.
STEP 7 : Delete the file “ DefaultAuthenticatormyrealmInit.initialized “ located in “C:\bea10.3\user_projects\domains\change_password\servers\AdminServer\data\ldap “
STEP 8 : Now start the server and login with the new user and password. 

Steps to reset console password on WLS 8x :


In the example below we are creating a new console user and password in WLS 8x :
Below are the steps for password recovery  :
STEP 1 :  Firstly, Stop the server if running and make sure that weblogic.jar is in the classpath.
STEP 2 : Open a command prompt and navigate to ” D:\bea816\user_projects\domains\mydomain “  and run “setEnv.cmd “
STEP 3 : Now run the following command :
“Java weblogic.security.utils.AdminAccount NewAdminUser NewAdminPassword . “
where ” NewAdminUser ” and ” NewAdminPassword ” are the new user and password you would like to create.
Note : The “ . “ (period) at the end of the command is very important..!! as it tells the command that this should be run in the domain directory.
STEP 4 : The above command creates a file “ DefaultAuthenticatorInit.ldift “ in the domain directory. ( as shown below )
.

STEP 5 : Delete the file “ DefaultAuthenticatormyrealmInit.initialized “ located in D:\bea816\user_projects\domains\mydomain\myserver\ldap “
STEP 6 : Clear the contents of boot.properties file located in ” D:\bea816\user_projects\domains\mydomain “
STEP 7 : Now start the server and login with the new user and password. 

CURL Commands


Password secure:

curl –data-binary @<Filename> -k -u adminhttps://hostname:5550Admin Password

Non password secure:curl –data-binary @request.xml https://hostname:5550 -u admin:{adminPW} -k

To check weather server is up or not:curl -f http://<hostname&gt;:7400/monitor