-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PAYARA-3789 Unify DN Representation #4042
Merged
Pandrex247
merged 11 commits into
payara:master
from
Pandrex247:PAYARA-3789-Unify-DN-Representation
Jun 17, 2019
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8b4a2d1
PAYARA-3789 Unify DN output and allow EMAILADDRESS
Pandrex247 00f2eca
PAYARA-3789 Don't use deprecated methods
Pandrex247 5f8551c
PAYARA-3789 Add more robust name generation
Pandrex247 a48c875
Remove unused imports
Pandrex247 8ebfbec
PAYARA-3789 Make sure all usages are in the same format
Pandrex247 c1ce43e
PAYARA-3789 Another missed getName
Pandrex247 143eb93
PAYARA-3789 Don't use variables from class
Pandrex247 93af14b
PAYARA-3789 Move OIDs into constants class
Pandrex247 1f96686
PAYARA-3789 Correct DN attribute name
Pandrex247 9e5d6ae
Merge branch 'master' of https://github.com/payara/Payara into PAYARA…
Pandrex247 9611222
PAYARA-3789 Variable formatting
Pandrex247 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,10 @@ | |
import java.security.Principal; | ||
import java.util.Collections; | ||
import java.util.Enumeration; | ||
import java.util.HashMap; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
import java.util.Set; | ||
|
||
|
@@ -101,7 +103,32 @@ public final class CertificateRealm extends BaseRealm { | |
|
||
// Descriptive string of the authentication type of this realm. | ||
public static final String AUTH_TYPE = "certificate"; | ||
|
||
public static final Map<String, String> oidMap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OID_MAP as name? |
||
static { | ||
Map<String, String> oidMapInitialiser = new HashMap<>(); | ||
oidMapInitialiser.put("0.9.2342.19200300.100.1.1", "UID"); | ||
oidMapInitialiser.put("0.9.2342.19200300.100.1.25", "DC"); | ||
oidMapInitialiser.put("1.2.840.113549.1.9.1", "EMAIL"); | ||
oidMapInitialiser.put("1.2.840.113549.1.9.1", "EMAILADDRESS"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate, so always EMAILADDRESS used and never EMAIL. |
||
oidMapInitialiser.put("1.3.6.1.4.1.42.2.11.2.1", "IP"); | ||
oidMapInitialiser.put("2.5.4.3", "CN"); | ||
oidMapInitialiser.put("2.5.4.4", "SURNAME"); | ||
oidMapInitialiser.put("2.5.4.5", "SERIALNUMBER"); | ||
oidMapInitialiser.put("2.5.4.6", "C"); | ||
oidMapInitialiser.put("2.5.4.7", "L"); | ||
oidMapInitialiser.put("2.5.4.8", "S"); | ||
oidMapInitialiser.put("2.5.4.8", "ST"); | ||
Pandrex247 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
oidMapInitialiser.put("2.5.4.9", "STREET"); | ||
oidMapInitialiser.put("2.5.4.10", "O"); | ||
oidMapInitialiser.put("2.5.4.11", "OU"); | ||
oidMapInitialiser.put("2.5.4.12", "T"); | ||
oidMapInitialiser.put("2.5.4.42", "GIVENNAME"); | ||
oidMapInitialiser.put("2.5.4.43", "INITIALS"); | ||
oidMapInitialiser.put("2.5.4.44", "GENERATION"); | ||
oidMapInitialiser.put("2.5.4.46", "DNQUALIFIER"); | ||
oidMap = Collections.unmodifiableMap(oidMapInitialiser); | ||
arjantijms marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
private List<String> defaultGroups = new LinkedList<>(); | ||
|
||
/** | ||
|
@@ -175,8 +202,8 @@ public Enumeration<String> getGroupNames(String username) throws NoSuchUserExcep | |
public String authenticate(Subject subject, X500Principal callerPrincipal) { | ||
// It is important to use X500Principal.getName() as that will | ||
// return the LDAP name in RFC2253 | ||
String callerPrincipalName = callerPrincipal.getName(); | ||
String callerPrincipalName = callerPrincipal.getName(X500Principal.RFC2253, oidMap); | ||
|
||
// Checks if the property for using common name is set | ||
if (Boolean.valueOf(getProperty("useCommonName"))) { | ||
callerPrincipalName = extractCN(callerPrincipalName); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using
getName(X500Principal.RFC2253, CertificateRealm.oidMap)
several times. Make a utility method so that X500Principal representation is only in 1 place for future?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that's really worth it? Unless I'm misunderstanding you we'd just be replacing
certificates[0].getSubjectX500Principal().getName(X500Principal.RFC2253, CertificateRealm.oidMap)
withCertificateRealm.getX500PrincipalSubjectName(certificates[0])
.It seems fragile to me to store the name of the certificate somewhere outside of the actual certificate itself.
Also, it isn't strictly necessary for me to put the full X500Principal.RFC2253 stuff everywhere, it's me just being safe. From my testing as long as you get the name in this manner from the
CertificateRealm
it propagates outward such that simply doinggetName()
will still have the OIDs translated.