Skip to Content
author's profile photo Former Member
Former Member

user.isAuthenticated() returns "False"

Hi everybody,

I´m trying to use this code:

IUser user = (IUser) componentRequest.getServletRequest().getAttribute("user");

if (user.isAuthenticated()) {

....

}

in my .jsp (PDK6 SP2), but it returns "false" when it´s supposed to return "true".

In my doProcessBeforeOutput() method I have something like this:

...

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

...

try {

IUserManagementService umService = (IUserManagementService) request.getService(IUserManagementService.KEY);

IUserFactory userFactory = umService.getDefaultFactory();

user = userFactory.getUser(request.getUser().getLogonUid());

} catch (UserManagementException ex) {

...

}

...

request.getServletRequest().setAttribute("user", user);

I´m using the usermanagement service as the documentation says. Am I missing something? Can I test it with the Component Inspector in PDK 6 (Java Development Role)? Do I have to configure some special property in my portal?

Thanks for Your help.

Susy.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Feb 14, 2005 at 06:10 PM

    Hi Susy,

    the method returns what it is expected to return. The IUser object you get from the request is constructed by the userFactory. From this you get an unauthenticated IUser object. How should anyone in this line know that the user is authenticated. You cut off all auth information when passing the logon ID.

    With other words: From the component request you get an IUser (authenticated!). From this you get the logon ID - a String. Now you ask the IUserFactory to return the IUser object corresponding to this logon ID. The IUserFactory says: "OK, I don't know what you want to do with it, but here it is; all I can say about this User is that (s)he exists." And <i>this</i> IUser object for sure is <i>not</i> authenticated.

    With this understood, you have solution at the same time: You can delete all the superfluous code and within your JSP just ask

    IUser user = (IUser) componentRequest.getUser();
    if (user.isAuthenticated()) {
    ....
    }

    On the other hand, it is hard to imagine how the user object comes into the componentrequest without being authenticated...

    Hope it helps

    Detlev

    PS: Please consider rewarding points for helpful answers. Thanks in advance!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.