Class SubjectDnX509PrincipalExtractor
- java.lang.Object
-
- org.springframework.security.web.authentication.preauth.x509.SubjectDnX509PrincipalExtractor
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.MessageSourceAware,X509PrincipalExtractor
public class SubjectDnX509PrincipalExtractor extends java.lang.Object implements X509PrincipalExtractor, org.springframework.context.MessageSourceAware
Obtains the principal from a certificate using a regular expression match against the Subject (as returned by a call toX509Certificate.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"
-
-
Constructor Summary
Constructors Constructor Description SubjectDnX509PrincipalExtractor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectextractPrincipal(java.security.cert.X509Certificate clientCert)Returns the principal (usually a String) for the given certificate.voidsetMessageSource(org.springframework.context.MessageSource messageSource)voidsetSubjectDnRegex(java.lang.String subjectDnRegex)Sets the regular expression which will by used to extract the user name from the certificate's Subject DN.
-
-
-
Method Detail
-
extractPrincipal
public java.lang.Object extractPrincipal(java.security.cert.X509Certificate clientCert)
Description copied from interface:X509PrincipalExtractorReturns the principal (usually a String) for the given certificate.- Specified by:
extractPrincipalin interfaceX509PrincipalExtractor
-
setSubjectDnRegex
public void setSubjectDnRegex(java.lang.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
-
setMessageSource
public void setMessageSource(org.springframework.context.MessageSource messageSource)
- Specified by:
setMessageSourcein interfaceorg.springframework.context.MessageSourceAware- Since:
- 5.5
-
-