3 Replies Latest reply on Mar 19, 2012 8:38 AM by Stefan Maier

    Problems with basic authentication with JBoss 7.1.1

    Stefan Maier Newbie



      I tried basic authentication with the preconfigured "other" security domain on JBoss 7.1.1, but I can't get it to work. I have added a user to application-useres.properties using the add-user.sh script but whenever I enter the correct username and password, I get  "HTTP Status 403 - Access to the requested resource has been denied".  I do net get any security exception, so I think that authentication was successful, but nevertheless  access to the servlet requested is not granted. As can be seen from the code the servlet is mapped to "/" and the URL pattern for the secured area is "/*". Do I miss anything here or is there some misconfiguration anywhere?


      This is my web.xml:



      ?xml version="1.0" encoding="UTF-8"?>

      <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"


               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">





                        <display-name>Authentication Ex Login</display-name>


















      and the jboss-web.xml:



      <?xml version="1.0" encoding="UTF-8"?>






      Finally the Servlet code:


      package example.authentication;



      import java.io.IOException;

      import java.io.PrintWriter;



      import javax.servlet.ServletException;

      import javax.servlet.annotation.WebServlet;

      import javax.servlet.http.HttpServlet;

      import javax.servlet.http.HttpServletRequest;

      import javax.servlet.http.HttpServletResponse;




      public class AuthenticationServlet extends HttpServlet


               private static final long serialVersionUID = 1L;



               public AuthenticationServlet()






               protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException






               protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException





               private void sayHello(HttpServletResponse response) throws IOException


                        PrintWriter writer = response.getWriter();



                        writer.println("<head><title>Hello World Servlet</title></head>");


                        writer.println("         <h1>Congratulations, you have been authenticated!</h1>");