// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/exception/GalaxyFDSClientException.java
// public class GalaxyFDSClientException extends Exception {
// 
//   public GalaxyFDSClientException() {}
// 
//   public GalaxyFDSClientException(String message) {
//     super(message);
//   }
// 
//   public GalaxyFDSClientException(Throwable cause) {
//     super(cause);
//   }
// 
//   public GalaxyFDSClientException(String message, Throwable cause) {
//     super(message, cause);
//   }
// }
// 
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/model/HttpHeaders.java
// public final class HttpHeaders {
//   /** RFC 1945 (HTTP/1.0) Section 10.2, RFC 2616 (HTTP/1.1) Section 14.8 */
//   public static final String AUTHORIZATION = "Authorization";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.9 */
//   public static final String CACHE_CONTROL = "Cache-Control";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.3, RFC 2616 (HTTP/1.1) Section 14.11 */
//   public static final String CONTENT_ENCODING = "Content-Encoding";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.4, RFC 2616 (HTTP/1.1) Section 14.13 */
//   public static final String CONTENT_LENGTH = "Content-Length";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.15 */
//   public static final String CONTENT_MD5 = "Content-MD5";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.16 */
//   public static final String CONTENT_RANGE = "Content-Range";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.5, RFC 2616 (HTTP/1.1) Section 14.17 */
//   public static final String CONTENT_TYPE = "Content-Type";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.6, RFC 2616 (HTTP/1.1) Section 14.18 */
//   public static final String DATE = "Date";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.10, RFC 2616 (HTTP/1.1) Section 14.29 */
//   public static final String LAST_MODIFIED = "Last-Modified";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.35 */
//   public static final String RANGE = "Range";
// }
// 
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/model/StorageAccessToken.java
// public class StorageAccessToken {
// 
//   private String token;
//   private long expireTime; // ms
// 
//   public StorageAccessToken() {}
// 
//   public StorageAccessToken(String token, long expireTime) {
//     this.token = token;
//     this.expireTime = expireTime;
//   }
// 
//   public String getToken() {
//     return token;
//   }
// 
//   public void setToken(String token) {
//     this.token = token;
//   }
// 
//   public long getExpireTime() {
//     return expireTime;
//   }
// 
//   public void setExpireTime(long expireTime) {
//     this.expireTime = expireTime;
//   }
// }


import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import com.google.gson.Gson;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.DefaultHttpClient;
import com.xiaomi.infra.galaxy.fds.android.exception.GalaxyFDSClientException;
import com.xiaomi.infra.galaxy.fds.android.model.HttpHeaders;
import com.xiaomi.infra.galaxy.fds.android.model.StorageAccessToken;
package com.xiaomi.infra.galaxy.fds.android.auth;




public class OAuthCredential implements GalaxyFDSCredential {
  private static final String STORAGE_ACCESS_TOKEN = "storageAccessToken";
  private static final String APP_ID = "appId";
  private static final String OAUTH_APPID = "oauthAppId";
  private static final String OAUTH_ACCESS_TOKEN = "oauthAccessToken";
  private static final String OAUTH_PROVIDER = "oauthProvider";
  private static final String OAUTH_MAC_KEY = "oauthMacKey";
  private static final String OAUTH_MAC_ALGORITHM = "oauthMacAlgorithm";
  private final String HEADER_VALUE = "OAuth";

  private final String appId;
  private final StorageAccessToken storageAccessToken;

  public OAuthCredential(String fdsServiceBaseUri, String appId,
      String oauthAppId, String oauthAccessToken, String oauthProvider,
      String macKey, String macAlgorithm) throws GalaxyFDSClientException {
    this.appId = appId;
    this.storageAccessToken = getStorageAccessToken(fdsServiceBaseUri, appId,
        oauthAppId, oauthAccessToken, oauthProvider, macKey, macAlgorithm);
  }

  private StorageAccessToken getStorageAccessToken(String serviceBaseUri,
      String appId, String oauthAppId, String oauthAccessToken,
      String oauthProvider, String macKey, String macAlgorithm)
      throws GalaxyFDSClientException {
    try {
      HttpClient httpClient = new DefaultHttpClient();
      HttpGet get = new HttpGet(serviceBaseUri + "/?" + STORAGE_ACCESS_TOKEN
          + "&" + APP_ID + "=" + appId
          + "&" + OAUTH_APPID + "=" + oauthAppId
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/exception/GalaxyFDSClientException.java
// public class GalaxyFDSClientException extends Exception {
// 
//   public GalaxyFDSClientException() {}
// 
//   public GalaxyFDSClientException(String message) {
//     super(message);
//   }
// 
//   public GalaxyFDSClientException(Throwable cause) {
//     super(cause);
//   }
// 
//   public GalaxyFDSClientException(String message, Throwable cause) {
//     super(message, cause);
//   }
// }
// 
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/model/HttpHeaders.java
// public final class HttpHeaders {
//   /** RFC 1945 (HTTP/1.0) Section 10.2, RFC 2616 (HTTP/1.1) Section 14.8 */
//   public static final String AUTHORIZATION = "Authorization";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.9 */
//   public static final String CACHE_CONTROL = "Cache-Control";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.3, RFC 2616 (HTTP/1.1) Section 14.11 */
//   public static final String CONTENT_ENCODING = "Content-Encoding";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.4, RFC 2616 (HTTP/1.1) Section 14.13 */
//   public static final String CONTENT_LENGTH = "Content-Length";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.15 */
//   public static final String CONTENT_MD5 = "Content-MD5";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.16 */
//   public static final String CONTENT_RANGE = "Content-Range";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.5, RFC 2616 (HTTP/1.1) Section 14.17 */
//   public static final String CONTENT_TYPE = "Content-Type";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.6, RFC 2616 (HTTP/1.1) Section 14.18 */
//   public static final String DATE = "Date";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.10, RFC 2616 (HTTP/1.1) Section 14.29 */
//   public static final String LAST_MODIFIED = "Last-Modified";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.35 */
//   public static final String RANGE = "Range";
// }
// 
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/model/StorageAccessToken.java
// public class StorageAccessToken {
// 
//   private String token;
//   private long expireTime; // ms
// 
//   public StorageAccessToken() {}
// 
//   public StorageAccessToken(String token, long expireTime) {
//     this.token = token;
//     this.expireTime = expireTime;
//   }
// 
//   public String getToken() {
//     return token;
//   }
// 
//   public void setToken(String token) {
//     this.token = token;
//   }
// 
//   public long getExpireTime() {
//     return expireTime;
//   }
// 
//   public void setExpireTime(long expireTime) {
//     this.expireTime = expireTime;
//   }
// }


// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/auth/OAuthCredential.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import com.google.gson.Gson;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.DefaultHttpClient;
import com.xiaomi.infra.galaxy.fds.android.exception.GalaxyFDSClientException;
import com.xiaomi.infra.galaxy.fds.android.model.HttpHeaders;
import com.xiaomi.infra.galaxy.fds.android.model.StorageAccessToken;

package com.xiaomi.infra.galaxy.fds.android.auth;




public class OAuthCredential implements GalaxyFDSCredential {
  private static final String STORAGE_ACCESS_TOKEN = "storageAccessToken";
  private static final String APP_ID = "appId";
  private static final String OAUTH_APPID = "oauthAppId";
  private static final String OAUTH_ACCESS_TOKEN = "oauthAccessToken";
  private static final String OAUTH_PROVIDER = "oauthProvider";
  private static final String OAUTH_MAC_KEY = "oauthMacKey";
  private static final String OAUTH_MAC_ALGORITHM = "oauthMacAlgorithm";
  private final String HEADER_VALUE = "OAuth";

  private final String appId;
  private final StorageAccessToken storageAccessToken;

  public OAuthCredential(String fdsServiceBaseUri, String appId,
      String oauthAppId, String oauthAccessToken, String oauthProvider,
      String macKey, String macAlgorithm) throws GalaxyFDSClientException {
    this.appId = appId;
    this.storageAccessToken = getStorageAccessToken(fdsServiceBaseUri, appId,
        oauthAppId, oauthAccessToken, oauthProvider, macKey, macAlgorithm);
  }

  private StorageAccessToken getStorageAccessToken(String serviceBaseUri,
      String appId, String oauthAppId, String oauthAccessToken,
      String oauthProvider, String macKey, String macAlgorithm)
      throws GalaxyFDSClientException {
    try {
      HttpClient httpClient = new DefaultHttpClient();
      HttpGet get = new HttpGet(serviceBaseUri + "/?" + STORAGE_ACCESS_TOKEN
          + "&" + APP_ID + "=" + appId
          + "&" + OAUTH_APPID + "=" + oauthAppId
          + "&" + OAUTH_ACCESS_TOKEN + "=" + oauthAccessToken