@Test public void testParseAlg() { String s = Jwt.parseAlgorithm(JWT); Assert.assertEquals("RS256", s); }
public static String parseAlgorithm(ByteBuf token) { try { ByteBuf header = header(token); ByteBuffer decodedHeader = URL_DECODER.decode(header.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedHeader); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if ("alg".equals(name)) { parser.nextToken(); return parser.getText(); } } } catch (Exception e) { throw Exceptions.propagate(e); } return "unknown"; }
Jwt { public static String parseAlgorithm(ByteBuf token) { try { ByteBuf header = header(token); ByteBuffer decodedHeader = URL_DECODER.decode(header.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedHeader); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if ("alg".equals(name)) { parser.nextToken(); return parser.getText(); } } } catch (Exception e) { throw Exceptions.propagate(e); } return "unknown"; } }
Jwt { public static String parseAlgorithm(ByteBuf token) { try { ByteBuf header = header(token); ByteBuffer decodedHeader = URL_DECODER.decode(header.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedHeader); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if ("alg".equals(name)) { parser.nextToken(); return parser.getText(); } } } catch (Exception e) { throw Exceptions.propagate(e); } return "unknown"; }  }
Jwt { public static String parseAlgorithm(ByteBuf token) { try { ByteBuf header = header(token); ByteBuffer decodedHeader = URL_DECODER.decode(header.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedHeader); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if ("alg".equals(name)) { parser.nextToken(); return parser.getText(); } } } catch (Exception e) { throw Exceptions.propagate(e); } return "unknown"; }  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 String parseAlgorithm(ByteBuf token) { try { ByteBuf header = header(token); ByteBuffer decodedHeader = URL_DECODER.decode(header.nioBuffer()); InputStreamWrapper is = IS_WRAPPER.get(); is.wrap(decodedHeader); JsonParser parser = JSON_FACTORY.createParser(is); while (parser.nextToken() != JsonToken.END_OBJECT) { String name = parser.getCurrentName(); if ("alg".equals(name)) { parser.nextToken(); return parser.getText(); } } } catch (Exception e) { throw Exceptions.propagate(e); } return "unknown"; }  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);  }