public class

SubjectDnX509PrincipalExtractor

extends Object
implements X509PrincipalExtractor
java.lang.Object
   ↳ org.springframework.security.web.authentication.preauth.x509.SubjectDnX509PrincipalExtractor

Class Overview

Obtains the principal from a certificate using a regular expression match against the Subject (as returned by a call to getSubjectDN()).

The regular expression should contain a single group; for example the default expression "CN=(.?)," matches the common name field. So "CN=Jimi Hendrix, OU=..." will give a user name of "Jimi Hendrix".

The matches are case insensitive. So "emailAddress=(.?)," will match "EMAILADDRESS=jimi@hendrix.org, CN=..." giving a user name "jimi@hendrix.org"

Summary

Fields
protected final Log logger
protected MessageSourceAccessor messages
Public Constructors
SubjectDnX509PrincipalExtractor()
Public Methods
Object extractPrincipal(X509Certificate clientCert)
Returns the principal (usually a String) for the given certificate.
void setMessageSource(MessageSource messageSource)
void setSubjectDnRegex(String subjectDnRegex)
Sets the regular expression which will by used to extract the user name from the certificate's Subject DN.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.security.web.authentication.preauth.x509.X509PrincipalExtractor

Fields

protected final Log logger

protected MessageSourceAccessor messages

Public Constructors

public SubjectDnX509PrincipalExtractor ()

Public Methods

public Object extractPrincipal (X509Certificate clientCert)

Returns the principal (usually a String) for the given certificate.

public void setMessageSource (MessageSource messageSource)

public void setSubjectDnRegex (String subjectDnRegex)

Sets the regular expression which will by used to extract the user name from the certificate's Subject DN.

It should contain a single group; for example the default expression "CN=(.?)," matches the common name field. So "CN=Jimi Hendrix, OU=..." will give a user name of "Jimi Hendrix".

The matches are case insensitive. So "emailAddress=(.?)," will match "EMAILADDRESS=jimi@hendrix.org, CN=..." giving a user name "jimi@hendrix.org"

Parameters
subjectDnRegex the regular expression to find in the subject