private static String getNetRC(OAuthTokenInfo accessTokenInfo) { StringBuilder sb = new StringBuilder(); sb.append("machine "); sb.append(accessTokenInfo.resourceHost()); sb.append(" login "); sb.append(accessTokenInfo.username()); sb.append(" password "); sb.append(accessTokenInfo.accessToken()); return sb.toString(); }
private static long getExpiresAt(OAuthTokenInfo tokenInfo) { if (tokenInfo.expiresAt() == null) { return Long.MAX_VALUE; } long expiresAt; try { expiresAt = Long.parseLong(tokenInfo.expiresAt()); } catch (NumberFormatException e) { return Long.MAX_VALUE; } return expiresAt; }
private static String getCookie(OAuthTokenInfo accessTokenInfo) { StringBuilder sb = new StringBuilder(); sb.append(accessTokenInfo.resourceHost()); sb.append("\tFALSE\t/\tTRUE\t"); sb.append(getExpiresAtSeconds(accessTokenInfo)); sb.append("\tgit-"); sb.append(accessTokenInfo.username()); sb.append('\t'); sb.append(accessTokenInfo.accessToken()); if (accessTokenInfo.providerId() != null) { sb.append('@').append(accessTokenInfo.providerId()); } return sb.toString(); }