Skip to content
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-3793 certificate group mapping #4272

Merged
merged 2 commits into from
Oct 22, 2019
Merged

PAYARA-3793 certificate group mapping #4272

merged 2 commits into from
Oct 22, 2019

Conversation

dmatej
Copy link
Contributor

@dmatej dmatej commented Oct 12, 2019

Description

This is a feature allowing group and role mapping based on the certificate's DN parts.

Important Info

Blockers

#4263 - contains test for the CertificateRealm

Testing

New tests

CertificateRealmITest

Testing Performed

Test suites executed

  • Quicklook - OK
  • Payara Samples - ?
  • Java EE7 Samples - OK
  • Java EE8 Samples - ?
  • Payara Private Tests - OK
  • Payara Microprofile TCKs Runner - ?
  • Jakarta TCKs - ?
  • Mojarra - ?
  • Cargo Tracker - ?

Testing Environment

Kubuntu 19.04

@dmatej
Copy link
Contributor Author

dmatej commented Oct 12, 2019

Jenkins test please

@dmatej dmatej changed the title Payara 3793 certificate role mapping Payara 3793 certificate group mapping Oct 15, 2019
@dmatej dmatej marked this pull request as ready for review October 18, 2019 21:16
@dmatej
Copy link
Contributor Author

dmatej commented Oct 18, 2019

Jenkins test please

@dmatej dmatej self-assigned this Oct 18, 2019
@dmatej dmatej requested a review from Pandrex247 October 18, 2019 21:24
@dmatej
Copy link
Contributor Author

dmatej commented Oct 20, 2019

Jenkins test please

@MarkWareham MarkWareham changed the title Payara 3793 certificate group mapping PAYARA-3793 certificate group mapping Oct 21, 2019
Copy link
Contributor

@cubastanley cubastanley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, just these final variable names - pretty sure its a Payara convention for final variables to have names in the format VARIABLE_NAME rather than standard camel case. There are more than the one's I've highlighted - Approved anyway as it's purely cosmetic but it is a convention that I feel should be followed

Comment on lines +62 to +63
private final boolean useCertificate;
private final SecurityContext securityContext;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency these variables should be refactored to reflect the fact that they're constant (i.e. USE_CERTIFICATE)

Copy link
Contributor Author

@dmatej dmatej Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not constants! They are only final, not static final. They don't change for the life of the instance, but each instance has it's own field ;)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have a naming rule in sonar for class level private final fields, we do for public final fields and for private final static fields, so technically David is right 😄. Confusingly, we do have a naming rule for local final fields (https://sonarcloud.io/organizations/payara/rules?languages=java&open=squid%3AS4174&q=final&tags=convention)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah no David's point makes sense I'm happy for it to stay as is ( ͡~ ͜ʖ ͡°)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlanRoth Interesting rule, I'm sure not standard and it may start great confusion, perhaps that's why it is not active in any profile :D
Nice example is here: https://softwareengineering.stackexchange.com/questions/252243/naming-convention-final-fields-not-static

Comment on lines +151 to +156
private final String prname;
private final String name;
private final Codec codec;
private final SecurityContextUtil secContextUtil;
private final GlassFishORBHelper orbHelper;
private final SecurityMechanismSelector smSelector;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment

*
* @author Harish Prabandham
*/
public class Group extends PrincipalImpl {


private static final long serialVersionUID = -3087471149205106412L;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor

@pzygielo pzygielo Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Hmmm. Same as above -> about upper/camel case?
(There is no freedom in choosing this name, it's specified by Serializable).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmatej dmatej added the PR: DO NOT MERGE Don't merge PR until further notice label Oct 21, 2019
final LdapName dn = getLdapName(principal);
_logger.log(Level.FINE, "dn={0}", dn);
final String principalName = getPrincipalName(dn);
_logger.log(Level.FINE, "Certificate realm is setting up security context for principal: '{0}'", principalName);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tricky bug ... apostrophes in '{0}' prevent replacement of the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to hate JUL pretty much ... :-(
And I know one way how to speed up anything in Payara :D

David Matejcek added 2 commits October 22, 2019 10:01
- automatic, semiautomatic and manual changes
- reduced visibility of realm.init methods to same as in parent
- some comments changed to javadocs
- enhanced loops (automatically)
- removed copypasted javadocs, removed commented out code
- correct generics on some places

- OIDs class transformed to OID enum
- JDBCRealm
  - renamed cr to connectorRuntimeDescriptor
- PamRealm
  - deprecated PAM.getGroupsOfUser method replaced with it's content:
    new UnixUser(username).getGroups()
- BaseRealm
  - removed deprecated constant - copy from parent class.
- AbstractStatefulRealm
  - addAssignGroups reimplemented
- ClientCertificateLoginModule
  - reduced logging complexity
  - removed redundant catch block
- LoginException
  - added constructor with cause
- CertificateRealm
  - OID_MAP moved to OID enum
  - using same constant for realm property: COMMON_NAME_AS_PRINCIPAL_NAME
- Util
  - removed getDefaultHabitat method - potential cause of NPE if called sooner
    than Globals initialized. Replaced with direct usage of Globals.
- realm can be configured to use some parts of DN as group names
@dmatej dmatej removed the PR: DO NOT MERGE Don't merge PR until further notice label Oct 22, 2019
@dmatej
Copy link
Contributor Author

dmatej commented Oct 22, 2019

Jenkins test please

@dmatej dmatej merged commit e97caae into payara:master Oct 22, 2019
@dmatej dmatej deleted the PAYARA-3793-certificate-role-mapping branch October 22, 2019 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants