@Test public void parseNonToken() { GAuthToken parsed = GAuthToken.tryParseFromString("notgauth|foo"); assertNull(parsed); }
public static GAuthToken tryParseFromString(String rawToken) { if (!rawToken.startsWith(TOKEN_PREFIX)) { return null; } String gauthToken = rawToken.substring(TOKEN_PREFIX.length()); try { Map<String, Object> tokenMap = JsonMapper.parseJson(gauthToken); String token = (String) tokenMap.get(TOKEN_KEY); @SuppressWarnings("unchecked") Map<String, Object> auth = (Map<String, Object>) tokenMap.get(AUTH_KEY); return new GAuthToken(token, auth); } catch (IOException e) { throw new RuntimeException("Failed to parse gauth token", e); } }
GAuthToken { public static GAuthToken tryParseFromString(String rawToken) { if (!rawToken.startsWith(TOKEN_PREFIX)) { return null; } String gauthToken = rawToken.substring(TOKEN_PREFIX.length()); try { Map<String, Object> tokenMap = JsonMapper.parseJson(gauthToken); String token = (String) tokenMap.get(TOKEN_KEY); @SuppressWarnings("unchecked") Map<String, Object> auth = (Map<String, Object>) tokenMap.get(AUTH_KEY); return new GAuthToken(token, auth); } catch (IOException e) { throw new RuntimeException("Failed to parse gauth token", e); } } }
GAuthToken { public static GAuthToken tryParseFromString(String rawToken) { if (!rawToken.startsWith(TOKEN_PREFIX)) { return null; } String gauthToken = rawToken.substring(TOKEN_PREFIX.length()); try { Map<String, Object> tokenMap = JsonMapper.parseJson(gauthToken); String token = (String) tokenMap.get(TOKEN_KEY); @SuppressWarnings("unchecked") Map<String, Object> auth = (Map<String, Object>) tokenMap.get(AUTH_KEY); return new GAuthToken(token, auth); } catch (IOException e) { throw new RuntimeException("Failed to parse gauth token", e); } } GAuthToken(String token, Map<String, Object> auth); }
GAuthToken { public static GAuthToken tryParseFromString(String rawToken) { if (!rawToken.startsWith(TOKEN_PREFIX)) { return null; } String gauthToken = rawToken.substring(TOKEN_PREFIX.length()); try { Map<String, Object> tokenMap = JsonMapper.parseJson(gauthToken); String token = (String) tokenMap.get(TOKEN_KEY); @SuppressWarnings("unchecked") Map<String, Object> auth = (Map<String, Object>) tokenMap.get(AUTH_KEY); return new GAuthToken(token, auth); } catch (IOException e) { throw new RuntimeException("Failed to parse gauth token", e); } } GAuthToken(String token, Map<String, Object> auth); static GAuthToken tryParseFromString(String rawToken); String serializeToString(); String getToken(); Map<String, Object> getAuth(); }
GAuthToken { public static GAuthToken tryParseFromString(String rawToken) { if (!rawToken.startsWith(TOKEN_PREFIX)) { return null; } String gauthToken = rawToken.substring(TOKEN_PREFIX.length()); try { Map<String, Object> tokenMap = JsonMapper.parseJson(gauthToken); String token = (String) tokenMap.get(TOKEN_KEY); @SuppressWarnings("unchecked") Map<String, Object> auth = (Map<String, Object>) tokenMap.get(AUTH_KEY); return new GAuthToken(token, auth); } catch (IOException e) { throw new RuntimeException("Failed to parse gauth token", e); } } GAuthToken(String token, Map<String, Object> auth); static GAuthToken tryParseFromString(String rawToken); String serializeToString(); String getToken(); Map<String, Object> getAuth();  }