本文整理了Java中com.auth0.jwt.algorithms.Algorithm.getName()
方法的一些代码示例,展示了Algorithm.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Algorithm.getName()
方法的具体详情如下:
包路径:com.auth0.jwt.algorithms.Algorithm
类名称:Algorithm
方法名:getName
[英]Getter for the name of this Algorithm, as defined in the JWT Standard. i.e. "HS256"
[中]获取此算法的名称,如JWT标准中所定义。i、 e.“HS256”
代码示例来源:origin: auth0/java-jwt
private void verifyAlgorithm(DecodedJWT jwt, Algorithm expectedAlgorithm) throws AlgorithmMismatchException {
if (!expectedAlgorithm.getName().equals(jwt.getAlgorithm())) {
throw new AlgorithmMismatchException("The provided Algorithm doesn't match the one defined in the JWT's Header.");
}
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateRSA256AlgorithmWithBothKeys() throws Exception {
RSAPublicKey publicKey = mock(RSAPublicKey.class);
RSAPrivateKey privateKey = mock(RSAPrivateKey.class);
Algorithm algorithm = Algorithm.RSA256(publicKey, privateKey);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA256withRSA"));
assertThat(algorithm.getName(), is("RS256"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateRSA384AlgorithmWithBothKeys() throws Exception {
RSAPublicKey publicKey = mock(RSAPublicKey.class);
RSAPrivateKey privateKey = mock(RSAPrivateKey.class);
Algorithm algorithm = Algorithm.RSA384(publicKey, privateKey);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA384withRSA"));
assertThat(algorithm.getName(), is("RS384"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateRSA512AlgorithmWithBothKeys() throws Exception {
RSAPublicKey publicKey = mock(RSAPublicKey.class);
RSAPrivateKey privateKey = mock(RSAPrivateKey.class);
Algorithm algorithm = Algorithm.RSA512(publicKey, privateKey);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA512withRSA"));
assertThat(algorithm.getName(), is("RS512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateECDSA512AlgorithmWithBothKeys() throws Exception {
ECPublicKey publicKey = mock(ECPublicKey.class);
ECPrivateKey privateKey = mock(ECPrivateKey.class);
Algorithm algorithm = Algorithm.ECDSA512(publicKey, privateKey);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA512withECDSA"));
assertThat(algorithm.getName(), is("ES512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateHMAC512AlgorithmWithBytes() throws Exception {
Algorithm algorithm = Algorithm.HMAC512("secret".getBytes(StandardCharsets.UTF_8));
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(HMACAlgorithm.class)));
assertThat(algorithm.getDescription(), is("HmacSHA512"));
assertThat(algorithm.getName(), is("HS512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateECDSA512AlgorithmWithProvider() throws Exception {
ECDSAKeyProvider provider = mock(ECDSAKeyProvider.class);
Algorithm algorithm = Algorithm.ECDSA512(provider);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA512withECDSA"));
assertThat(algorithm.getName(), is("ES512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateRSA512AlgorithmWithProvider() throws Exception {
RSAKeyProvider provider = mock(RSAKeyProvider.class);
Algorithm algorithm = Algorithm.RSA512(provider);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA512withRSA"));
assertThat(algorithm.getName(), is("RS512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateHMAC384AlgorithmWithBytes() throws Exception {
Algorithm algorithm = Algorithm.HMAC384("secret".getBytes(StandardCharsets.UTF_8));
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(HMACAlgorithm.class)));
assertThat(algorithm.getDescription(), is("HmacSHA384"));
assertThat(algorithm.getName(), is("HS384"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateHMAC384AlgorithmWithString() throws Exception {
Algorithm algorithm = Algorithm.HMAC384("secret");
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(HMACAlgorithm.class)));
assertThat(algorithm.getDescription(), is("HmacSHA384"));
assertThat(algorithm.getName(), is("HS384"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateHMAC512AlgorithmWithString() throws Exception {
Algorithm algorithm = Algorithm.HMAC512("secret");
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(HMACAlgorithm.class)));
assertThat(algorithm.getDescription(), is("HmacSHA512"));
assertThat(algorithm.getName(), is("HS512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateRSA384AlgorithmWithPublicKey() throws Exception {
RSAKey key = mock(RSAKey.class, withSettings().extraInterfaces(RSAPublicKey.class));
Algorithm algorithm = Algorithm.RSA384(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA384withRSA"));
assertThat(algorithm.getName(), is("RS384"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateRSA512AlgorithmWithPublicKey() throws Exception {
RSAKey key = mock(RSAKey.class, withSettings().extraInterfaces(RSAPublicKey.class));
Algorithm algorithm = Algorithm.RSA512(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA512withRSA"));
assertThat(algorithm.getName(), is("RS512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateRSA512AlgorithmWithPrivateKey() throws Exception {
RSAKey key = mock(RSAKey.class, withSettings().extraInterfaces(RSAPrivateKey.class));
Algorithm algorithm = Algorithm.RSA512(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA512withRSA"));
assertThat(algorithm.getName(), is("RS512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateECDSA384AlgorithmWithPublicKey() throws Exception {
ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPublicKey.class));
Algorithm algorithm = Algorithm.ECDSA384(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA384withECDSA"));
assertThat(algorithm.getName(), is("ES384"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateECDSA384AlgorithmWithPrivateKey() throws Exception {
ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPrivateKey.class));
Algorithm algorithm = Algorithm.ECDSA384(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA384withECDSA"));
assertThat(algorithm.getName(), is("ES384"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateECDSA512AlgorithmWithPrivateKey() throws Exception {
ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPrivateKey.class));
Algorithm algorithm = Algorithm.ECDSA512(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA512withECDSA"));
assertThat(algorithm.getName(), is("ES512"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateRSA256AlgorithmWithPrivateKey() throws Exception {
RSAKey key = mock(RSAKey.class, withSettings().extraInterfaces(RSAPrivateKey.class));
Algorithm algorithm = Algorithm.RSA256(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA256withRSA"));
assertThat(algorithm.getName(), is("RS256"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateECDSA256AlgorithmWithPublicKey() throws Exception {
ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPublicKey.class));
Algorithm algorithm = Algorithm.ECDSA256(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA256withECDSA"));
assertThat(algorithm.getName(), is("ES256"));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldCreateECDSA512AlgorithmWithPublicKey() throws Exception {
ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPublicKey.class));
Algorithm algorithm = Algorithm.ECDSA512(key);
assertThat(algorithm, is(notNullValue()));
assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
assertThat(algorithm.getDescription(), is("SHA512withECDSA"));
assertThat(algorithm.getName(), is("ES512"));
}
内容来源于网络,如有侵权,请联系作者删除!