@Test public void test_read2() { tokenReader = new TokenReader<String>() { protected String build(String rawString, String decodedHeader, String decodedBody, String encodedSignature) { return null; } }; String accessToken = "BadToken"; try { tokenReader.read(accessToken); Assert.fail("failed test"); }catch (IllegalArgumentException e) { } }
public T read(String base64String) { if (base64String == null || base64String.isEmpty()) { throw new IllegalArgumentException("Impossible to obtain a Token from a null or empty string"); } StringBuilder buffer = new StringBuilder(); BufferedReader reader = new BufferedReader(new StringReader(base64String)); String line = null; try { while ((line = reader.readLine()) != null) { buffer.append(line.trim()); } } catch (IOException e) { } finally { try { reader.close(); } catch (IOException e) { } } Matcher matcher = base64urlTokenPattern.matcher(buffer.toString()); if (!matcher.matches()) { throw new IllegalArgumentException(base64String + "is not a valid Token, it does not match with the pattern: " + base64urlTokenPattern.pattern()); } String header = matcher.group(1); String decodedHeader = base64Decode(header); String body = matcher.group(2); String decodedBody = base64Decode(body); String signature = matcher.group(3); return build(base64String, decodedHeader, decodedBody, signature); }
TokenReader extends TokenDecoder { public T read(String base64String) { if (base64String == null || base64String.isEmpty()) { throw new IllegalArgumentException("Impossible to obtain a Token from a null or empty string"); } StringBuilder buffer = new StringBuilder(); BufferedReader reader = new BufferedReader(new StringReader(base64String)); String line = null; try { while ((line = reader.readLine()) != null) { buffer.append(line.trim()); } } catch (IOException e) { } finally { try { reader.close(); } catch (IOException e) { } } Matcher matcher = base64urlTokenPattern.matcher(buffer.toString()); if (!matcher.matches()) { throw new IllegalArgumentException(base64String + "is not a valid Token, it does not match with the pattern: " + base64urlTokenPattern.pattern()); } String header = matcher.group(1); String decodedHeader = base64Decode(header); String body = matcher.group(2); String decodedBody = base64Decode(body); String signature = matcher.group(3); return build(base64String, decodedHeader, decodedBody, signature); } }
TokenReader extends TokenDecoder { public T read(String base64String) { if (base64String == null || base64String.isEmpty()) { throw new IllegalArgumentException("Impossible to obtain a Token from a null or empty string"); } StringBuilder buffer = new StringBuilder(); BufferedReader reader = new BufferedReader(new StringReader(base64String)); String line = null; try { while ((line = reader.readLine()) != null) { buffer.append(line.trim()); } } catch (IOException e) { } finally { try { reader.close(); } catch (IOException e) { } } Matcher matcher = base64urlTokenPattern.matcher(buffer.toString()); if (!matcher.matches()) { throw new IllegalArgumentException(base64String + "is not a valid Token, it does not match with the pattern: " + base64urlTokenPattern.pattern()); } String header = matcher.group(1); String decodedHeader = base64Decode(header); String body = matcher.group(2); String decodedBody = base64Decode(body); String signature = matcher.group(3); return build(base64String, decodedHeader, decodedBody, signature); }  }
TokenReader extends TokenDecoder { public T read(String base64String) { if (base64String == null || base64String.isEmpty()) { throw new IllegalArgumentException("Impossible to obtain a Token from a null or empty string"); } StringBuilder buffer = new StringBuilder(); BufferedReader reader = new BufferedReader(new StringReader(base64String)); String line = null; try { while ((line = reader.readLine()) != null) { buffer.append(line.trim()); } } catch (IOException e) { } finally { try { reader.close(); } catch (IOException e) { } } Matcher matcher = base64urlTokenPattern.matcher(buffer.toString()); if (!matcher.matches()) { throw new IllegalArgumentException(base64String + "is not a valid Token, it does not match with the pattern: " + base64urlTokenPattern.pattern()); } String header = matcher.group(1); String decodedHeader = base64Decode(header); String body = matcher.group(2); String decodedBody = base64Decode(body); String signature = matcher.group(3); return build(base64String, decodedHeader, decodedBody, signature); }  T read(String base64String); }
TokenReader extends TokenDecoder { public T read(String base64String) { if (base64String == null || base64String.isEmpty()) { throw new IllegalArgumentException("Impossible to obtain a Token from a null or empty string"); } StringBuilder buffer = new StringBuilder(); BufferedReader reader = new BufferedReader(new StringReader(base64String)); String line = null; try { while ((line = reader.readLine()) != null) { buffer.append(line.trim()); } } catch (IOException e) { } finally { try { reader.close(); } catch (IOException e) { } } Matcher matcher = base64urlTokenPattern.matcher(buffer.toString()); if (!matcher.matches()) { throw new IllegalArgumentException(base64String + "is not a valid Token, it does not match with the pattern: " + base64urlTokenPattern.pattern()); } String header = matcher.group(1); String decodedHeader = base64Decode(header); String body = matcher.group(2); String decodedBody = base64Decode(body); String signature = matcher.group(3); return build(base64String, decodedHeader, decodedBody, signature); }  T read(String base64String);  }