Saturday, March 14, 2009

Assume an application needs security permissions granted before the

Question :Assume an application needs security permissions granted before the
application can talk to the database. How
do you go about setting the permissions? Give an example of setting the
permission in Tomcat and stand alone
java programme. (Security)


Answer :In Tomcat:
Add security permission to catalina.policy file located under
/conf/ Add the following lines
grant codeBase "file:${catalina.home}/webapps/MyContext/-"
{
permission java.security.AllPermission;
};
In stand alone java application:
Create a .policy file that points to the code base where the application
resides.
grant codebase "file:c:/source/java/-"
{
permission java.security.AllPermission;
};
java -Djava.security.policy=.policy com.test.MyClass

No comments: