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

Builder NestedCollection support #841

Merged
merged 6 commits into from
Sep 29, 2023
Merged

Builder NestedCollection support #841

merged 6 commits into from
Sep 29, 2023

Conversation

lhazlewood
Copy link
Contributor

Various collection properties exist on JwtParserBuilder, JwkBuilder, ClaimsMutator (audience), etc, and they are a pain to consistently represent across builders, with forced overloaded methods (set a single value, set a collection), and currently none of them have the ability to remove or clear existing entries if desired. The likelihood of one builder representing overloaded methods one way and another a different way is high and that possibility should be reduced/eliminated.

This PR enables a consistent collection property mutator design concept that works across all builders with collection properties, and eliminates the need for inconsistent and/or numerous overloaded methods for a cleaner/easier-to-read API.

For example:

  • ClaimsMutator's audience(String), audience(Collection) and audienceSingle(String) are removed in favor of a single audience() sub-builder
  • JwkBuilder operations(KeyOperation) and operations(Collection) are removed in favor of an operations() sub-builder
  • ProtectedHeaderMutator -> critical() sub-builder for applied critical header parameter names
  • JwtParserBuilder
    • critical(): sub-builder for supported critical header parameters
    • zip(): sub-builder for compression algorithm customization
    • enc() sub-builder for encryption algorithm customization
    • sig(): sub-builder for signature and mac algorithm customization
    • key(): sub-builder for key algorithm customization

These latter zip(), enc(), sig() and key() method names were chosen to parallel the Jwts.ZIP, Jwts.ENC, Jwts.SIG and Jwts.KEY registries

- Added JwkBuilder#operations() NestedCollection builder and removed #operation(KeyOperation) and #operations(Collection<KeyOperation>)
- KeyOperationPolicyBuilder now extends CollectionMutator
@lhazlewood lhazlewood added this to the 0.12.0 milestone Sep 28, 2023
@lhazlewood lhazlewood self-assigned this Sep 28, 2023
@lhazlewood lhazlewood merged commit 854bb89 into master Sep 29, 2023
19 checks passed
@lhazlewood lhazlewood deleted the cbuilders branch September 29, 2023 20:42
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.

1 participant