• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JWKSource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.nimbusds.jose.jwk.source.JWKSource的典型用法代码示例。如果您正苦于以下问题:Java JWKSource类的具体用法?Java JWKSource怎么用?Java JWKSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JWKSource类属于com.nimbusds.jose.jwk.source包,在下文中一共展示了JWKSource类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setupProcessors

import com.nimbusds.jose.jwk.source.JWKSource; //导入依赖的package包/类
/**
 * Prepare the tokens processors, one per allowed signing algorithm
 */
private void setupProcessors(int allowedClockSkew)
    throws InvalidConfigurationException, ExternalDependencyException {

    JWKSource keySource = this.getJwkSource();

    this.jwtProcessors = new HashMap<>();
    for (String s : this.signingAlgos) {
        // Create JWT processor
        DefaultJWTProcessor processor = new DefaultJWTProcessor();

        // Override the default instance (same class) in order to set our Clock skew value (the internal default is 60 seconds)
        DefaultJWTClaimsVerifier<SecurityContext> claimsVerifier = new DefaultJWTClaimsVerifier<>();
        claimsVerifier.setMaxClockSkew(allowedClockSkew);
        processor.setJWTClaimsSetVerifier(claimsVerifier);

        // Set the key selector
        processor.setJWSKeySelector(new JWSVerificationKeySelector(getAlgo(s), keySource));

        // Store the processor in the list, ready to be used
        this.jwtProcessors.put(s, processor);
    }
}
 
开发者ID:Azure,项目名称:device-telemetry-java,代码行数:26,代码来源:OpenIdConnectJwtValidation.java


示例2: getAadJwtTokenValidator

import com.nimbusds.jose.jwk.source.JWKSource; //导入依赖的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;
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:22,代码来源:UserPrincipal.java


示例3: lookupJWKSource

import com.nimbusds.jose.jwk.source.JWKSource; //导入依赖的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);
    }
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:20,代码来源:DefaultValidatingJWTProcessor.java


示例4: configurableJWTProcessor

import com.nimbusds.jose.jwk.source.JWKSource; //导入依赖的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;
}
 
开发者ID:IxorTalk,项目名称:ixortalk.aws.cognito.jwt.security.filter,代码行数:11,代码来源:JwtAutoConfiguration.java


示例5: init

import com.nimbusds.jose.jwk.source.JWKSource; //导入依赖的package包/类
@PostConstruct
public void init() {
    try {
        JWKSource<SecurityContext> keySource = lookupJWKSource();
        JWSAlgorithm expectedJWSAlg = jwtConfiguration.getAlgorithm();
        JWSKeySelector<SecurityContext> keySelector = new JWSVerificationKeySelector<>(expectedJWSAlg, keySource);
        delegate.setJWSKeySelector(keySelector);
    } catch (IOException | ParseException e) {
        throw new JWTException("Unable to read JWT Configuration",e);
    }
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:12,代码来源:DefaultValidatingJWTProcessor.java



注:本文中的com.nimbusds.jose.jwk.source.JWKSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Listeners类代码示例发布时间:2022-05-23
下一篇:
Java BinaryResponseParser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap