Wednesday, April 08, 2009

Add Authentication for your Tomcat Web Application (Using Tomcat Security Realms )

Here im going to note down small set of steps which are very esay and fster to do and create a login for your tomcat web application.
1. get root access and get into the tomcat folder.
2. Open conf/server.xml and uncomment the following line.

<Realm className="org.apache.catalina.realm.MemoryRealm" />
package com.infosys.hanumant.rome;

3. Open webapps/your_tomcat_application/WEB-INF/web.xml and add the following security constraint:


<security-constraint>
<web-resource-collection>
<web-resource-name>
Any_Name_That_You_Wish
</web-resource-name>
<url-pattern>
/*
</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>
name_of_the_role_which_has_access
</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>
Any_Name_That_You_Wish
</realm-name>
</login-config>


here you have to use the same "web-resource-name" and the "realm-name".

4.
Open conf/tomcat-users.xml and add the following <user> sub-element:


<user name="anyUserName" password="anyPassword" roles="name_of_the_role_which_has_access">


remember that the role which we use here in this tomcat-users.xml and the one which we used in the step 3 should be same. And here we dont need to creat a role differently. Just adding the above line will be enough.

5. Now its time to restart tomcat server.

Enjoy

Easy way to write XML (or HTML) Tags on your blog

When you try to copy and paste xml or html tags on you blog, the blogger count it as a html tag and it will result various other things other than the output you needed.

So i found a link where you can convert you code easily to the code that should be written.
http://francois.schnell.free.fr/tools/BloggerPaste/BloggerPaste.html

If you really feel thats the wrong way still you can waste time on typing all the charactors as well.

Enjoy