style(simple-jwt): Upgraded method to get Algorithm declared in third-party implementation.
This commit is contained in:
+1
-1
@@ -140,7 +140,7 @@ public class AuthzeroTokenResolver implements TokenResolver<DecodedJWT> {
|
||||
throw new IllegalArgumentException("A secret is required to build a JSON Web Token.");
|
||||
}
|
||||
this.jtiCreator = jtiCreator;
|
||||
this.algorithm = AuthzeroTokenResolverConfig.getInstance().getFunction(algorithm).apply(secret);
|
||||
this.algorithm = AuthzeroTokenResolverConfig.getInstance().getAlgorithm(algorithm).apply(secret);
|
||||
this.issuer = issuer;
|
||||
this.verifier = JWT.require(this.algorithm).build();
|
||||
}
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ public final class AuthzeroTokenResolverConfig implements TokenResolverConfig<Fu
|
||||
* implementation
|
||||
*/
|
||||
@Override
|
||||
public Function<String, Algorithm> getFunction(TokenAlgorithm algorithm) {
|
||||
public Function<String, Algorithm> getAlgorithm(TokenAlgorithm algorithm) {
|
||||
return Optional.of(SUPPORTED_ALGORITHMS).map((entry) -> entry.get(algorithm))
|
||||
.orElseThrow(() -> new UnsupportedAlgorithmException("The specified algorithm is not supported yet."));
|
||||
}
|
||||
|
||||
+4
-5
@@ -30,14 +30,13 @@ import cn.org.codecrafters.simplejwt.constants.TokenAlgorithm;
|
||||
* specifying algorithm functions corresponding to different TokenAlgorithm
|
||||
* instances supported by the TokenResolver implementation.
|
||||
*
|
||||
*
|
||||
* @param <AlgorithmFunction> the type representing algorithm functions used by
|
||||
* the TokenResolver
|
||||
* @param <Algo> the type representing algorithm functions used by the
|
||||
* {@code TokenResolver}
|
||||
* @author Zihlu Wang
|
||||
* @version 1.0.0
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface TokenResolverConfig<AlgorithmFunction> {
|
||||
public interface TokenResolverConfig<Algo> {
|
||||
|
||||
/**
|
||||
* Gets the algorithm function corresponding to the specified
|
||||
@@ -53,6 +52,6 @@ public interface TokenResolverConfig<AlgorithmFunction> {
|
||||
* required
|
||||
* @return the algorithm function associated with the given TokenAlgorithm
|
||||
*/
|
||||
AlgorithmFunction getFunction(TokenAlgorithm algorithm);
|
||||
Algo getAlgorithm(TokenAlgorithm algorithm);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user