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.

Comment From: MarianConstantinMarica

Can I work on this?

Comment From: jan-knoblich

@jzheaux could you assign this to me?