Saturday 15 January 2011

Give authetication to a file in tomcat server -


I have a text file and put it in the Tomcat server root folder. I want to give that file authentication and how can I use that file after giving authentication.

How can I get this? Please help anybody. Assume that you have this project structure:

and you want to save / folder Only accessible to the role of admin , you can access it on your web. Xml should be edited:

  & lt ;? Xml version = "1.0" encoding = "UTF-8" & gt; & Lt; Web-App version = "3.0" xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema -instance" Xsi: Schema Location = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> & Lt; Session-config & gt; & Lt; Session timeout & gt; 30 & lt; / Session-timeout & gt; & Lt; / Session-config & gt; & Lt; Security-lock & gt; & Lt; Display-name & gt; Constraint1 & lt; / Display-name & gt; & Lt; Web resource collection & gt; & Lt; Web resource name & gt; File & lt; / Web resource name & gt; & Lt; Description / & gt; & Lt; URL pattern & gt; / Folder / * & lt; / URL pattern & gt; & Lt; / Web resource collection & gt; & Lt; Auth-obstructing & gt; & Lt; Description / & gt; & Lt; Role Name & gt; Admin & lt; / Role Name & gt; & Lt; / Auth-Barrier & gt; & Lt; / Safety-barrier & gt; & Lt; Security-roles & gt; & Lt; Description / & gt; & Lt; Role Name & gt; Admin & lt; / Role Name & gt; & Lt; / Safety-roles & gt; & Lt; / Web application & gt;   

So if a person tries to use the admin file resource without the role, then he will get it:

Enter image details here

This is role-based authentication.

Of course this is a way. There are also other safety mechanisms that can be used in tomcat. See these resources for more information about Tomcat's safety

  1. / Html>

No comments:

Post a Comment