@Test public void testParseAccessKeyNotFound() throws Exception { HashSet<String> set = new HashSet<>(); set.add("notFound"); long l = Jwt.parseAccessKey(JWT, set); Assert.assertEquals(-1, l); }
public static long parseAccessKey(ByteBuf token, Set<String> mappedFields) { try { ByteBuf payload = payload(token); ByteBuffer decodedPayload = URL_DECODER.decode(payload.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedPayload); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if (mappedFields.contains(name)) { parser.nextToken(); return Long.valueOf(parser.getText()); } } } catch (Exception e) { throw Exceptions.propagate(e); } return -1; }
Jwt { public static long parseAccessKey(ByteBuf token, Set<String> mappedFields) { try { ByteBuf payload = payload(token); ByteBuffer decodedPayload = URL_DECODER.decode(payload.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedPayload); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if (mappedFields.contains(name)) { parser.nextToken(); return Long.valueOf(parser.getText()); } } } catch (Exception e) { throw Exceptions.propagate(e); } return -1; } }
Jwt { public static long parseAccessKey(ByteBuf token, Set<String> mappedFields) { try { ByteBuf payload = payload(token); ByteBuffer decodedPayload = URL_DECODER.decode(payload.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedPayload); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if (mappedFields.contains(name)) { parser.nextToken(); return Long.valueOf(parser.getText()); } } } catch (Exception e) { throw Exceptions.propagate(e); } return -1; }  }
Jwt { public static long parseAccessKey(ByteBuf token, Set<String> mappedFields) { try { ByteBuf payload = payload(token); ByteBuffer decodedPayload = URL_DECODER.decode(payload.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedPayload); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if (mappedFields.contains(name)) { parser.nextToken(); return Long.valueOf(parser.getText()); } } } catch (Exception e) { throw Exceptions.propagate(e); } return -1; }  static ByteBuf header(ByteBuf token); static ByteBuf payload(ByteBuf token); static ByteBuf signature(ByteBuf token); static ByteBuf headerAndPayload(ByteBuf token); static boolean verifySHA256withRSA(PublicKey publicKey, ByteBuf token); static boolean verify(String alg, PublicKey publicKey, ByteBuf token); static long parseAccessKey(ByteBuf token, Set<String> mappedFields); static String parseAlgorithm(ByteBuf token); }
Jwt { public static long parseAccessKey(ByteBuf token, Set<String> mappedFields) { try { ByteBuf payload = payload(token); ByteBuffer decodedPayload = URL_DECODER.decode(payload.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedPayload); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if (mappedFields.contains(name)) { parser.nextToken(); return Long.valueOf(parser.getText()); } } } catch (Exception e) { throw Exceptions.propagate(e); } return -1; }  static ByteBuf header(ByteBuf token); static ByteBuf payload(ByteBuf token); static ByteBuf signature(ByteBuf token); static ByteBuf headerAndPayload(ByteBuf token); static boolean verifySHA256withRSA(PublicKey publicKey, ByteBuf token); static boolean verify(String alg, PublicKey publicKey, ByteBuf token); static long parseAccessKey(ByteBuf token, Set<String> mappedFields); static String parseAlgorithm(ByteBuf token);  }