Form based authentication HTTP 403 access forbidden in WL 8.1

Hi there..
I found following message posted in April-2004 by Sandeep very useful.
I also ended up getting the following HTTP 403 Forbidden access error while using Pageflow controller and Form based authentication.
I noticed 2 things. If you have a normal webapp A, which is a plain old webapp (which does not use pageflow..workshop etc..) then the following error does not occur.
It only happens with those webapps which utilizes WL 8.1's pageflow features. Note that I am not using nested page flows. I just used 1 pageflow controller and wanted to have the form based login feature for the same.
BEA's samples on form authentication talks about nested page flows and javax.security.auth.login.FailedLoginException and etc.. are they only applicable to nested pageflows?
can't I use the same to capture failed login exception within a single controller?
I tried out putting FailedLoginException exception-handler in Global.app file but it didn't catch it. Only the following work around worked. is this a bug in WL 8.1 workshop? or I am missing something.
I would appreciate if someone can clear this doubt.
I am using WL 8.1 with sp3.
Rajesh
Hey guys,
I could find the solution for my problem. Here it is
We need to add following lines of code in the erro.jsp page.
<form action"j_security_check>
....write the error mesage....
</form>
You will get rid of "403 Forbidden page" error.
Thanks,
Sandip
[email protected] (Sandip Atkole) wrote in message news:<[email protected]>...
I am trying to set up Form-Based Authentication on WebLogic 8.1
The Problem:
If the user provides correct userid/password, he gets access to the
protected resource as required, but if he provides incorrect
userid/password, he gets a 403 Forbidden page, instead of getting the
login failure page.
The Descriptors:
WEB.XML
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/Login.jsp</form-login-page>
<form-error-page>/LoginError.jsp</form-error-page>
</form-login-config>
</login-config>
Why doesn't it redirect to "/LoginError.jsp" instead of showing the
403 Forbidden page?
Thanks in advance
Sandip

It seems like a bug. However when I explicitly reset the error using set status it worked for me. I added following code in my error jsp .
<%     
     response.setHeader("conent-type","text/html");
     response.setStatus(200);
%>

Similar Messages

  • Help : Form based authentication - Forbidden 403

    Hi,
    I have create a web app that requires form based authentication when
    accessing certain pages.
    Thus, I've created the entry in the web.xml accordiingly and tested on
    Tomcat to be working fine.
    When I redeployed the web app to weblogic, the normal access of pages
    works fine.
    But when I try to access the restricted pages, the browser show the
    error.
    "Error 403--Forbidden
    From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
    10.4.4 403 Forbidden
    The server understood the request, but is refusing to fulfill it.
    Authorization will not help and the request SHOULD NOT be repeated.
    I'm puzzled by the fact that it didn't even prompt me to the login
    page.
    How can I fix the problem?
    Or, which are the documents I should read?
    I have gone through the weblogic documentation briefly, but either it
    mention security management as a whole or just the security-constraint
    in the web app dd.
    I'm new to weblogic, so, it's likely that I missed something very
    basic and appreciate anyone to point that out to me.
    Thanks for any advice.
    Cheers.
    Han Ming

    It seems like a bug. However when I explicitly reset the error using set status it worked for me. I added following code in my error jsp .
    <%     
         response.setHeader("conent-type","text/html");
         response.setStatus(200);
    %>

  • Forms Based Authentication in Project Server 2013

    Hi,
    I have created a PWA web app with SQL Forms Based Authentication. I am able to login and able to see the Project Center page.
    But the Project Center Web Part is not getting displayed. Also facing the same issue while
    Enterprise Custom Fields and Look up page,
    the page is blank
    When user tries to edit user in Manage Users page under Security, that page is also blank
    Projects ribbon doesn't show up
    User not able to create projects
    Kindly provide some pointers for the same.
    Thanks & regards,
    Divyang Agrawal

    Hi Kirtesh,
    Thanks for the response.
    The issue here is not related to hardware, but it is regarding the user not having appropriate rights to do the above mentioned operations.
    Are there few more steps that are required for the FBA, where a user needs to be given access rights explicitly.
    The users I have used for now have been added to administrator's group and have full rights on the system.
    Also, when I try to create a Project in the instance using the CSOM code and passing the user's credentials who is a part of Administrator Group., it gives me a 403 forbidden exception.
    Kindly provide some inputs for the same.
    Regards,
    Divyang Agrawal

  • Behavior in form-based authentication

    Environment
    - WebLogic5.1 with SP8
    - WinNT 4.0 with SP5
    - JDK1.2.2
    When an authenticated user tries to access a resource that the user is not
    authorized to access, he/she
    is automatically forwarded to login page and WebLogic loses the
    authentication information of that user.
    Then the user has to re-login to access resources that he/she has
    permissions and previously accessed.
    My question is:
    1. Is there any way to redirect the user who attempts to access unauthorized
    resources to an error page, not the login page,
    so that the user doesn't have to re-login to access authorized resources?
    2. if a user tries to access an unauthrized resource, shouldn't I be
    getting a 403 {sc_Forbidden} error back?
    Is that correct? If so, I don't see why the following setting wouldn't work.
    <error-page>
    <error-code>403</error-code>
    <location>/errorpages/error.jsp?errorcode=403</location>
    </error-page>
    <error-page>
    <error-code>401</error-code>
    <location>/errorpages/error.jsp?errorcode=401</location>
    </error-page>
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/login.jsp</form-login-page>
    <form-error-page>/errorpages/error.jsp?errorcode=999</form-error-page>
    </form-login-config>
    </login-config>
    Thanks in advance for any help or comment.
    Sang

    Tom,
    Thanks for you comment. I appreciate it.
    I've tried what you suggested but there is still a problem.
    When a user is forwarded to the page specified as a login page in the xml,
    the identity of the user is already lost in the container.
    If you print the current user in the login.jsp by calling
    "Request.getRemoteUser()", you'll get a NULL.
    Although you go back to the JSP page you have already accessed, you have to
    go through the authentication over again.
    Is this correct authentication behavior?
    The following is an abstract of form-based authentication processes from
    Servlet v2.2 spec.
    ============================================================================
    When a user attempts to access a protected web resource, the container
    checks if the user has been
    authenticated. If so, and dependent on the user's authority to access the
    resource, the requested web
    resource is activated and returned. If the user is not authenticated, all of
    the following steps occur:
    1. The login form associated with the security constraint is returned to the
    client. The URL path
    which triggered the authentication is stored by the container.
    2. The client fills out the form, including the username and password
    fields.
    3. The form is posted back to the server.
    4. The container processes the form to authenticate the user. If
    authentication fails, the error page is
    returned.
    5. The authenticated principal is checked to see if it is in an authorized
    role for accessing the origi-nal
    web request.
    6. The client is redirected to the original resource using the original
    stored URL path.
    If the user is not successfully authenticated, the error page is returned to
    the client. It is
    recommended that the error page contains information that allows the user to
    determine that the
    authorization failed.
    ============================================================================
    Although the procedures of form based authentication is well-specified,
    behavior of authorization is quite unclear.
    It doesn't specify what should be done and what happens to the state of the
    current identity in case of authorization failure.
    Is there any workaround solution for this problem?
    Thanks again.
    Sang
    Tom Mitchell <[email protected]> wrote in message
    news:[email protected]...
    Sang,
    The behavior you are seeing seems to be correct. You are logged in andtry to
    hit a resource that you do not have access to. So, as far as thecontainer
    knows, it is supposed to give you a chance to reauthenticate as someonewho can
    access the new resource.
    If you have rights to both resources, you will not get prompted again.
    If I understand your desired behavior, you could have login to take place
    "manually" - meaning you will have an explicit login button or link.
    Then could have your login page, defined in the xml, actually be an errorpage
    that would not affect the current identity.
    Hope this helps.
    Tom Mitchell
    [email protected]
    Very Current Stoneham, MA Weather
    http://www.tom.org
    "Sang Y. Sung" wrote:
    Environment
    - WebLogic5.1 with SP8
    - WinNT 4.0 with SP5
    - JDK1.2.2
    When an authenticated user tries to access a resource that the user is
    not
    authorized to access, he/she
    is automatically forwarded to login page and WebLogic loses the
    authentication information of that user.
    Then the user has to re-login to access resources that he/she has
    permissions and previously accessed.
    My question is:
    1. Is there any way to redirect the user who attempts to accessunauthorized
    resources to an error page, not the login page,
    so that the user doesn't have to re-login to access authorizedresources?
    >>
    2. if a user tries to access an unauthrized resource, shouldn't I be
    getting a 403 {sc_Forbidden} error back?
    Is that correct? If so, I don't see why the following setting wouldn'twork.
    >>
    <error-page>
    <error-code>403</error-code>
    <location>/errorpages/error.jsp?errorcode=403</location>
    </error-page>
    <error-page>
    <error-code>401</error-code>
    <location>/errorpages/error.jsp?errorcode=401</location>
    </error-page>
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/login.jsp</form-login-page>
    <form-error-page>/errorpages/error.jsp?errorcode=999</form-error-page>
    </form-login-config>
    </login-config>
    Thanks in advance for any help or comment.
    Sang

  • Forcing specific clients or groups to use forms based authentication (FBA) instead of windows based authentication (WIA) with ADFS

    Hi,
    We are have a quite specific issue. The problem is most likely by design in ADFS 3.0 (running on Windows Server 2012 R2) and we are trying to find a "work-around".
    Most users in the organization is using their own personal computer and everything is fine and working as expected, single sign-on (WIA) internally to Office 365 and forms based (FBA) externally (using Citrix NetScaler as reverse proxy and load
    balancing with the correct rewrites to add client-ip, proxy header and URL-transformation).
    The problem occurs for a few (50-100) users where they are sharing the same computer, automatically logged on to the computer using a generic AD-user (same for all of them). This AD-user they are logged on with does not have any access to Office365
    and if they try to access SharePoint Online they receive an error that they can't login (from SharePoint Online, not ADFS).
    We can't change this, they need to have this generic account logged on to these computers. The issue occurs when a user that has access to SharePoint Online tries to access it when logged on with a generic account.
    They are not able to "switch" from the generic account in ADFS / SharePoint Online to their personal account.
    The only way I've found that may work is removing IE as a WIA-capable agent and deploy a User-Agent version string specific to most users but not the generic account.
    My question to you: Is there another way? Maybe when ADFS sees the generic user, it forces forms based authentication or something like that?
    Best regards,
    Simon

    I'd go with your original workaround using the user-agent and publishing a GPO for your normal users that elects to use a user-agent string associated with Integrated Windows Auth.. for the generic accounts, I'd look at using a loopback policy that overwrites
    that user agent setting, so that forms logon is preferred for that subset of users. I don't think the Netscaler here is useful in this capacity as it's a front-end proxy and you need to evaluate the AuthZ rules on the AD FS server after the request has been
    proxied. The error pages in Windows Server 2012 R2 are canned as the previous poster mentioned and difficult to customize (Javascript only)...
    http://blog.auth360.net

  • Error in form based authentication

    Hi all,
    i want 2 implement form based authentication to a dummy resource in iis.
    first i created authentication as
    Challenge Method Form
    Challenge Parameter passthrough: no
    creds: usernamevar passwordvar
    action: /access/oblix/apps/webgate/bin/webgate.dll
    form: /public/login.html
    SSL Required No
    Challenge Redirect
    Enabled Yes
    and configured a policy domain for a dummy resource test.html with form authentication schema. i kept that in a folder 'access' which was placed in iis. i mentioned the action attribute to '/access/test.html' in login.html through which i want to do authentication.
    but when i am accessing http://*...*/test.html
    i am getting http 404 error.
    can anyone help me.
    Thank you

    Hi,
    thanks for ur response. i make some changes to my configuration which was given in previous post. now i configured as follows:
    i kept my test.html and login.html in the iis root folder. and i defined my policy as follows:
    Name : form (policy name)
    Enabled : Yes
    Resource Resource Type :http
    URL Prefix : /test.html
    Description
    Authorization Rules Name ---- Form authorization
    Description ---
    Enabled --- Yes
    Allow takes precedence ----Yes
    Allow Access Role---- Any one
    Default Rules
    Authentication Rule
    name of the authentication: policy form authentication
    Authentication Scheme : Form authentication -----------------which was created in Access system console
    Authorization Expression
    Expression : Form authorization
    Duplicate Actions: No policy defined for this Authorization Expression. The Access System level default policy for dealing with duplicate action headers will be employed.
    Audit Rule
    There is no Audit Rule defined.
    Policy Name : form policy
    Description :
    Resource Type: http
    Resource Operation(s) : POST
    GET
    Resource : all
    Authentication Rule
    policy auth. rule
    Authentication Scheme Form authentication
    Authorization Expression
    There is no Authorization Expression defined.
    Audit Rule
    There is no Audit Rule defined.
    Delegated Access Admins Delegate Rights
    People Administrator
    Grant Rights
    There are no Delegated Access Admins with this right.
    Basic Rights
    There are no Delegated Access Admins with this right.
    and i also created login.html with a method 'post' and pointed out the action to '/access/oblix/apps/webgate/bin/webgate.dll' . i placed it in IIS root folder.
    now my auth. schema is as follows.
    form: /login.html action:/access/oblix/apps/webgate/bin/webgate.dll passthrough: no creds: usernamevar passwordvar (which are names of fields in login.html)
    and the plugin mapping is as follows:
    credential_mapping:obMappingBase="cn=users,dc=orademo,dc=com", obMappingFilter="(&(&(objectclass=User)(sAMAccountName=%usernamevar%) )(|(!(obuseraccountcontrol=*))(obuseraccountcontrol=ACTIVATED)) )"
    validate_password: obCredentialPassword="passwordvar"
    so when i am accessing http://<hostname>/test.html
    it is giving popup window like basic auth. schema. i am not getting my login page. and in that even i am logging as admin . it is saying unauthorized user.
    please help me how to configure it.
    Edited by: new2idm on Feb 17, 2010 9:19 PM
    Edited by: new2idm on Feb 17, 2010 9:19 PM

  • Any one having idea on Form based authentication ?

    Hi ,
    I need help on configuring web.xml for form based authentication .
    ie if any one clicks or attempts to access any page in application it should redirect to login page.
    Thanks.

    there is no need to write a servlet filter for this any more. It is part of the servlet spec. Web containers should provide it as a matter of course. It will automatically handle the popping up of the login page, and continue to the destination on successful login, all automagically.
    A quick search on Google provides several articles and examples on this very subject. Try http://www.onjava.com/pub/a/onjava/2002/06/12/form.html
    Heres a quick example of web.xml config taken from that article:
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/login.jsp</form-login-page>
    <form-error-page>/fail_login.html</form-error-page>
    </form-login-config>
    </login-config>
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>AdminPages</web-resource-name>
    <description> accessible by authorised users </description>
    <url-pattern>/admin/*</url-pattern>
    <http-method>GET</http-method>
    </web-resource-collection>
    <auth-constraint>
    <description>These are the roles who have access</description>
    <role-name>manager</role-name>
    </auth-constraint>
    </security-constraint>Cheers,
    evnafets

  • Session expired message in form based authentication

    Hi, i m using JAAS form based authentication on jboss for our application and we want session expired message to show in the login form when it loads for authentication after session expired.
    do any one have any idea how to achive this as the application will never be able to detect that the session expired as it will always have a valid session available becoz ,When an HTTP session expires and the client makes a request to any secured resource, the JAAS subject will not be found for authorization. At this point, the security framework creates a new HTTP session, stores the target URL value in the session, and then redirects the user to the login page. After a successful login process, the user is forwarded back to the target page,
    but our Web applications may need to capture these session expiration events and show some custom message to the user.
    HTTP session listener doesn't work here as HTTP session listener does not allow you to create a new session.
    Thanks in advance

    ObSSOCookie does have session time data. Access Manager SDK can parse the cookie and can access it's own settings for max and idle session time.
    Trick is, once the user is logged out, the cookie is destroyed. I suspect there is no real practical way to do this.
    I have pondered the idea that you could use AJAX to communicate with a service that uses the SDK to return data about current session state - "You have 40 seconds left to get your form filled out, buddy! 39, 38, 37..."
    Oh to have that much free time... ;)
    Mark

  • Performing form based authentication with entities

    Hey everyone,
    Im in a major dilemma.Im trying to perform form-based authentication using entities.I have created the entity class from the database,and I used a SLSB to access the bean method via JNDI(when I tried using dependency injection,there was an exception).I also cannot use hibernate as a persistent provider.I used toplink since it is the default in netbeans 5.5.1 and it did not raise any issues.But then,I noticed that toplink is most compatible with the oracle application server,and I use sun java system application server 9.1.I have not been able to successfully perform the authentication.
    here's the code:note,there are still bugs as ive been going back and forth trying to find a solution and also because Ive been working with preexisting code.
    model:
    SLSB
    * userValidationBean.java
    * Created on 26 March 2008, 18:25
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package Entities;
    import javax.ejb.Stateless;
    import javax.ejb.Remote;
    import java.util.List;
    import javax.persistence.PersistenceContext;
    import javax.persistence.EntityManager;
    import javax.persistence.Query;
    import Entities.UserTable;
    import javax.transaction.UserTransaction;
    import javax.annotation.Resource;
    //the reason for the many comments is that im still debugging and there are still some bugs.Ive also been trying to go back and forth just
    //to get a solution.
    //the other accompanying classes had preexisting code i wrote earlier.
    * @author Ayo
    @Stateless
    @Remote(userValidationRemote.class)
    public class userValidationBean implements Entities.userValidationRemote {
    @PersistenceContext private EntityManager manager;
    @Resource private javax.transaction.UserTransaction tran;
    /** Creates a new instance of userValidationBean */
    public userValidationBean() {
    //"SELECT u.username,u.password FROM UserTable u WHERE u.username =?1 and u.password=?2"
    public boolean checkUser()
    try
    tran.begin();
    UserTable user=new UserTable();
    Query query=manager.createQuery("select u.username,u.password from u.user_table where u.username=:username and u.password=:password");
    /*query.set("username",user.getUsername());
    query.setParameter("password",user.getPassword());*/
    query.setParameter("username",user.getUsername());
    query.setParameter("password",user.getPassword());
    userValidationBean ubean=(userValidationBean)query.getSingleResult();
    boolean result=ubean==null?true:false;
    tran.commit();
    catch(Exception e)
    System.out.println("Error:"+e);
    // boolean result=ubean==null?true:false;
    return result;
    remote interface
    package Entities;
    import javax.ejb.Remote;
    import Entities.UserTable;
    * This is the business interface for userValidation enterprise bean.
    @Remote
    public interface userValidationRemote {
    public boolean checkUser();
    controller:servlet
    * userCheck.java
    * Created on 15 March 2008, 22:41
    package servlets;
    import Entities.UserTable;
    import Entities.userValidationBean;
    import javax.annotation.*;
    import Entities.userValidationRemote;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.ejb.*;
    import javax.naming.*;
    import javax.persistence.*;
    * @author Ayo
    * @version
    public class userCheck extends HttpServlet {
    //@EJB userValidationRemote userRemote;
    boolean checkUser;
    String username,password;
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    /*con=null;
    ps=null;
    rs=null;
    s=null;
    */response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    username=request.getParameter("username");
    password=request.getParameter("password");
    if(username==""||password=="")
    //RequestDispatcher de=request.getRequestDispatcher("admin_error.jsp");
    //de.forward(request,response);
    //showError("<b><font color=\"red\">Invalid Login details!</font></b>",request,response);
    showError("<b><font color=\"red\">Please fill in the required blanks.</font></b>",request,response);
    else
    try
    Context ctx=new InitialContext();
    userValidationRemote userRemote=(userValidationRemote)ctx.lookup("Entities.userValidationRemote");
    checkUser= userRemote.checkUser();
    //checkUser= userRemote.checkUser();
    //return;
    //checkUser(UserTable user);
    catch(Exception e)
    out.println("Error:"+e);
    //userValidation.checkUser(UserTable user);
    if(checkUser==true)
    RequestDispatcher d=request.getRequestDispatcher("blah.jsp");
    d.forward(request,response);
    else if(checkUser==false)
    // RequestDispatcher d=request.getRequestDispatcher("admin_error.jsp");
    //d.forward(request,response);
    showError("<b><font color=\"red\">Invalid Login details!</font></b>",request,response);
    //call bean(stateless or stateful)which access method on entity that validates.
    // checkUser(request,response);
    /* TODO output your page here
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet userCheck</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Servlet userCheck at " + request.getContextPath () + "</h1>");
    out.println("</body>");
    out.println("</html>");
    //out.close();
    /* public synchronized void checkUser(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    if(username==""&&password=="")
    showError("<b><font color=\"red\">Please fill in the required blanks.</font></b>",request,response);
    else
    try
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Health_Management_System","root","");
    ps=con.prepareStatement("select username,password from user_table where username=?and password=?");
    ps.setString(1,username);
    ps.setString(2,password);
    rs=ps.executeQuery();
    if(rs.next())
    user=rs.getString(1);
    pass=rs.getString(2);
    //check user type,wether super admin,user or the other subadmins or a regular user.
    checkType(request,response);
    else
    //redirect to admin error page,then close the connection.
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    con.close();
    catch(Exception e)
    private synchronized void checkType(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    try
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Health_Management_System","root","");
    ps=con.prepareStatement("select user_type,user_id,access_level from user_table where username=? and password=?");
    ps.setString(1,user);
    ps.setString(2,pass);
    rs=ps.executeQuery();
    if(rs.next())
    user_type=rs.getString(1);
    user_id=""+rs.getInt(2);
    access_level=rs.getString(3);
    if(user_type.equals("super")&&(access_level.equals("all")))
    //create admin user session,add to the username and the user_id.
    //redirect to super admin page,with access rights to create
    //health admin,insurance admin and HMO admin.
    //pretty cool stuff!
    HttpSession session=request.getSession(true);
    session.setAttribute("user",user);
    session.setAttribute("user_id",user_id);
    RequestDispatcher dispatcher=request.getRequestDispatcher("admin_user_page.jsp");
    dispatcher.forward(request,response);
    //session.setAttribute(user_id);
    //remember to create a hidden field if you need to pass this information
    //to another page and retrieve the super admin id to track his activities.
    else if(user_type.equals("health administrator")&&(access_level.equals("Health")))
    HttpSession session=request.getSession(true);
    session.setAttribute("user",user);
    session.setAttribute("user_id",user_id);
    RequestDispatcher des=request.getRequestDispatcher("health_admin_user_page.jsp");
    des.forward(request,response);
    //check for other user types,health admin,hmo admin and insurance admin.
    else if(user_type.equals("hmo administrator")&&(access_level.equals("HMO")))
    HttpSession session=request.getSession(true);
    session.setAttribute("user",user);
    session.setAttribute("user_id",user_id);
    RequestDispatcher d=request.getRequestDispatcher("hmo_admin_user_page.jsp");
    d.forward(request,response);
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    else if(user_type.equals("insurance administrator")&&(access_level.equals("insurance")))
    HttpSession session=request.getSession(true);
    session.setAttribute("user",user);
    session.setAttribute("user_id",user_id);
    RequestDispatcher de=request.getRequestDispatcher("insurance_admin_user_page.jsp");
    de.forward(request,response);
    else if(user_type.equals("user")&&(access_level.equals("health")))
    try
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql:http://localhost:3306/Health_Management_System","root","");
    ps=con.prepareStatement("select staff_id from user_table where username=?and password=?");
    ps.setString(1,username);
    ps.setString(2,password);
    rs=ps.executeQuery();
    if(rs.next())
    String staff_id=""+rs.getInt(1);
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Health_Management_System","root","");
    ps=con.prepareStatement("select * from health_staff_table where staff_id=?");
    ps.setString(1,staff_id);
    rs=ps.executeQuery();
    if(rs.next())
    //retrieve the values from health staff and store them in variables.
    //store important variables in user sessions e.g.staff_id,username,place of work for display in the web page.
    //redirect to required page.
    String first_name=rs.getString("first_name");
    String last_name=rs.getString("last_name");
    String work_place=rs.getString("place_of_work");
    HttpSession session=request.getSession(true);
    session.setAttribute("first_name",first_name);
    session.setAttribute("last_name",last_name);
    session.setAttribute("work_place",work_place);
    session.setAttribute("staff_id",staff_id);
    //redirect to user page.
    else
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    else
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    catch(Exception e)
    //catch exception and redirect to page.
    else if(user_type.equals("user")&&(access_level.equals("HMO")))
    try
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql:http://localhost:3306/Health_Management_System","root","");
    ps=con.prepareStatement("select staff_id from user_table where username=?and password=?");
    ps.setString(1,username);
    ps.setString(2,password);
    rs=ps.executeQuery();
    if(rs.next())
    String staff_id=""+rs.getInt(1);
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Health_Management_System","root","");
    ps=con.prepareStatement("select * from hmo_staff_table where staff_id=?");
    ps.setString(1,staff_id);
    rs=ps.executeQuery();
    if(rs.next())
    //retrieve the values from HMO staff and store them in variables.
    //store important variables in user sessions e.g.staff_id,username,place of work for display in the web page.
    //redirect to required page.
    String first_name=rs.getString("first_name");
    String last_name=rs.getString("last_name");
    String work_place=rs.getString("place_of_work");
    HttpSession session=request.getSession(true);
    session.setAttribute("first_name",first_name);
    session.setAttribute("last_name",last_name);
    session.setAttribute("work_place",work_place);
    session.setAttribute("staff_id",staff_id);
    else
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    else
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    catch(Exception e)
    //catch exception and redirect to page.
    else if(user_type.equals("user")&&(access_level.equals("insurance")))
    try
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql:http://localhost:3306/Health_Management_System","root","");
    ps=con.prepareStatement("select staff_id from user_table where username=?and password=?");
    ps.setString(1,username);
    ps.setString(2,password);
    rs=ps.executeQuery();
    if(rs.next())
    String staff_id=""+rs.getInt(1);
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Health_Management_System","root","");
    ps=con.prepareStatement("select * from insurance_staff_table where staff_id=?");
    ps.setString(1,staff_id);
    rs=ps.executeQuery();
    if(rs.next())
    //retrieve the values from insurance staff and store them in variables.
    //store important variables in user sessions e.g.staff_id,username,place of work for display in the web page.
    //redirect to required page.
    String first_name=rs.getString("first_name");
    String last_name=rs.getString("last_name");
    String work_place=rs.getString("place_of_work");
    HttpSession session=request.getSession(true);
    session.setAttribute("first_name",first_name);
    session.setAttribute("last_name",last_name);
    session.setAttribute("work_place",work_place);
    session.setAttribute("staff_id",staff_id);
    else
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    else
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    catch(Exception e)
    //catch exception and redirect to page.
    else
    //invalid login details.After all else fails.
    showError("<b><font color=\"red\">Invalid Login details.</font></b>",request,response);
    catch(Exception e)
    private void showError(String errorMsg,HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    request.setAttribute("error_msg",errorMsg);
    RequestDispatcher dispatcher=request.getRequestDispatcher("admin_error.jsp");
    dispatcher.forward(request,response);
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    // </editor-fold>
    view
    <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Login</title>
    <style type="text/css">
    <!--
    .style3 {     color: #000000;
         font-family: Arial, Helvetica, sans-serif;
         font-size: 12px;
    .style1 {color: #0000FF}
    .style4 {
         color: #0000FF;
         font-size: 12px;
    .style5 {
         font-size: 12px
    .style6 {
         color: #FF0000;
         font-size: 12px;
    .style7 {
         font-size: 36px
    .style8 {color: #000000}
    -->
    </style>
    </head>
    <body>
    <table width="564" border="0" align="center">
    <tr>
    <td width="558" bgcolor="#CCCCCC" class="style1"><div align="center">
    <p> </p>
    <h1 class="style7">Welcome to HealthPort</h1>
    <p>HealthPort Login</p>
    <p><span class="style8">Today's date is:<%= new java.util.Date() %></span></p>
    <form id="form1" name="form1" method="post" action="userCheck">
    <p align="right" class="style3">Username
    <label></label>
    <input type="text" name="username" id="username" />
    </p>
    <p align="right" class="style3">Password
    <input type="password" name="password" id="password" />
    </p>
    <p align="right" class="style3">
    <span class="style6">
    <label></label>
    <label></label>
    </span>
    <span class="style5">
    <label></label>
    </span>
    <label>
    <input type="submit" name="button" id="button" value="Login" />
    </label>
    </p>
    <div align="right">
    </div></form>
    <div align="right"><div align="left"><p align="right"> </p>
    </div></div></div></td>
    </tr>
    <tr>
    <td bgcolor="#CCCCCC" class="style1"> </td>
    </tr>
    </table>
    </body>
    </html>
    so,that's about it.I'd appreciate it.I know this is a lot.I'm grateful
    Ayo.

    Hi.Im still having issues trying to perform form based authenticatin with entities.I tried this method but im getting errors on the marked lines.
    controller servlet
    * userCheck.java
    * Created on 15 March 2008, 22:41
    package servlets;
    import Entities.UserTable;
    import Entities.userValidationBean;
    import javax.annotation.*;
    import Entities.userValidationRemote;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.ejb.*;
    import javax.naming.*;
    import javax.persistence.*;
    * @author Ayo
    * @version
    public class userCheck extends HttpServlet {
    //@EJB userValidationRemote userRemote;
    boolean checkUser;
    String username,password;
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    /*con=null;
    ps=null;
    rs=null;
    s=null;
    */response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    username=request.getParameter("username");
    password=request.getParameter("password");
    if(username==""||password=="")
    showError("<b><font color=\"red\">Please fill in the required blanks.</font></b>",request,response);
    else
    try
    Context ctx=new InitialContext();
    userValidationRemote userRemote=(userValidationRemote)ctx.lookup("Entities.userValidationRemote");
    (error on this line-saying ')' expected and no matter if i add ) there is still erro)userRemote.authenticate(String p_user,String p_password);
    catch(Exception e)
    out.println("Error:"+e);
    if(checkUser==true)
    RequestDispatcher d=request.getRequestDispatcher("blah.jsp");
    d.forward(request,response);
    else if(checkUser==false)
    showError("<b><font color=\"red\">Invalid Login details!</font></b>",request,response);
    private void showError(String errorMsg,HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
    request.setAttribute("error_msg",errorMsg);
    RequestDispatcher dispatcher=request.getRequestDispatcher("admin_error.jsp");
    dispatcher.forward(request,response);
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    /** Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    // </editor-fold>
    view
    <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Login</title>
    <style type="text/css">
    <!--
    .style3 {     color: #000000;
         font-family: Arial, Helvetica, sans-serif;
         font-size: 12px;
    .style1 {color: #0000FF}
    .style4 {
         color: #0000FF;
         font-size: 12px;
    .style5 {
         font-size: 12px
    .style6 {
         color: #FF0000;
         font-size: 12px;
    .style7 {
         font-size: 36px
    .style8 {color: #000000}
    -->
    </style>
    </head>
    <body>
    <table width="564" border="0" align="center">
    <tr>
    <td width="558" bgcolor="#9DACBF" class="style1"><div align="center">
    <p> </p>
    <h1 class="style7">Welcome to HealthPort</h1>
    <p>HealthPort Login</p>
    <p><span class="style8">Today's date is:<%= new java.util.Date() %></span></p>
    <form id="form1" name="form1" method="post" action="userCheck">
    <p align="right" class="style3">Username
    <label></label>
    <input type="text" name="username" id="username" />
    </p>
    <p align="right" class="style3">Password
    <input type="password" name="password" id="password" />
    </p>
    <p align="right" class="style3">
    <span class="style6">
    <label></label>
    <label></label>
    </span>
    <span class="style5">
    <label></label>
    </span>
    <label>
    <input type="submit" name="button" id="button" value="Login" />
    </label>
    </p>
    <div align="right">
    </div></form>
    <div align="right"><div align="left"><p align="right"> </p>
    </div></div></div></td>
    </tr>
    <tr>
    <td bgcolor="#CCCCCC" class="style1"> </td>
    </tr>
    </table>
    </body>
    </html>
    SLSB (implements userValidationRemote)
    * userValidationBean.java
    * Created on 26 March 2008, 18:25
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package Entities;
    import javax.ejb.Stateless;
    import javax.ejb.Remote;
    import javax.persistence.PersistenceContext;
    import javax.persistence.EntityManager;
    import javax.persistence.Query;
    import Entities.UserTable;
    import javax.annotation.*;
    //import javax.transaction.UserTransaction;
    * @author Ayo
    @Stateless(mappedName="ejb/facade/userValidationBean")
    @Remote(userValidationRemote.class)
    (error on this line saying can't find class TransactionManagement)@TransactionManagement(value=TransactionManagementType.CONTAINER)
    public class userValidationBean implements Entities.userValidationRemote {
    @PersistenceContext(unitName="HealthInsuranceApp-ejbPU") private EntityManager manager;
    /** Creates a new instance of userValidationBean */
    public userValidationBean() {
    //"SELECT u.username,u.password FROM UserTable u WHERE u.username =?1 and u.password=?2"
    public boolean authenticate(String p_user,String p_password)
    UserTable m_user=manager.find(UserTable.class,p_user);
    if(m_user!=null)
    return m_user.getPassword().equals(p_password);
    return false;
    Entity
    * UserTable.java
    * Created on 29 March 2008, 13:24
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package Entities;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.Table;
    * Entity class UserTable
    * @author Ayo
    @Entity(name="qs_UserPwd")
    @Table(name = "user_table")
    public class UserTable implements Serializable {
    @Id
    @Column(name = "user_id", nullable = false)
    private Integer userId;
    @Column(name = "username")
    private String username;
    @Column(name = "password")
    private String password;
    @Column(name = "user_type")
    private String userType;
    @Column(name = "access_level")
    private String accessLevel;
    @Column(name = "staff_id")
    private Integer staffId;
    @Column(name = "staff_type", nullable = false)
    private String staffType;
    @Column(name = "time_created")
    private String timeCreated;
    @Column(name = "time_modified")
    private String timeModified;
    @Column(name = "time_logged_in")
    private String timeLoggedIn;
    @Column(name = "time_logged_out")
    private String timeLoggedOut;
    @Column(name = "created_by")
    private String createdBy;
    /** Creates a new instance of UserTable */
    public UserTable() {
    * Creates a new instance of UserTable with the specified values.
    * @param userId the userId of the UserTable
    public UserTable(Integer userId) {
    this.userId = userId;
    * Creates a new instance of UserTable with the specified values.
    * @param userId the userId of the UserTable
    * @param staffType the staffType of the UserTable
    public UserTable(Integer userId, String staffType) {
    this.userId = userId;
    this.staffType = staffType;
    public UserTable(String p_user,String p_password)
    setUsername(p_user);
    setPassword(p_password);
    * Gets the userId of this UserTable.
    * @return the userId
    public Integer getUserId() {
    return this.userId;
    * Sets the userId of this UserTable to the specified value.
    * @param userId the new userId
    public void setUserId(Integer userId) {
    this.userId = userId;
    * Gets the username of this UserTable.
    * @return the username
    public String getUsername() {
    return this.username;
    * Sets the username of this UserTable to the specified value.
    * @param username the new username
    public void setUsername(String p_user) {
    p_user = username;
    * Gets the password of this UserTable.
    * @return the password
    public String getPassword() {
    return this.password;
    * Sets the password of this UserTable to the specified value.
    * @param password the new password
    public void setPassword(String p_password) {
    p_password=password;
    * Gets the userType of this UserTable.
    * @return the userType
    public String getUserType() {
    return this.userType;
    * Sets the userType of this UserTable to the specified value.
    * @param userType the new userType
    public void setUserType(String userType) {
    this.userType = userType;
    * Gets the accessLevel of this UserTable.
    * @return the accessLevel
    public String getAccessLevel() {
    return this.accessLevel;
    * Sets the accessLevel of this UserTable to the specified value.
    * @param accessLevel the new accessLevel
    public void setAccessLevel(String accessLevel) {
    this.accessLevel = accessLevel;
    * Gets the staffId of this UserTable.
    * @return the staffId
    public Integer getStaffId() {
    return this.staffId;
    * Sets the staffId of this UserTable to the specified value.
    * @param staffId the new staffId
    public void setStaffId(Integer staffId) {
    this.staffId = staffId;
    * Gets the staffType of this UserTable.
    * @return the staffType
    public String getStaffType() {
    return this.staffType;
    * Sets the staffType of this UserTable to the specified value.
    * @param staffType the new staffType
    public void setStaffType(String staffType) {
    this.staffType = staffType;
    * Gets the timeCreated of this UserTable.
    * @return the timeCreated
    public String getTimeCreated() {
    return this.timeCreated;
    * Sets the timeCreated of this UserTable to the specified value.
    * @param timeCreated the new timeCreated
    public void setTimeCreated(String timeCreated) {
    this.timeCreated = timeCreated;
    * Gets the timeModified of this UserTable.
    * @return the timeModified
    public String getTimeModified() {
    return this.timeModified;
    * Sets the timeModified of this UserTable to the specified value.
    * @param timeModified the new timeModified
    public void setTimeModified(String timeModified) {
    this.timeModified = timeModified;
    * Gets the timeLoggedIn of this UserTable.
    * @return the timeLoggedIn
    public String getTimeLoggedIn() {
    return this.timeLoggedIn;
    * Sets the timeLoggedIn of this UserTable to the specified value.
    * @param timeLoggedIn the new timeLoggedIn
    public void setTimeLoggedIn(String timeLoggedIn) {
    this.timeLoggedIn = timeLoggedIn;
    * Gets the timeLoggedOut of this UserTable.
    * @return the timeLoggedOut
    public String getTimeLoggedOut() {
    return this.timeLoggedOut;
    * Sets the timeLoggedOut of this UserTable to the specified value.
    * @param timeLoggedOut the new timeLoggedOut
    public void setTimeLoggedOut(String timeLoggedOut) {
    this.timeLoggedOut = timeLoggedOut;
    * Gets the createdBy of this UserTable.
    * @return the createdBy
    public String getCreatedBy() {
    return this.createdBy;
    * Sets the createdBy of this UserTable to the specified value.
    * @param createdBy the new createdBy
    public void setCreatedBy(String createdBy) {
    this.createdBy = createdBy;
    * Returns a hash code value for the object. This implementation computes
    * a hash code value based on the id fields in this object.
    * @return a hash code value for this object.
    @Override
    public int hashCode() {
    int hash = 0;
    hash += (this.userId != null ? this.userId.hashCode() : 0);
    return hash;
    * Determines whether another object is equal to this UserTable. The result is
    * <code>true</code> if and only if the argument is not null and is a UserTable object that
    * has the same id field values as this object.
    * @param object the reference object with which to compare
    * @return <code>true</code> if this object is the same as the argument;
    * <code>false</code> otherwise.
    @Override
    public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof UserTable)) {
    return false;
    UserTable other = (UserTable)object;
    if (this.userId != other.userId && (this.userId == null || !this.userId.equals(other.userId))) return false;
    return true;
    * Returns a string representation of the object. This implementation constructs
    * that representation based on the id fields.
    * @return a string representation of the object.
    @Override
    public String toString() {
    return "Entities.UserTable[userId=" + userId + "]";
    please what do I do? or is there a better way? seems like my appserver(sun java system app server 9.1)doesnt support dependency injection as
    there's always an exception in the server log when i try it.i use the default transaction provider toplink because use of any of the others raises an exception and my application index page never shows. please i need help? I want to be able to succesfully perform this authentication as its the only way i can move to the next level
    Ayo.

  • FORM based authentication

    Hi,
    I'm using Oracle JDeveloper 9.0.3 with the embedded oc4j. I have configured for simple FORM based authentication by storing username/password in the principals.xml file.
    I am presented with the login form correctly when I try to access a protected resource, but my username/password is always rejected (I'm redirected to the error page after trying to log-in). Can someone pls help??
    The relevant portions of the contents of the deployment descriptor files that I'm using:
    principals.xml
    <principals>
    <groups>
    <group name="securegroup">
    <description>secureusers</description>
    </group>
    </groups>
    <users>
    <user username="testuser" password="test">
    <description>test user </description>
    <group-membership group="securegroup" />
    </user>
    </users>
    </principals>
    web.xml
    <web-app>
    <security-constraint>
    <display-name>Example Security Constraint</display-name>
    <web-resource-collection>
    <web-resource-name>Protected Area</web-resource-name>
    <!-- Define the context-relative URL(s) to be protected -->
    <url-pattern>*</url-pattern>
    <!-- If you list http methods, only those methods are protected -->
    </web-resource-collection>
    <auth-constraint>
    <!-- Anyone with one of the listed roles may access this area -->
    <role-name>role1</role-name>
    </auth-constraint>
    </security-constraint>
    <!-- Default login configuration uses form-based authentication -->
    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>Example Form-Based Authentication Area</realm-name>
    <form-login-config>
    <form-login-page>login.jsp</form-login-page>
    <form-error-page>error.jsp</form-error-page>
    </form-login-config>
    </login-config>
    <!-- Security roles referenced by this web application -->
    <security-role>
    <role-name>role1</role-name>
    </security-role>
    </web-app>
    orion-application.xml
    <orion-application>
    <security-role-mapping name="role1">
    <group name="securegroup" />
    </security-role-mapping>
    </orion-application>
    application.xml (stored in my D:\JDeveloper\jdev\MyProj\MyProject\WEB-INF\src\META-INF folder)
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN" "http://java.sun.com/j2ee/dtds/application_1_2.dtd">
    <application>
    <security-role-mapping name="role1">
    <group name="securegroup" />
    </security-role-mapping>
    </application>

    REPOST
    <br><br>
    Keywords: form-login, principals.xml, embedded OC4J, authentication
    <p>
    Please see http://forums.oracle.com/forums/message.jsp?id=1266989
    <p>
    The provided link does not work.<br><br>
    In the application.xml of the OC4j config folder I have comemnted out the: <br> <jazn provider="XML" location="./jazn-data.xml"/>
    and added my roles mappings from web.xml :<br>
         <security-role-mapping name="OES_admin">
              <group name="administrators"/>
         </security-role-mapping>
    <p>
    plus in proncipals.xml have created an entry for my test user:<p>
              <user username="testusr" password="test">
                   <description>Just me</description>
                   <group-membership group="users" />
                   <group-membership group="guests" />
                   <group-membership group="administrators" />
              </user>
    <p>
    And still cannot run Form-authentication from inside jdeveloper .... authentication runs fine when the app is deployed to Tomcat5
    <p>
    Help Please, I'm using jdev 10.1.2.0
    Message was edited by:
    omar71

  • Ask for help with form based authentication & authorization

    Hi:
    I encountered the following problem when I tried the form based authentication & authorization (see the attached part of the config files, web.xml, weblogic.xml & weblogic.properties)
    1. authorization seems not invoked against the rules specfied, it doesn't go the login error page as long as the user/pwd match, even though the user does not have the necessary role
    in the example below, user3 should be denied to access the signin page, but seems no login error page returned, actually I never see any page / error message which complain about the authorization / access control error
    2. after authenticate correctly, always get redirected to the / (context root) url, instead of the url prior the login page, for e.g., signin page
    Any idea ?
    Thanks in advance.
    HaiMing
    attach config files
    web.xml
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>MySecureBit1</web-resource-name>
    <description>no description</description>
    <url-pattern>/control/signin</url-pattern>
    <http-method>POST</http-method>
    <http-method>GET</http-method>
    </web-resource-collection>
    </security-constraint>
    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>default</realm-name>
    <form-login-config>
    <form-login-page>/control/formbasedlogin</form-login-page>
    <form-error-page>/control/formbasedloginerror</form-error-page>
    </form-login-config>
    </login-config>
    <security-role>
    <description>the customer role</description>
    <role-name>customer</role-name>
    </security-role>
    weblogic.xml
    <security-role-assignment>
    <role-name>
    customer
    </role-name>
    <principal-name>
    customer_group
    </security-role-assignment>
    weblogic.properties
    weblogic.password.user1=user1pass
    weblogic.password.user2=user2pass
    weblogic.password.user3=user3pass
    weblogic.security.group.customer_group=user1,user2

    Hi, Paul:
    Thanks a lot for your reply.
    Firstly let me just correct a little in the attachment I put previously, I think I missed following lines :
    <auth-constraint>
    <description>no description</description>
    <role-name>customer</role-name>
    </auth-constraint>
    So, user1 & user2 are in the customer group, but user3 not, and /control/singin is protected by this security constraint, as a result, when anyone click the link to /control/singin, he was led to the login page, if he tries to login as user1 & user2, he should pass & led to original page (in this case /control/singin, and my code's logic, once /control/signin is used, means that he already login successfully & redirected to the login success page), but if he tries to login as user3, he should only pass the authentication check, but fail the authorization check, and led to login error page.
    What not happen are :
    1. user1 & user2 pass, but redirect to /
    2. user3 also pass, because I see that debug message shows also get redirected to /, instead of login error page
    (login error page will be displayed, only if I try to login as a user with either wrong userid, or wrong password)
    3. one more thing I notice after I first time post the message, the container does not remember the principal, after 1. is done, not even for a while
    And the similar configuration works under Tomcat 3.2.1, for all 3. mentioned above.
    Any idea ?
    HaiMing
    "Paul Patrick" <[email protected]> wrote:
    If I understand what your trying to do, everyone should get access to the
    login page since roles are not
    associated with principals until after they authenticate. If I follow what
    you specified in the XML files,
    authenticated users user1 and user2 are members of a group called
    customer_group.
    The principal customer_group (and therefore its members) is mapped in the
    weblogic.xml file to the role
    customer.
    I can't speak to the reason your being redirected to the document root.
    Paul Patrick
    "HaiMing" <[email protected]> wrote in message
    news:[email protected]...
    Hi:
    I encountered the following problem when I tried the form basedauthentication & authorization (see the attached part of the config files,
    web.xml, weblogic.xml & weblogic.properties)
    1. authorization seems not invoked against the rules specfied, itdoesn't go the login error page as long as the user/pwd match, even though
    the user does not have the necessary role
    in the example below, user3 should be denied to access the signinpage, but seems no login error page returned, actually I never see any page
    / error message which complain about the authorization / access control
    error
    2. after authenticate correctly, always get redirected to the / (contextroot) url, instead of the url prior the login page, for e.g., signin page
    Any idea ?
    Thanks in advance.
    HaiMing
    attach config files
    web.xml
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>MySecureBit1</web-resource-name>
    <description>no description</description>
    <url-pattern>/control/signin</url-pattern>
    <http-method>POST</http-method>
    <http-method>GET</http-method>
    </web-resource-collection>
    </security-constraint>
    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>default</realm-name>
    <form-login-config>
    <form-login-page>/control/formbasedlogin</form-login-page>
    <form-error-page>/control/formbasedloginerror</form-error-page>
    </form-login-config>
    </login-config>
    <security-role>
    <description>the customer role</description>
    <role-name>customer</role-name>
    </security-role>
    weblogic.xml
    <security-role-assignment>
    <role-name>
    customer
    </role-name>
    <principal-name>
    customer_group
    </security-role-assignment>
    weblogic.properties
    weblogic.password.user1=user1pass
    weblogic.password.user2=user2pass
    weblogic.password.user3=user3pass
    weblogic.security.group.customer_group=user1,user2

  • Form based authentication in JSF

    Hi,
    I am using form based authentication in JSF .
    I am not able to display the JSF page.
    I have this security constraint in my web.xml
    <security-constraint>
    <display-name>Example Security Constraint</display-name>
    <web-resource-collection>
    <web-resource-name>Protected Area</web-resource-name>
    <url-pattern>/jsp/WorkingZone.jsp</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>manager</role-name>
    </auth-constraint>
    </security-constraint>
    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>Example Form-Based Authentication Area</realm-name>
    <form-login-config>
    <form-login-page>/Login/login.jsp</form-login-page>
    <form-error-page>/Login/error.jsp</form-error-page>
    </form-login-config>
    </login-config>
    WorkingZone.jsp is a jsp page with JSF components.Which can only be invoked with faces context.
    I am using JDBCRealm
    For the valid user I am getting this error------>
    HTTP Status 400 - Invalid direct reference to form login page
    type Status report
    message Invalid direct reference to form login page
    description The request sent by the client was syntactically incorrect (Invalid direct reference to form login page).
    Please give me the solution.How can I access my jsf page.

    Thank you.
    Marcos
    Hi,
    It should help you:
    http://searchsoftwarequality.techtarget.com/searchAppS
    ecurity/downloads/JSF_ch15.pdf
    Message was edited by:
    syllepsa

  • MOBI SSO with trusted authentication and form based authentication

    Dear All,
    I am trying to configure Trusted authentication based SSO FOR MOBI, here are the details:
    - SAP BI 4.1 SP04
    - Trusted authentication with HTTP header configurred for BI Launchpad and working fine.
    Now to have SSO from Mobile, I plan to leverage the existing configuration of BI Launchpad and at Mobile level, I want to use authentication type as TRUSTED_AUTH_FORM, instead of TRUSTED_AUTH_BASIC, with the approach: Trusted authentication with HTTP header.
    And
    Provide our app users their X502 certs.
    1. Will the above approach work ??
    2. As per SAP NOTE: 2038165 - SSO using form based trusted auth gives with the SAP BI app for iOS gives error MOB00920 this does not work and is still under investigation from July last year ? So for any community member, has this been found working ??
    I would appreciate your valuable inputs.
    Regards,
    Sarvjot Singh

    Hi,
    According to your post, my understanding is that you want to know the difference of the SharePoint three type user authentications.
    Windows claims-based authentication uses your existing Windows authentication provider (Active Directory Domain Services [AD DS]) to validate the credentials of connecting clients. Use this authentication to allow AD DS-based accounts access to SharePoint
    resources. Authentication methods include NTLM, Kerberos, and Basic.
    Forms-based authentication can be used against credentials that are stored in an authentication provider that is available through the ASP.NET interface
    SAML token-based authentication in SharePoint 2013 requires coordination with administrators of a claims-based environment, whether it is your own internal environment or a partner environment.
    There is a good article contains all the SharePoint Authentications, including how they work and how to configure.
    http://sp77.blogspot.com/2014/02/authentication-in-sharepoint-2013_5.html#.VFcyQ_mUfkJ
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • FORM Based Authentication and Browser Refreshing

    We are using FORM Based Authentication in our web application and it works rather well. I have noticed an interesting bit of behavior that I am unable to explain. After an attempt is made to access the first protected resource the container will display the login page specified in the web.xml file. After successful authentication the original protected resource is displayed as expected. In the Address line of the browser however the original URI requested is now replaced with the following:
    http://<domain>:<port>/<root>/j_security_check
    Now, when we hit the refresh button on the browser we get the following error:
    404 Not Found
    Resource /<domain>/j_security_check not found on this server
    Two questions. 1. why does it do this? and/or (more importantly) 2. How do I prevent this behavior or work around it?

    I�m trying to figure out how to pass the user�s ID
    and password, using form-based authentication and
    file realm, to our JDBC connection. Two separate issues.
    I've usually seen it done where there are three tiers, of course. The user provides login credentials from the view tier, which are passed to the controller tier. The controller will validate the user against a database or LDAP. Once they're validated, the credentials are put into session and provided for all apps that need them, including the persistence tier.
    The connection pool requires that you create connections using an application ID, not the user ID. You have to move the security out of the database and into the application.
    %

  • Form-based authentication and JSF

    I am trying to use a form-based authentication in Tomcat 6, and from what I understand the page that contains the login form can not be a JSF page.
    The problem I'm having with this is that I need the client's username and password accessible from my backing bean, but I don't know how to put them there from a standard JSP.
    Before all this, I had a simple login form with username/password fields that were bound to a bean, and a button that executed a bean method that would perform the login procedure, retrieve the client's data from the DB and create a Client object in the session to be accessible throughout the application. Now, I need to use container managed access control with form-based authentication, and I know how to set it up but don't know how to create the Client object if the container does all the authentication and I never even get a hold of a username/password combination let alone the rest of the client's data.
    Any advice on this would be greatly appreciated.

    alf.redo wrote:
    ...following article: [j2ee_security_a_jsf_based_login_form|http://groundside.com/blog/DuncanMills.php?title=j2ee_security_a_jsf_based_login_form]
    This is exactly the solution I am planning to use. It is good to know there are others who have decided to go that way.
    Thanks

Maybe you are looking for

  • Manual restore from a Time Machine backup from a failing disk?

    The hard drive on the iMac seemed to be having issues.  I called apple and they said to bring it in for a hard drive (recalled) replacement.  So, I unplugged the TimeMachine backup drive, and took the iMac in to have the hard drive replaced.  When I

  • Moving hard drive to another computer?

    I currently have an older G5 tower. It appears the power supply has finally given out after years of extensive use. I'm thinking this may be a good time for me to upgrade and purchase a Mac Pro. However, I'm not quite sure how to move the data from m

  • Is that adapter 1394 the same as firewire or i-link?

    Hello, i have a neo2 and i´m trying connect my mini dv video camera to the back conector with a firewire cable but i can´t find the camera or i don´t know how to do it. Anyone of you can tell me where can i found information in order to configure it.

  • Button and/or Chapter Limit?

    Is there a limit to the number of chapters I can have in a single timeline? Is there a limit to the number of buttons I can have on a single menu? Where are the answers (if there are any) to these questions documented? Steve Cohen

  • HT201304 Changing banking details in App Store

    How do I change my banking account info