I am testing security constraints for certain URLs. I feel url pattern is acting weird. I want access restricted whatever comes after ServletSecurityTest(webapproot)/
. But, after deploying war file in websphere, even ServletSecurityTest(webapproot)
itself is restricted. why ?
For example:
I wanted this http//ravi-pc:9080/ServletSecurityTest/testSecurity.do
to be restricted. That is alright. But even http//ravi-pc:9080/ServletSecurityTest
is restricted. why ?
Any ideas ?
web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>Servlet Security Resources</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Administrator</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>Administrator</role-name>
</security-role>
Servlet
@WebServlet(name="SecurityTestServlet", urlPatterns={"/testSecurity.do"})
public class SecurityTestServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().write("Only Administrators can see this...");
}
}