本文整理汇总了Java中com.nimbusds.jose.jwk.source.RemoteJWKSet类的典型用法代码示例。如果您正苦于以下问题:Java RemoteJWKSet类的具体用法?Java RemoteJWKSet怎么用?Java RemoteJWKSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteJWKSet类属于com.nimbusds.jose.jwk.source包,在下文中一共展示了RemoteJWKSet类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAadJwtTokenValidator
import com.nimbusds.jose.jwk.source.RemoteJWKSet; //导入依赖的package包/类
private ConfigurableJWTProcessor<SecurityContext> getAadJwtTokenValidator()
throws MalformedURLException {
final ConfigurableJWTProcessor<SecurityContext> jwtProcessor = new DefaultJWTProcessor<>();
final JWKSource<SecurityContext> keySource = new RemoteJWKSet<>(
new URL(KEY_DISCOVERY_URI));
final JWSAlgorithm expectedJWSAlg = JWSAlgorithm.RS256;
final JWSKeySelector<SecurityContext> keySelector = new JWSVerificationKeySelector<>(expectedJWSAlg, keySource);
jwtProcessor.setJWSKeySelector(keySelector);
jwtProcessor.setJWTClaimsSetVerifier(new DefaultJWTClaimsVerifier<SecurityContext>() {
@Override
public void verify(JWTClaimsSet claimsSet, SecurityContext ctx) throws BadJWTException {
super.verify(claimsSet, ctx);
final String issuer = claimsSet.getIssuer();
if (issuer == null || !issuer.contains("https://sts.windows.net/")) {
throw new BadJWTException("Invalid token issuer");
}
}
});
return jwtProcessor;
}
示例2: lookupJWKSource
import com.nimbusds.jose.jwk.source.RemoteJWKSet; //导入依赖的package包/类
private JWKSource<SecurityContext> lookupJWKSource() throws IOException, ParseException {
if(jwtConfiguration.getJwkResource() != null &&
!"".equals(jwtConfiguration.getJwkResource())) {
URL resource = DefaultValidatingJWTProcessor.class.getResource(jwtConfiguration.getJwkResource());
try(InputStream stream = resource.openStream()) {
String key = com.nimbusds.jose.util.IOUtils.readInputStreamToString(stream, Charset.defaultCharset());
return new ImmutableJWKSet<>(JWKSet.parse(key));
}
}
else if(jwtConfiguration.getJwkSourceUrl() != null &&
!"".equals(jwtConfiguration.getJwkSourceUrl())) {
return new RemoteJWKSet<>(new URL(jwtConfiguration.getJwkSourceUrl()));
}
else {
JWKSet jwkSet = JWKSet.load(new File(jwtConfiguration.getJwkSourceFile()));
return new ImmutableJWKSet<>(jwkSet);
}
}
示例3: configurableJWTProcessor
import com.nimbusds.jose.jwk.source.RemoteJWKSet; //导入依赖的package包/类
@Bean
public ConfigurableJWTProcessor configurableJWTProcessor() throws MalformedURLException {
ResourceRetriever resourceRetriever = new DefaultResourceRetriever(jwtConfiguration.getConnectionTimeout(), jwtConfiguration.getReadTimeout());
URL jwkSetURL = new URL(jwtConfiguration.getJwkUrl());
JWKSource keySource = new RemoteJWKSet(jwkSetURL, resourceRetriever);
ConfigurableJWTProcessor jwtProcessor = new DefaultJWTProcessor();
JWSKeySelector keySelector = new JWSVerificationKeySelector(RS256, keySource);
jwtProcessor.setJWSKeySelector(keySelector);
return jwtProcessor;
}