| 122 | /// Signs `claims` with the given HMAC algorithm. Use this when you want |
| 123 | /// to pass the algorithm dynamically. |
| 124 | public static String sign(Map<String, Object> claims, byte[] secret, String algorithm) { |
| 125 | if (claims == null) { |
| 126 | throw new CryptoException("claims must not be null"); |
| 127 | } |
| 128 | if (algorithm == null) { |
| 129 | throw new CryptoException("algorithm must not be null"); |
| 130 | } |
| 131 | String signingInput = signingInput(algorithm, claims); |
| 132 | byte[] sig = computeHmac(algorithm, secret, signingInput); |
| 133 | return signingInput + "." + com.codename1.util.Base64.encodeUrlSafe(sig); |
| 134 | } |
| 135 | |
| 136 | /// Signs `claims` with the given RSA or ECDSA algorithm. |
| 137 | /// |