public static Signature getSignature(Algorithm alg) { try { return Signature.getInstance(getJavaAlgorithm(alg)); } catch (Exception e) { throw new RuntimeException(e); } }
public static byte[] sign(byte[] data, Algorithm algorithm, PrivateKey privateKey) { try { Signature signature = getSignature(algorithm); signature.initSign(privateKey); signature.update(data); return signature.sign(); } catch (Exception e) { throw new RuntimeException(e); } }
public static byte[] sign(byte[] data, Algorithm algorithm, SecretKey key) { try { Mac mac = HMACProvider.getMAC(algorithm); mac.init(key); mac.update(data); return mac.doFinal(); } catch (Exception e) { throw new RuntimeException(e); } } public static boolean verify(JWSInput input, SecretKey key)
public String hmac512(SecretKey sharedSecret) { byte[] data = marshalContent(); byte[] signature = HMACProvider.sign(data, Algorithm.HS512, sharedSecret); return encode(Algorithm.HS512, data, signature); }
public String rsa512(PrivateKey privateKey) { byte[] data = marshalContent(); byte[] signature = RSAProvider.sign(data, Algorithm.RS512, privateKey); return encode(Algorithm.RS512, data, signature); }
public static Mac getMAC(final Algorithm alg) { try { return javax.crypto.Mac.getInstance(getJavaAlgorithm(alg)); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(Messages.MESSAGES.unsupportedHMACalgorithm(e.getLocalizedMessage()), e); } }
public String hmac512(byte[] sharedSecret) { byte[] data = marshalContent(); byte[] signature = HMACProvider.sign(data, Algorithm.HS512, sharedSecret); return encode(Algorithm.HS512, data, signature); }
public String rsa384(PrivateKey privateKey) { byte[] data = marshalContent(); byte[] signature = RSAProvider.sign(data, Algorithm.RS384, privateKey); return encode(Algorithm.RS384, data, signature); } public String rsa512(PrivateKey privateKey)
public static boolean verify(JWSInput input, PublicKey publicKey) { try { Signature verifier = getSignature(input.getHeader().getAlgorithm()); verifier.initVerify(publicKey); verifier.update(input.getContent()); return verifier.verify(input.getSignature()); } catch (Exception e) { throw new RuntimeException(e); } }
public static byte[] sign(byte[] data, Algorithm algorithm, byte[] sharedSecret) { try { Mac mac = HMACProvider.getMAC(algorithm); mac.init(new SecretKeySpec(sharedSecret, mac.getAlgorithm())); mac.update(data); return mac.doFinal(); } catch (Exception e) { throw new RuntimeException(e); } }
public String hmac256(SecretKey sharedSecret) { byte[] data = marshalContent(); byte[] signature = HMACProvider.sign(data, Algorithm.HS256, sharedSecret); return encode(Algorithm.HS256, data, signature); }
public String rsa256(PrivateKey privateKey) { byte[] data = marshalContent(); byte[] signature = RSAProvider.sign(data, Algorithm.RS256, privateKey); return encode(Algorithm.RS256, data, signature); } public String rsa384(PrivateKey privateKey)
public String hmac256(byte[] sharedSecret) { byte[] data = marshalContent(); byte[] signature = HMACProvider.sign(data, Algorithm.HS256, sharedSecret); return encode(Algorithm.HS256, data, signature); }
public String rsa512(PrivateKey privateKey) { byte[] data = marshalContent(); byte[] signature = RSAProvider.sign(data, Algorithm.RS512, privateKey); return encode(Algorithm.RS512, data, signature); }
public String hmac384(SecretKey sharedSecret) { byte[] data = marshalContent(); byte[] signature = HMACProvider.sign(data, Algorithm.HS384, sharedSecret); return encode(Algorithm.HS384, data, signature); }
public String hmac384(byte[] sharedSecret) { byte[] data = marshalContent(); byte[] signature = HMACProvider.sign(data, Algorithm.HS384, sharedSecret); return encode(Algorithm.HS384, data, signature); }
public static boolean verify(JWSInput input, SecretKey key) { try { byte[] signature = sign(input.getContent(), input.getHeader().getAlgorithm(), key); String x = Base64Url.encode(signature); return x.equals(input.getEncodedSignature()); } catch (Exception e) { throw new RuntimeException(e); } }
public static boolean verify(JWSInput input, byte[] sharedSecret) { try { byte[] signature = sign(input.getContent(), input.getHeader().getAlgorithm(), sharedSecret); String x = Base64Url.encode(signature); return x.equals(input.getEncodedSignature()); } catch (Exception e) { throw new RuntimeException(e); } }
public String hmac256(byte[] sharedSecret) { byte[] data = marshalContent(); byte[] signature = HMACProvider.sign(data, Algorithm.HS256, sharedSecret); return encode(Algorithm.HS256, data, signature); }
public String hmac512(byte[] sharedSecret) { byte[] data = marshalContent(); byte[] signature = HMACProvider.sign(data, Algorithm.HS512, sharedSecret); return encode(Algorithm.HS512, data, signature); }