我在我的 Java 应用程序中实现 jose4j 以验证 Azure 颁发的访问令牌的签名。该应用程序运行良好,但是,我遇到了有关Signing Key rollover的文档。jose4j 在使用时会自动处理它HttpsJwksVerificationKeyResolver
吗?
我目前正在使用以下代码段来构建JwtConsumer
String azureKeyDiscoveryUrl =
"https://login.microsoftonline.com/{my-tenant-id}/discovery/keys";
HttpsJwks azureKeyDiscovery = new HttpsJwks(azureKeyDiscoveryUrl);
HttpsJwksVerificationKeyResolver azureJwksKeyResolver = new HttpsJwksVerificationKeyResolver(azureKeyDiscovery);
JwtConsumer azureJwtConsumer = new JwtConsumerBuilder()
.setRequireExpirationTime()
.setAllowedClockSkewInSeconds(30)
.setRequireIssuedAt()
.setRequireNotBefore()
.setVerificationKeyResolver(azureJwksKeyResolver)
.setExpectedAudience("my-audience")
.setJwsAlgorithmConstraints(new AlgorithmConstraints(
AlgorithmConstraints.ConstraintType.WHITELIST, AlgorithmIdentifiers.RSA_USING_SHA256))
.build();
JwtClaims claims = azureJwtConsumer.processToClaims("tokenStringHere");