MCPcopy Index your code
hub / github.com/codenameone/CodenameOne / parse

Method parse

CodenameOne/src/com/codename1/security/Jwt.java:181–200  ·  view source on GitHub ↗
(String token)

Source from the content-addressed store, hash-verified

179 /// Parses an encoded JWT into a [Jwt] object. The signature is NOT
180 /// verified -- you must call one of the `verify*` methods afterwards.
181 public static Jwt parse(String token) {
182 if (token == null) {
183 throw new CryptoException("token must not be null");
184 }
185 int firstDot = token.indexOf('.');
186 if (firstDot < 0) {
187 throw new CryptoException("malformed JWT: no '.'");
188 }
189 int secondDot = token.indexOf('.', firstDot + 1);
190 if (secondDot < 0) {
191 throw new CryptoException("malformed JWT: only one '.'");
192 }
193 String headerB64 = token.substring(0, firstDot);
194 String payloadB64 = token.substring(firstDot + 1, secondDot);
195 String sigB64 = token.substring(secondDot + 1);
196 Map<String, Object> header = readJson(com.codename1.util.Base64.decodeUrlSafe(headerB64));
197 Map<String, Object> claims = readJson(com.codename1.util.Base64.decodeUrlSafe(payloadB64));
198 byte[] sig = sigB64.length() == 0 ? new byte[0] : com.codename1.util.Base64.decodeUrlSafe(sigB64);
199 return new Jwt(header, claims, sig, headerB64 + "." + payloadB64);
200 }
201
202 // ================================================================
203 // verification

Callers 13

runJwtHs256Method · 0.95
runJwtRs256Method · 0.95
jwtRsRoundTripMethod · 0.95
hs256_roundTripMethod · 0.95
hs256_referenceVectorMethod · 0.95
hs512_roundTripMethod · 0.95
JSONContentMethod · 0.45
XMLContentMethod · 0.45
MapContentMethod · 0.45

Calls 5

readJsonMethod · 0.95
lengthMethod · 0.95
decodeUrlSafeMethod · 0.80
indexOfMethod · 0.65
substringMethod · 0.65

Tested by 8

runJwtHs256Method · 0.76
runJwtRs256Method · 0.76
jwtRsRoundTripMethod · 0.76
hs256_roundTripMethod · 0.76
hs256_referenceVectorMethod · 0.76
hs512_roundTripMethod · 0.76