38 throw new SignatureException(
"The signature algorithm is null");
41 throw new SignatureException(
"The shared secret is null");
43 if (signingInput == null) {
44 throw new SignatureException(
"The signing input is null");
50 algorithm =
"HMACSHA256";
53 algorithm =
"HMACSHA384";
56 algorithm =
"HMACSHA512";
59 throw new SignatureException(
"Unsupported signature algorithm");
63 SecretKey secretKey =
new SecretKeySpec(
sharedSecret.getBytes(Util.UTF8_STRING_ENCODING), algorithm);
64 Mac mac = Mac.getInstance(algorithm);
66 byte[] sig = mac.doFinal(signingInput.getBytes(Util.UTF8_STRING_ENCODING));
67 return Base64Util.base64urlencode(sig);
68 }
catch (NoSuchAlgorithmException e) {
69 throw new SignatureException(e);
70 }
catch (InvalidKeyException e) {
71 throw new SignatureException(e);
72 }
catch (UnsupportedEncodingException e) {
73 throw new SignatureException(e);
74 }
catch (Exception e) {
75 throw new SignatureException(e);
String sharedSecret
Definition: HMACSigner.java:28
SignatureAlgorithm getSignatureAlgorithm()
Definition: AbstractJwsSigner.java:37