@Test public void testVerifyES256() throws Exception { PublicKey publicKey = buildEs256PublicKey(GOOGLE_ES256_X, GOOGLE_ES256_Y); JsonWebSignature.Header header = new JsonWebSignature.Header(); header.setAlgorithm("ES256"); JsonWebSignature.Payload payload = new JsonWebToken.Payload(); byte[] signatureBytes = Base64.decodeBase64(ES256_SIGNATURE); byte[] signedContentBytes = StringUtils.getBytesUtf8(ES256_CONTENT); JsonWebSignature jsonWebSignature = new JsonWebSignature(header, payload, signatureBytes, signedContentBytes); Assert.assertTrue(jsonWebSignature.verifySignature(publicKey)); }
public final boolean verifySignature(PublicKey publicKey) throws GeneralSecurityException { String algorithm = getHeader().getAlgorithm(); if ("RS256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getSha256WithRsaSignatureAlgorithm(), publicKey, signatureBytes, signedContentBytes); } else if ("ES256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getEs256SignatureAlgorithm(), publicKey, DerEncoder.encode(signatureBytes), signedContentBytes); } else { return false; } }
JsonWebSignature extends JsonWebToken { public final boolean verifySignature(PublicKey publicKey) throws GeneralSecurityException { String algorithm = getHeader().getAlgorithm(); if ("RS256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getSha256WithRsaSignatureAlgorithm(), publicKey, signatureBytes, signedContentBytes); } else if ("ES256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getEs256SignatureAlgorithm(), publicKey, DerEncoder.encode(signatureBytes), signedContentBytes); } else { return false; } } }
JsonWebSignature extends JsonWebToken { public final boolean verifySignature(PublicKey publicKey) throws GeneralSecurityException { String algorithm = getHeader().getAlgorithm(); if ("RS256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getSha256WithRsaSignatureAlgorithm(), publicKey, signatureBytes, signedContentBytes); } else if ("ES256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getEs256SignatureAlgorithm(), publicKey, DerEncoder.encode(signatureBytes), signedContentBytes); } else { return false; } } JsonWebSignature(
      Header header, Payload payload, byte[] signatureBytes, byte[] signedContentBytes); }
JsonWebSignature extends JsonWebToken { public final boolean verifySignature(PublicKey publicKey) throws GeneralSecurityException { String algorithm = getHeader().getAlgorithm(); if ("RS256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getSha256WithRsaSignatureAlgorithm(), publicKey, signatureBytes, signedContentBytes); } else if ("ES256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getEs256SignatureAlgorithm(), publicKey, DerEncoder.encode(signatureBytes), signedContentBytes); } else { return false; } } JsonWebSignature(
      Header header, Payload payload, byte[] signatureBytes, byte[] signedContentBytes); @Override Header getHeader(); final boolean verifySignature(PublicKey publicKey); @Beta final X509Certificate verifySignature(X509TrustManager trustManager); @Beta final X509Certificate verifySignature(); final byte[] getSignatureBytes(); final byte[] getSignedContentBytes(); static JsonWebSignature parse(JsonFactory jsonFactory, String tokenString); static Parser parser(JsonFactory jsonFactory); static String signUsingRsaSha256(
      PrivateKey privateKey,
      JsonFactory jsonFactory,
      JsonWebSignature.Header header,
      JsonWebToken.Payload payload); }
JsonWebSignature extends JsonWebToken { public final boolean verifySignature(PublicKey publicKey) throws GeneralSecurityException { String algorithm = getHeader().getAlgorithm(); if ("RS256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getSha256WithRsaSignatureAlgorithm(), publicKey, signatureBytes, signedContentBytes); } else if ("ES256".equals(algorithm)) { return SecurityUtils.verify( SecurityUtils.getEs256SignatureAlgorithm(), publicKey, DerEncoder.encode(signatureBytes), signedContentBytes); } else { return false; } } JsonWebSignature(
      Header header, Payload payload, byte[] signatureBytes, byte[] signedContentBytes); @Override Header getHeader(); final boolean verifySignature(PublicKey publicKey); @Beta final X509Certificate verifySignature(X509TrustManager trustManager); @Beta final X509Certificate verifySignature(); final byte[] getSignatureBytes(); final byte[] getSignedContentBytes(); static JsonWebSignature parse(JsonFactory jsonFactory, String tokenString); static Parser parser(JsonFactory jsonFactory); static String signUsingRsaSha256(
      PrivateKey privateKey,
      JsonFactory jsonFactory,
      JsonWebSignature.Header header,
      JsonWebToken.Payload payload);  }