Sunday, January 29, 2012

Adding Security Domain in JBOSS

if you need to use a specific authentication system, then you need to specify it in jboss as below



java:/jaas/jmx-console



here I have configured it to /jaas/jmx-console. that is the application policy defined for jmx console. It has been defined in server/default/conf/login-config.xml as below




props/jmx-console-users.properties
props/jmx-console-roles.properties

Writing Client

In jboss 5.1 I was able to login with following
// SecurityClient client = SecurityClientFactory.getSecurityClient();
// client.setSimple("admin", "admin");
// client.setSimple("chan", "abc");
// client.login();

But in jboss 6 that didn't work. But adding user name and password to jndi.properties as below, I was able to login to the system.

java.naming.security.principal=chan
java.naming.security.credentials=abc


Wednesday, January 18, 2012

Useufull Links

Java Regex : http://www.vogella.de/articles/JavaRegularExpressions/article.html LOG4j xml configuration http://www.daniel-hirscher.de/Java_files/Log4jQuickRef.pdf

Look for identity insert

Sunday, January 8, 2012

EJB Client Login

I found some difficulties in client login to access some ejb. I followed Mastering ejb 4th edition and tried to login but it didn't work and it consumed my number of days. But during that time I got some good knowledge on JAAS and Some Of ways to login is desribed here.

1) Using JndiLoginInitialContextFactory

This is simple add following properites to java env.

java.naming.factory.initial=org.jboss.security.jndi.JndiLoginInitialContextFactory
java.naming.security.principal=admin
java.naming.security.credentials=admin

2) Using SecurityClient

SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("admin", "admin");
client.login();

3) The way I said I couldn't
Finally I was able to login as mentioned in Mastering ejb book. only thing that missed was some configuratin. after I adding that configuration, It started to work fine.

Configuration conf = new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
AppConfigurationEntry entry = new AppConfigurationEntry("org.jboss.security.ClientLoginModule",AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, new java.util.HashMap());
return new AppConfigurationEntry[] {entry};
}
};
LoginContext loginContext =
new LoginContext("HelloClient",null, new CallbackHandler(), null);
loginContext.login();

Reference

http://blog.e-beyond.de/2010/04/18/jaas-jboss-client-authentication/

Labels:

Sunday, January 1, 2012

Interesting Linux commands

I found some very important linux command we can use in scripting and monitoring.

1) sed

This can be used to search and replace a text in file and print it on the screen as bellow

sed 's/regexp/replacement/' test.txt > test2.txt

2) watch

This command is used to execute same command in a periodic lay in the monitoring purpose.

watch -n 1 date

above command show date in every second in the console

3) grep

Search for a text and print matching lines

grep "sampath" test.txt
grep -e "sampath" -e "chandana" test.txt


4) cut

This can be used to cut line by line with given character positions

grep "sampath" test.txt | cut -c 1-2
grep "sampath" test.txt | cut -c 1-2,5,6

5) Find for a file

find ./ -name finename.ext

6) Find a files containing some text
grep -lir "text_need_to_find" ./

-l list file names
-r search recursivly in subdirectories
-i ignore case sensitive

7) Reintalling packages in ubuntu
sudo apt-get --reinstall install libaprutil1