Results 1 to 5 of 5

Thread: X509AuthenticationFilter

  1. #1
    Join Date
    Mar 2007
    Posts
    561

    Default X509AuthenticationFilter

    Hi,

    I'm using spring sec 3.0. When I set up a X509AuthenticationFilter via <sec:x509 user-service-ref="userDetailsService" subject-principal-regex="CN=(.*?)," /> and the X509PrincipalExtractor cannot extract the principal from the certificate an exception is thrown and the auth filter chains stops processing.

    Shouldn't continueFilterChainOnUnsuccessfulAuthentication step in here and if set to true continue to process the chain?

    How can I handle this situation?

    Thank you

  2. #2
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Just curious, what exception is being thrown, from where? Looking at the code, it seems you're right, that if getPreAuthenticatedPrincipal throws an exception, it isn't handled by logic that incorporates continueFilterChainOnUnsuccessfulAuthentication.

    I could see an argument that "continueFilterChainOnUnsuccessfulAuthenticati on" isn't technically applicable here, since that flag is supposed to check for failed authentication, not bad (invalid) credentials, but regardless, it seems like this should be behavior that you should be able to toggle. I'd suggest filing a JIRA with this suggestion.

    In the meantime, you could implement your own subclass of X509AuthenticationFilter with logic to handle this situation and just configure it as a custom filter, replacing the standard X.509 filter.
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  3. #3
    Join Date
    Mar 2007
    Posts
    561

    Default

    Quote Originally Posted by pmularien View Post
    Just curious, what exception is being thrown, from where?
    SubjectDnX509PrincipalExtractor throws exceptions if it cannot extract the username.

    I think I will extend it and return null in this case. Bad idea?

  4. #4
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    I think that should be sufficient - note that in that case (returning null), continuing on the filter chain is implied and not explicitly controlled by the boolean flag you mentioned (so don't be surprised if you later set it to false and it still continues).
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  5. #5
    Join Date
    Mar 2007
    Posts
    561

    Default

    Hm, now I'm a little bit lost...
    I have no clue how to set up a X509AuthenticationFilter...
    The step where it breaks is when I try to setup the authenticationManager for this filter.

Posting Permissions

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