本文整理了Java中com.nimbusds.jose.jwk.JWK.getAlgorithm()
方法的一些代码示例,展示了JWK.getAlgorithm()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JWK.getAlgorithm()
方法的具体详情如下:
包路径:com.nimbusds.jose.jwk.JWK
类名称:JWK
方法名:getAlgorithm
[英]Gets the intended JOSE algorithm ( alg) for this JWK.
[中]获取此JWK的预期JOSE算法(alg)。
代码示例来源:origin: spring-projects/spring-security
@Test
public void getWhenMatchThenCreatesKeys() {
when(this.matcher.matches(any())).thenReturn(true);
List<JWK> keys = this.source.get(this.selector).block();
assertThat(keys).hasSize(2);
JWK key1 = keys.get(0);
assertThat(key1.getKeyID()).isEqualTo("1923397381d9574bb873202a90c32b7ceeaed027");
assertThat(key1.getAlgorithm().getName()).isEqualTo("RS256");
assertThat(key1.getKeyType()).isEqualTo(KeyType.RSA);
assertThat(key1.getKeyUse()).isEqualTo(KeyUse.SIGNATURE);
JWK key2 = keys.get(1);
assertThat(key2.getKeyID()).isEqualTo("7ddf54d3032d1f0d48c3618892ca74c1ac30ad77");
assertThat(key2.getAlgorithm().getName()).isEqualTo("RS256");
assertThat(key2.getKeyType()).isEqualTo(KeyType.RSA);
assertThat(key2.getKeyUse()).isEqualTo(KeyUse.SIGNATURE);
}
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
private ECPublicKey getKey(String kid, String alg) throws Exception {
JWK jwk = keyCache.get(kid);
if (jwk == null) {
// update cache loading jwk public key data from url
JWKSet jwkSet = JWKSet.load(new URL(PUBLIC_KEY_VERIFICATION_URL));
for (JWK key : jwkSet.getKeys()) {
keyCache.put(key.getKeyID(), key);
}
jwk = keyCache.get(kid);
}
// confirm that algorithm matches
if (jwk != null && jwk.getAlgorithm().getName().equals(alg)) {
return ECKey.parse(jwk.toJSONString()).toECPublicKey();
}
return null;
}
代码示例来源:origin: de.adorsys.cryptoutils/jjwk
public static JWSAlgorithm getJWSAlgo(KeyAndJwk randomKey) {
Algorithm algorithm = randomKey.jwk.getAlgorithm();
if(algorithm!=null && (algorithm instanceof JWSAlgorithm)) return (JWSAlgorithm) algorithm;
KeyType keyType = randomKey.jwk.getKeyType();
if(keyType!=null){
if(KeyType.RSA.equals(keyType)){
return JWSAlgorithm.RS256;
} else if(KeyType.EC.equals(keyType)){
return JWSAlgorithm.ES256;
} else if(KeyType.OCT.equals(keyType)){
return JWSAlgorithm.HS256;
} else {
throw new IllegalStateException("Unknown key type: " + keyType);
}
} else {
if(randomKey.jwk instanceof RSAKey){
return JWSAlgorithm.RS256;
} else if (randomKey.jwk instanceof ECKey){
return JWSAlgorithm.ES256;
} else if (randomKey.jwk instanceof OctetSequenceKey){
return JWSAlgorithm.HS256;
} else {
throw new IllegalStateException("Unknown key type: " + randomKey.jwk.getClass().getName());
}
}
}
代码示例来源:origin: de.adorsys.cryptoutils/jjwk
try {
Algorithm alg = jwk.getAlgorithm();
if(alg!=null){
if(alg instanceof JWSAlgorithm) {
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
if (algs != null && ! algs.contains(key.getAlgorithm()))
return false;
代码示例来源:origin: gravitee-io/graviteeio-access-management
jwk.setKeyOps(nimbusJwk.getKeyOperations().stream().map(keyOperation -> keyOperation.identifier()).collect(Collectors.toSet()));
if (nimbusJwk.getAlgorithm() != null) {
jwk.setAlg(nimbusJwk.getAlgorithm().getName());
内容来源于网络,如有侵权,请联系作者删除!