Better API support for setting algorithm constraints to JwtConsumerBuilder

Issue #154 closed
Marcin Nowak created an issue

As a developer I' like to have simpler API for adding algorithm constraints to JwtConsumerBuilder. Current interface exposes internal implementation and is forcing to use AlgorithmConstraints as parameter.

JwtConsumerBuilder builder = new JwtConsumerBuilder()
  .setJwsAlgorithmConstraints(new AlgorithmConstraints(AlgorithmConstraints.ConstraintType.WHITELIST, AlgorithmIdentifiers.RSA_USING_SHA256))

Above code can be found in many places: https://www.programcreek.com/java-api-examples/?api=org.jose4j.jwt.consumer.JwtConsumerBuilder

One of proposition to make it simpler is to add additional method with the same parameters as in AlgorithmConstraints constructor:

JwtConsumerBuilder builder = new JwtConsumerBuilder()
  .setJwsAlgorithmConstraints(AlgorithmConstraints.ConstraintType.WHITELIST, AlgorithmIdentifiers.RSA_USING_SHA256)

Comments (3)

  1. Log in to comment