com.auth0.jwt.algorithms.Algorithm.getName()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(320)

本文整理了Java中com.auth0.jwt.algorithms.Algorithm.getName()方法的一些代码示例,展示了Algorithm.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Algorithm.getName()方法的具体详情如下:
包路径:com.auth0.jwt.algorithms.Algorithm
类名称:Algorithm
方法名:getName

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

  1. private void verifyAlgorithm(DecodedJWT jwt, Algorithm expectedAlgorithm) throws AlgorithmMismatchException {
  2. if (!expectedAlgorithm.getName().equals(jwt.getAlgorithm())) {
  3. throw new AlgorithmMismatchException("The provided Algorithm doesn't match the one defined in the JWT's Header.");
  4. }
  5. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateRSA256AlgorithmWithBothKeys() throws Exception {
  3. RSAPublicKey publicKey = mock(RSAPublicKey.class);
  4. RSAPrivateKey privateKey = mock(RSAPrivateKey.class);
  5. Algorithm algorithm = Algorithm.RSA256(publicKey, privateKey);
  6. assertThat(algorithm, is(notNullValue()));
  7. assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
  8. assertThat(algorithm.getDescription(), is("SHA256withRSA"));
  9. assertThat(algorithm.getName(), is("RS256"));
  10. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateRSA384AlgorithmWithBothKeys() throws Exception {
  3. RSAPublicKey publicKey = mock(RSAPublicKey.class);
  4. RSAPrivateKey privateKey = mock(RSAPrivateKey.class);
  5. Algorithm algorithm = Algorithm.RSA384(publicKey, privateKey);
  6. assertThat(algorithm, is(notNullValue()));
  7. assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
  8. assertThat(algorithm.getDescription(), is("SHA384withRSA"));
  9. assertThat(algorithm.getName(), is("RS384"));
  10. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateRSA512AlgorithmWithBothKeys() throws Exception {
  3. RSAPublicKey publicKey = mock(RSAPublicKey.class);
  4. RSAPrivateKey privateKey = mock(RSAPrivateKey.class);
  5. Algorithm algorithm = Algorithm.RSA512(publicKey, privateKey);
  6. assertThat(algorithm, is(notNullValue()));
  7. assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
  8. assertThat(algorithm.getDescription(), is("SHA512withRSA"));
  9. assertThat(algorithm.getName(), is("RS512"));
  10. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateECDSA512AlgorithmWithBothKeys() throws Exception {
  3. ECPublicKey publicKey = mock(ECPublicKey.class);
  4. ECPrivateKey privateKey = mock(ECPrivateKey.class);
  5. Algorithm algorithm = Algorithm.ECDSA512(publicKey, privateKey);
  6. assertThat(algorithm, is(notNullValue()));
  7. assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
  8. assertThat(algorithm.getDescription(), is("SHA512withECDSA"));
  9. assertThat(algorithm.getName(), is("ES512"));
  10. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateHMAC512AlgorithmWithBytes() throws Exception {
  3. Algorithm algorithm = Algorithm.HMAC512("secret".getBytes(StandardCharsets.UTF_8));
  4. assertThat(algorithm, is(notNullValue()));
  5. assertThat(algorithm, is(instanceOf(HMACAlgorithm.class)));
  6. assertThat(algorithm.getDescription(), is("HmacSHA512"));
  7. assertThat(algorithm.getName(), is("HS512"));
  8. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateECDSA512AlgorithmWithProvider() throws Exception {
  3. ECDSAKeyProvider provider = mock(ECDSAKeyProvider.class);
  4. Algorithm algorithm = Algorithm.ECDSA512(provider);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA512withECDSA"));
  8. assertThat(algorithm.getName(), is("ES512"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateRSA512AlgorithmWithProvider() throws Exception {
  3. RSAKeyProvider provider = mock(RSAKeyProvider.class);
  4. Algorithm algorithm = Algorithm.RSA512(provider);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA512withRSA"));
  8. assertThat(algorithm.getName(), is("RS512"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateHMAC384AlgorithmWithBytes() throws Exception {
  3. Algorithm algorithm = Algorithm.HMAC384("secret".getBytes(StandardCharsets.UTF_8));
  4. assertThat(algorithm, is(notNullValue()));
  5. assertThat(algorithm, is(instanceOf(HMACAlgorithm.class)));
  6. assertThat(algorithm.getDescription(), is("HmacSHA384"));
  7. assertThat(algorithm.getName(), is("HS384"));
  8. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateHMAC384AlgorithmWithString() throws Exception {
  3. Algorithm algorithm = Algorithm.HMAC384("secret");
  4. assertThat(algorithm, is(notNullValue()));
  5. assertThat(algorithm, is(instanceOf(HMACAlgorithm.class)));
  6. assertThat(algorithm.getDescription(), is("HmacSHA384"));
  7. assertThat(algorithm.getName(), is("HS384"));
  8. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateHMAC512AlgorithmWithString() throws Exception {
  3. Algorithm algorithm = Algorithm.HMAC512("secret");
  4. assertThat(algorithm, is(notNullValue()));
  5. assertThat(algorithm, is(instanceOf(HMACAlgorithm.class)));
  6. assertThat(algorithm.getDescription(), is("HmacSHA512"));
  7. assertThat(algorithm.getName(), is("HS512"));
  8. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateRSA384AlgorithmWithPublicKey() throws Exception {
  3. RSAKey key = mock(RSAKey.class, withSettings().extraInterfaces(RSAPublicKey.class));
  4. Algorithm algorithm = Algorithm.RSA384(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA384withRSA"));
  8. assertThat(algorithm.getName(), is("RS384"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateRSA512AlgorithmWithPublicKey() throws Exception {
  3. RSAKey key = mock(RSAKey.class, withSettings().extraInterfaces(RSAPublicKey.class));
  4. Algorithm algorithm = Algorithm.RSA512(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA512withRSA"));
  8. assertThat(algorithm.getName(), is("RS512"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateRSA512AlgorithmWithPrivateKey() throws Exception {
  3. RSAKey key = mock(RSAKey.class, withSettings().extraInterfaces(RSAPrivateKey.class));
  4. Algorithm algorithm = Algorithm.RSA512(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA512withRSA"));
  8. assertThat(algorithm.getName(), is("RS512"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateECDSA384AlgorithmWithPublicKey() throws Exception {
  3. ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPublicKey.class));
  4. Algorithm algorithm = Algorithm.ECDSA384(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA384withECDSA"));
  8. assertThat(algorithm.getName(), is("ES384"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateECDSA384AlgorithmWithPrivateKey() throws Exception {
  3. ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPrivateKey.class));
  4. Algorithm algorithm = Algorithm.ECDSA384(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA384withECDSA"));
  8. assertThat(algorithm.getName(), is("ES384"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateECDSA512AlgorithmWithPrivateKey() throws Exception {
  3. ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPrivateKey.class));
  4. Algorithm algorithm = Algorithm.ECDSA512(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA512withECDSA"));
  8. assertThat(algorithm.getName(), is("ES512"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateRSA256AlgorithmWithPrivateKey() throws Exception {
  3. RSAKey key = mock(RSAKey.class, withSettings().extraInterfaces(RSAPrivateKey.class));
  4. Algorithm algorithm = Algorithm.RSA256(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(RSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA256withRSA"));
  8. assertThat(algorithm.getName(), is("RS256"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateECDSA256AlgorithmWithPublicKey() throws Exception {
  3. ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPublicKey.class));
  4. Algorithm algorithm = Algorithm.ECDSA256(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA256withECDSA"));
  8. assertThat(algorithm.getName(), is("ES256"));
  9. }

代码示例来源:origin: auth0/java-jwt

  1. @Test
  2. public void shouldCreateECDSA512AlgorithmWithPublicKey() throws Exception {
  3. ECKey key = mock(ECKey.class, withSettings().extraInterfaces(ECPublicKey.class));
  4. Algorithm algorithm = Algorithm.ECDSA512(key);
  5. assertThat(algorithm, is(notNullValue()));
  6. assertThat(algorithm, is(instanceOf(ECDSAAlgorithm.class)));
  7. assertThat(algorithm.getDescription(), is("SHA512withECDSA"));
  8. assertThat(algorithm.getName(), is("ES512"));
  9. }

相关文章