Monday, August 22, 2016

JBOSS Security Password Generator

Ever struggling to generate Encrypted password using JBOSS Security Login Module ??
Here is how you can do it, go to JBOSS_INSTALLATION directory.

Run below command in Unix (some jars are required, locate that and give proper path in below command):
dmodi__Jboss$ java -cp ./DEPLOY_NAME/lib/jboss-common.jar:./DEPLOY_NAME/lib/jboss-jca.jar:./DEPLOY_NAME/lib/jbosssx.jar org.jboss.resource.security.SecureIdentityLoginModule PASSWORD
Encoded password: 5f78dc15b9a559cbdf8592078de921bc


//That's it. You are done with. But do you see any problem here, yes people KNOW what is PASSWORD, when you set this in PRODUCTION environment, where many people were present.
To hide that, you need to write a Shell Script, assume file name is "HidePassword.sh"

vi HidePassword.sh
echo "Enter Password to Encrypt for followed by Enter:"
stty -echo
read pass
stty echo
java -cp ./DEPLOY_NAME/lib/jboss-common.jar:./DEPLOY_NAME/lib/jboss-jca.jar:./DEPLOY_NAME/lib/jbosssx.jar  org.jboss.resource.security.SecureIdentityLoginModule $pass
echo 'Done'

//EXIT now=>   :wq

Run Now:

dmodi__Jboss$    sh HidePassword.sh
Enter Password to Encrypt for followed by Enter:   ( I entered same PASSWORD, but it will not be visible in console)
Encoded password: 5f78dc15b9a559cbdf8592078de921bc
Done


//Now this password you need to put into Databse security Domain files. That you can see in many links. 
For reference:    https://docs.jboss.org/jbosssecurity/docs/6.0/security_guide/html/Encrypting_Data_Source_Passwords.html
=======================END============================


Thursday, August 4, 2016

Search a string in a file or recursively in a directory in windows. For Unix, shell scripting is awesome but windows
we always curse Microsoft. But we too have command prompt too.

Below program will search a string in a directory (all files recursively). Copy the code in a file called "LogSearch.bat".
And run as below, this will give all the file names where WARNING_MESSAGE is present.

LogSearch.bat WARNING_MESSAGE D:\server_logs\

-------------------------------------------------------------
@echo off
echo 'Enter_String_To_Search Directory_Name_To_Search'
set arg1=%1
set arg2=%2
setlocal
pushd %arg2%
findstr /s /m %arg1% *
popd
endlocal
-------------------------------------------------------------