Skip to content

Commit 2b740b7

Browse files
committed
Update SubjectX500PrincipalExtractor Javadoc
- Provide more details on how the principalName is extracted - Update to specify an OID is used for emailAddress
1 parent f690a7f commit 2b740b7

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

web/src/main/java/org/springframework/security/web/authentication/preauth/x509/SubjectX500PrincipalExtractor.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
import org.springframework.util.Assert;
3535

3636
/**
37-
* Obtains the principal from a certificate using RFC2253 and RFC1779 formats. By default,
38-
* RFC2253 is used: DN is extracted from CN. If extractPrincipalNameFromEmail is true then
39-
* format RFC1779 will be used: DN is extracted from EMAIlADDRESS.
37+
* Extracts the principal from the {@link X500Principal#getName(String)} returned by
38+
* {@link X509Certificate#getSubjectX500Principal()} passed into
39+
* {@link #extractPrincipal(X509Certificate)} depending on the value of
40+
* {@link #setExtractPrincipalNameFromEmail(boolean)}.
4041
*
4142
* @author Max Batischev
4243
* @author Rob Winch
@@ -80,8 +81,26 @@ public void setMessageSource(MessageSource messageSource) {
8081
}
8182

8283
/**
83-
* If true then DN will be extracted from EMAIlADDRESS, defaults to {@code false}
84-
* @param extractPrincipalNameFromEmail whether to extract DN from EMAIlADDRESS
84+
* Sets if the principal name should be extracted from the emailAddress or CN
85+
* attribute (default).
86+
*
87+
* By default, the format {@link X500Principal#RFC2253} is passed to
88+
* {@link X500Principal#getName(String)} and the principal is extracted from the CN
89+
* attribute as defined in
90+
* <a href="https://datatracker.ietf.org/doc/html/rfc2253#section-2.3">Converting
91+
* AttributeTypeAndValue of RFC2253</a>.
92+
*
93+
* If {@link #setExtractPrincipalNameFromEmail(boolean)} is {@code true}, then the
94+
* format {@link X500Principal#RFC2253} is passed to
95+
* {@link X500Principal#getName(String)} and the principal is extracted from the
96+
* <a href="https://oid-base.com/get/1.2.840.113549.1.9.1">OID.1.2.840.113549.1.9.1
97+
* (emailAddress)</a> attribute as defined in
98+
* <a href="https://datatracker.ietf.org/doc/html/rfc1779#section-2.3">Section 2.3 of
99+
* RFC1779</a>.
100+
* @param extractPrincipalNameFromEmail whether to extract the principal from the
101+
* emailAddress (default false)
102+
* @see <a href="https://datatracker.ietf.org/doc/html/rfc2253">RFC2253</a>
103+
* @see <a href="https://datatracker.ietf.org/doc/html/rfC1779">RFC1779</a>
85104
*/
86105
public void setExtractPrincipalNameFromEmail(boolean extractPrincipalNameFromEmail) {
87106
if (extractPrincipalNameFromEmail) {

0 commit comments

Comments
 (0)