MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / verify

Method verify

CodenameOne/src/com/codename1/security/Jwt.java:241–258  ·  view source on GitHub ↗
(PublicKey publicKey)

Source from the content-addressed store, hash-verified

239 /// algorithm must match the token's `alg` header (RS256/384/512 or
240 /// ES256/384/512).
241 public boolean verify(PublicKey publicKey) {
242 String alg = getAlgorithm();
243 if (NONE.equals(alg)) {
244 return verifyAllowNoneAlgorithm && (signature == null || signature.length == 0);
245 }
246 String sigAlg = signatureAlgorithmFor(alg);
247 byte[] data;
248 try {
249 data = signingInput.getBytes("UTF-8");
250 } catch (UnsupportedEncodingException e) {
251 throw new CryptoException("UTF-8 not supported", e);
252 }
253 byte[] sig = signature;
254 if (alg.startsWith("ES")) {
255 sig = joseToDerEcdsa(sig, ecdsaCoordinateLength(alg));
256 }
257 return Signature.verify(sigAlg, publicKey, data, sig);
258 }
259
260 // ================================================================
261 // accessors

Callers 3

runJwtRs256Method · 0.95
jwtRsRoundTripMethod · 0.95

Calls 8

getAlgorithmMethod · 0.95
signatureAlgorithmForMethod · 0.95
startsWithMethod · 0.95
joseToDerEcdsaMethod · 0.95
ecdsaCoordinateLengthMethod · 0.95
verifyMethod · 0.95
equalsMethod · 0.65
getBytesMethod · 0.65

Tested by 3

runJwtRs256Method · 0.76
jwtRsRoundTripMethod · 0.76