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
No comments:
Post a Comment