Skip to content

NimbusJwtEncoder should simplify constructing with javax.security Keys #16267

Closed
@jzheaux

Description

@jzheaux

Currently to construct a NimbusJwtEncoder with a single key takes something like the following:

OctetSequenceKey jwk = new OctetSequenceKeyGenerator(256)
    .keyID(UUID.randomUUID().toString())
    .algorithm(JWSAlgorithm.HS256)
    .issueTime(new Date())
    .generate();
JWKSource<SecurityContext> source = new ImmutableJWKSet<>(new JWKSet(jwk));
NimbusJwtEncoder encoder = new NimbusJwtEncoder(source);

whereas to do the converse in NimbusJwtDecoder is simpler:

NimbusJwtDecoder decoder = NimbusJwtDecoder.withSecretKey(key).build();

It would be nice if NimbusJwtEncoder offered similar behavior:

SecretKey key = ...
NimbusJwtEncoder.withSecretKey(key).build(); // or
NimbusJwtEncoder.withSecretKey(key).keyId(...).build(); // etc.

KeyPair keyPair = ... // RSA or EC
NimbusJwtEncoder.withKeyPair(keyPair).build(); // or
NimbusJwtEncoder.withKeyPair(keyPair).keyId(...).build(); // etc.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions