Results 1 to 5 of 5

Thread: How to retrieve userid having colon in spring security

  1. #1
    Join Date
    Jul 2011
    Posts
    21

    Question How to retrieve userid having colon in spring security

    I have a user id = "tel:123" and password="code", and when i retrieve the user id from authentication object i get only "tel" as user id and password as "123:code".
    It seems spring security uses ":" as delimiter to separate user id and password.

    So could you please help me out how I can retrieve the user id correctly with colon.

    Comments are highly appreciated.

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

    Default

    No, the username and password are not stored in the same field or delimited by a colon. How is the Authentication object being created - what are you authenticating against?
    Spring - by Pivotal
    twitter @tekul

  3. #3
    Join Date
    Jul 2011
    Posts
    21

    Default

    Thanks Luke for the response,

    I am using customized authentication provider class which implements "AuthenticationProvider" interface.

    And implementing the method :

    # public Authentication authenticate(Authentication authentication) throws AuthenticationException {

    I am just getting the values from the authentication object, which is being set by the framework.

    I get user id and password as given:

    # Object obj = authentication.getPrincipal();
    # if (obj instanceof UserDetails) {
    # username = ((UserDetails) obj).getUsername();
    # password = ((UserDetails) obj).getPassword();
    # } else {
    # username = obj.toString();
    # password = obj.toString();
    # }
    Last edited by rc123; Jul 29th, 2011 at 02:25 AM.

  4. #4
    Join Date
    Jul 2011
    Posts
    21

    Default

    Hi Luke I have provided the details and am using basic authentication.
    So what i guess is basic authentication scheme uses a colon as a separator between username and password.

    From the header i got this: Authorization: Basic dGVsOjEyMzpQYXNzd29yZDEh
    This is a Base64 encoded value and it uses delimiter to separate username and password.

    When base64 decoded ,looks like

    Authorization: tel : 123:Password



    Could you please give some inputs.

    Thanks
    Last edited by rc123; Aug 2nd, 2011 at 02:00 AM.

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

    Default

    The user ID isn't allowed to contain a colon if you are using Basic authentication. Check the RFC (page 5).
    Spring - by Pivotal
    twitter @tekul

Posting Permissions

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