Results 1 to 5 of 5

Thread: isAuthenticated() is always false.

Hybrid View

  1. #1

    Default isAuthenticated() is always false.

    Hi All,
    I am using the UsernamePasswordAuthenticationToken for authentication. I can see the following in the log

    =================================================

    [java] 2005-03-16 14:35:09,054 DEBUG org.springframework.jdbc.core.StatementCreatorUtil s - Setting SQL statement parameter value: columnIndex 1, parameter value [testuser], valueClass [java.lang.String], sqlType 12
    [java] 2005-03-16 14:35:09,054 DEBUG org.springframework.jdbc.datasource.DataSourceUtil s - Closing JDBC connection
    [java] 2005-03-16 14:35:09,054 DEBUG org.springframework.context.support.ClassPathXmlAp plicationContext - Publishing event in context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=25699763]: net.sf.acegisecurity.providers.dao.event.Authentic ationSuccessEvent[source=net.sf.acegisecurity.providers.UsernamePass wordAuthenticationToken@c9630a: Username: testuser; Password: [PROTECTED]; Authenticated: false; Details: null; Not granted any authorities]
    ==============================================

    There is an AuthenticationSuccessEvent but the Authenticated property still shows false. When and how does the authenticated property be set to true?


    Any ideas??

    Thanks in advance

  2. #2
    Join Date
    Sep 2004
    Posts
    50

    Default

    This sounds like a very similar problem to my post ref:

    upgrading 0.8.0 Null authentication SecureContextImpl

  3. #3
    Join Date
    Feb 2005
    Posts
    24

    Default

    Just looked at the source for DaoAuthenticationProvider and UsernamePasswordAuthenticationToken...

    Basically it looks like on a successful auth, the DaoAuthenticationProvider is simply returning a new UsernamePasswordAuthenticationToken with the same exact properties you supplied in the first place. It never runs setAuthenticated(). I'd say this is a bug.

    Here's the method in question from DaoAuthenticationProvider:
    (the authentication passed in is the original Authentication object)
    Code:
    protected Authentication createSuccessAuthentication(Object principal,
            Authentication authentication, UserDetails user) {
            // Ensure we return the original credentials the user supplied,
            // so subsequent attempts are successful even with encoded passwords.
            // Also ensure we return the original getDetails(), so that future
            // authentication events after cache expiry contain the details
            UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(principal,
                    authentication.getCredentials(), user.getAuthorities());
            result.setDetails((authentication.getDetails() != null)
                ? authentication.getDetails() : null);
    
            return result;
        }

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

  5. #5
    Join Date
    Feb 2005
    Posts
    24

    Default

    thanks.
    that makes some more sense.

Similar Threads

  1. Why Authenticated is false
    By Zhukov2004 in forum Security
    Replies: 10
    Last Post: Oct 24th, 2007, 11:46 AM
  2. Replies: 1
    Last Post: Jun 24th, 2005, 10:35 PM
  3. Replies: 4
    Last Post: May 29th, 2005, 07:39 AM
  4. Replies: 2
    Last Post: Dec 24th, 2004, 08:02 AM
  5. sessionForm=true or false ?
    By sds in forum Web
    Replies: 0
    Last Post: Dec 9th, 2004, 03:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •