*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem with Form-based Authentication ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem with Form-based Authentication ..." Watch "Problem with Form-based Authentication ..." New topic
Author

Problem with Form-based Authentication ...

Maneessh saxena
Ranch Hand

Joined: Oct 03, 2006
Posts: 125
hi Great Ranchers,

I was trying to implement the Form-based Authentication / Security. But instead of getting login form I am getting an Error saying "Navigation to the webpage was canceled". I am clueless .... Is there something to do that's related to Internet Explorer settings ??? .....

Best Regards


SCJP 1.4, SCWCD 1.5
Atul Samnerkar
Ranch Hand

Joined: Sep 20, 2003
Posts: 44
Can you please provide the code you used?

  • Login page code
  • Error page code
  • web.xml entry


  • Thanks,
    Atul
    Maneessh saxena
    Ranch Hand

    Joined: Oct 03, 2006
    Posts: 125
    Hi Atul ,

    Thanks for your immediate response. files desired are given below....
    Please see & let me know if any discrepancy ....


    -----------------------------------------------------------

    Login.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <img src="images/ATT108667.jpg"><br>
    <form method="post" action="j_security_check">
    Enter Name : <input type="text" name="j_username"><br>
    Enter PassWord : <input type="text" name="j_password"><br>
    <input type="submit" value="Enter">
    </form>
    </body>
    </html>

    --------------------------------------------------------------------------------------------------------

    web.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>TestMemo</display-name>
    <servlet>
    <description></description>
    <display-name>TestServlet</display-name>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>com.lnt.TestServlet</servlet-class>
    <security-role-ref>
    <role-name>manager</role-name>
    <role-link>director</role-link>
    </security-role-ref>
    </servlet>
    <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/TestServlet</url-pattern>
    </servlet-mapping>
    <security-role>
    <role-name>director</role-name>
    </security-role>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>someName</web-resource-name>
    <url-pattern>/TestServlet</url-pattern>
    <http-method>GET</http-method>
    </web-resource-collection>

    <auth-constraint>
    <role-name>director</role-name>
    </auth-constraint>

    <user-data-constraint>
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
    </security-constraint>

    <login-config>
    <auth-method>BASIC</auth-method>
    <form-login-config>
    <form-login-page>/Login.jsp</form-login-page>
    <form-error-page>/Errorpage.jsp</form-error-page>
    </form-login-config>
    </login-config>

    </web-app>



    --------------------------------------------------------------------------------------------------------------------

    TestServlet.java



    package com.lnt;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;


    public class TestServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;


    public TestServlet() {
    super();
    }

    protected void doGet(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
    //super.doGet(request, response);
    //This Is The Constrainrd Resource ......
    }

    protected void doPost(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
    super.doPost(request, response);
    }
    }


    --------------------------------------------------


    Thanks & Regards
    Atul Samnerkar
    Ranch Hand

    Joined: Sep 20, 2003
    Posts: 44
    Change the <auth-method> from "BASIC" to "FORM"
    <auth-method>FORM</auth-method>


    Cheers..
    Maneessh saxena
    Ranch Hand

    Joined: Oct 03, 2006
    Posts: 125
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>


    Sorry It was by mistake .... Actually that's what my problem is even if I had "auth-method>FORM</auth-method>" my customized login page was not coming instead an error was coming saying "Navigation to the webpage was canceled". I don't know why .....
    Maneessh saxena
    Ranch Hand

    Joined: Oct 03, 2006
    Posts: 125
    Hi,

    I got why it was not working ... actually I did not set the " SSL on Tomcat ", That's why it was not working .....

    Thanks for your support ...

    Best Regards
     
    jQuery in Action, 2nd edition
     
    subject: Problem with Form-based Authentication ...
     
    Similar Threads
    login authentication
    Security Maintenance
    Form Authentication - not getting the user
    NTLM Authentication Problem
    JAAS programatically