@Test public void testVerify() { String accessToken = "eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"; String jwt[] = accessToken.split("\\."); assertTrue(sHmacImpl.verify(jwt[2], jwt[0], jwt[1], key)); }
@Override public boolean verify(String signature, String header, String payload, SymmetricKeyImpl verifyingKey) { String signed = calculate(header, payload, verifyingKey); return signed.equals(signature); }
SignatureMethodsHMAC256Impl implements SignatureMethod<SymmetricKeyImpl, SymmetricKeyImpl> { @Override public boolean verify(String signature, String header, String payload, SymmetricKeyImpl verifyingKey) { String signed = calculate(header, payload, verifyingKey); return signed.equals(signature); } }
SignatureMethodsHMAC256Impl implements SignatureMethod<SymmetricKeyImpl, SymmetricKeyImpl> { @Override public boolean verify(String signature, String header, String payload, SymmetricKeyImpl verifyingKey) { String signed = calculate(header, payload, verifyingKey); return signed.equals(signature); }  }
SignatureMethodsHMAC256Impl implements SignatureMethod<SymmetricKeyImpl, SymmetricKeyImpl> { @Override public boolean verify(String signature, String header, String payload, SymmetricKeyImpl verifyingKey) { String signed = calculate(header, payload, verifyingKey); return signed.equals(signature); }  @Override String calculate(String header, String payload, SymmetricKeyImpl signingKey); @Override boolean verify(String signature, String header, String payload, SymmetricKeyImpl verifyingKey); @Override String getAlgorithm(); }
SignatureMethodsHMAC256Impl implements SignatureMethod<SymmetricKeyImpl, SymmetricKeyImpl> { @Override public boolean verify(String signature, String header, String payload, SymmetricKeyImpl verifyingKey) { String signed = calculate(header, payload, verifyingKey); return signed.equals(signature); }  @Override String calculate(String header, String payload, SymmetricKeyImpl signingKey); @Override boolean verify(String signature, String header, String payload, SymmetricKeyImpl verifyingKey); @Override String getAlgorithm();  }