Results 1 to 7 of 7

Thread: How to get User details

  1. #1

    Default How to get User details

    Hi,

    I'm new to Acegi.
    I would like to access some properties for the user using the authz:authentication tag.

    I subclassed JdbcDaoImpl to add the new sql statement but now I cannot go further.

    Could anybody tell me exactly what should be modified to achieve my purpose?

    Complete samples would be great.

    Thanks

    LuKe

  2. #2
    Join Date
    Jul 2005
    Location
    Munich, Germany
    Posts
    153

    Default

    Quote Originally Posted by lukeb
    I would like to access some properties for the user using the authz:authentication tag.
    From the Acegi documentation:

    1.7.4.2. AuthenticationTag

    AuthenticationTag is used to simply output a property of the current principal's Authentication.getPrincipal() object to the web page.

    The following JSP fragment illustrates how to use the AuthenticationTag:

    <authz:authentication operation="username"/>

    This tag would cause the principal's name to be output. Here we are assuming the Authentication.getPrincipal() is a UserDetails object, which is generally the case when using the typical DaoAuthenticationProvider.


    HTH
    Oliver

  3. #3
    Join Date
    Feb 2006
    Posts
    8

    Default

    hi, in reference to the above answer.................

    <authz:authentication operation="username"/> only seems to work with the User object (implemening userdetails) properties. But if a nested object exists then can we not use the tag to access that particular property??

    e.g.
    <authz:authentication operation="username.address.line1"/> ??

    Address for sure is not null when I check but the tag cannot seem to render nested properties like the standard jstl c tag.

    If I remove the nested property line1 then it picks up the address property but renders this as null? But it isnt.

    Any ideas????

    bets wishes

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

    Default

    The authz tag doesn't support nesting. Please feel free to add a patch and unit tests to JIRA if you require this functionality.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  5. #5
    Join Date
    May 2006
    Posts
    1

    Default

    According to the documentation the AuthenticationTag invokes methods on the object returned by Authentication.getPrincipal(). However, both the AuthenticationProcessingFilter and the SiteminderAuthenticationProcessingFilter set a simple username String as the principal in the attemptAuthentication method with no clean way to override this behavior.

    I would request a method in the AuthenticationProcessingFilter called something like obtainPrincipal to allow for an easy mechanism to override what object is set as the principal.

    Here is an optional default implementation:

    protected Object obtainPrincipal(String username) {
    return username;
    }
    Last edited by ajrobinson; May 16th, 2006 at 11:56 AM.

  6. #6
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    AuthenticationProcessingFilter doesn't set the principal to be a String in attemptAuthentication(). The code for the method is here:

    http://acegisecurity.org/multiprojec...Filter.html#59

    It uses whatever is returned by the authentication manager as the principal object. Typically this will be a UserDetails object, as returned from the authenticate method of AbstractUserDetailsManager:

    http://acegisecurity.org/multiprojec...vider.html#199

    (Usually a concrete instance of DaoAuthenticationProvider).

    You can override the createSuccessAuthentication() method or specialse the UserDetailsService that is used to further customise the contents of the Authentication object that is returned.

  7. #7
    Join Date
    Apr 2006
    Posts
    8

    Default

    Quote Originally Posted by Ben Alex
    The authz tag doesn't support nesting. Please feel free to add a patch and unit tests to JIRA if you require this functionality.
    I need this feature. Is it implemented yet ?

    Thanks.

Posting Permissions

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