Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ADF Login Page Issue with ADF Security

aJohnyFeb 28 2015 — edited Feb 28 2015

Hi all,

I have created a login page using Jdeveloper 12c. I created this based on a login video demo from youtube. (https://www.youtube.com/watch?v=mAWBezngA1s)

When I tried to enter username and password and click on login button, the login page just gets refreshed and not getting re-directed to the welcome page (protected.jsf).

The code which gets executed when clicking on the login button is as below.

In the Jdeveloper console I can see "Coming Here...." is getting printed. "Coming Here...."

    public String doLogin() {

        String un = userName;

        byte[] pw = password.getBytes();

        FacesContext ctx = FacesContext.getCurrentInstance();

        HttpServletRequest request = (HttpServletRequest) ctx.getExternalContext().getRequest();

        Subject mySubject;

        try {

            mySubject = Authentication.login(new URLCallbackHandler(un, pw));

            ServletAuthentication.runAs(mySubject, request);

            ServletAuthentication.generateNewSessionID(request);

            String loginUrl = "/adfAuthentication?success_url=/faces/protected.jsf";

            HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();

            RequestDispatcher requestDispatcher = request.getRequestDispatcher(loginUrl);

            requestDispatcher.forward(request, response);

            System.out.println("Coming Here....");

        } catch (FailedLoginException e) {

            FacesMessage msg =

                new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid username or password",

                                 "Invalid username or password");

            ctx.addMessage(null, msg);

        } catch (Exception e) {

            System.out.println("In Exception....");

            FacesMessage msg =

                new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error caught in Exception", "Error caught in Exception");

            ctx.addMessage(null, msg);

        }

        return null;

    }

I have created the User --> Enterprise Role --> Application Role. Also granted the protected.jsf page to the newly created application role.

I tried to replace "protected.jsf" to "xyz.jsf" (expected to get some error as there is no page called xyz.jsf), but the screen just refreshes, not throwing any error also.

Could you please let me know what could be wrong.

Let me know if I need to provide any further details.

Cheers

AJ

This post has been answered by kdario on Feb 28 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 28 2015
Added on Feb 28 2015
7 comments
1,397 views