summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOluwatobi Bashir-Bello <nbashirbello@google.com>2014-06-23 08:44:41 -0400
committerOluwatobi Bashir-Bello <nbashirbello@google.com>2014-06-23 08:44:41 -0400
commit7fb1a2e9ec3685e48a75e5fd6dc5fbdc08046213 (patch)
treea0915b6c48630c4c2c4cd29cc945e5f53891dca1
parentb03bc8dbe6d0f3c79c57c32271088ff4505d5f7d (diff)
downloadcloud-7fb1a2e9ec3685e48a75e5fd6dc5fbdc08046213.tar.gz
Add the client info.
Change-Id: I6e19244143557f33bf27e00f225356bedef48abe
-rw-r--r--lib-working/google-gct-login-context-pg.jarbin0 -> 604 bytes
-rw-r--r--login/login.iml9
-rw-r--r--login/src/com/google/gct/login/GoogleLogin.java52
3 files changed, 34 insertions, 27 deletions
diff --git a/lib-working/google-gct-login-context-pg.jar b/lib-working/google-gct-login-context-pg.jar
new file mode 100644
index 0000000..a0e8f00
--- /dev/null
+++ b/lib-working/google-gct-login-context-pg.jar
Binary files differ
diff --git a/login/login.iml b/login/login.iml
index 1f48ab9..897f97a 100644
--- a/login/login.iml
+++ b/login/login.iml
@@ -77,6 +77,15 @@
</library>
</orderEntry>
<orderEntry type="module" module-name="platform-impl" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../lib-working/google-gct-login-context-pg.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
</component>
</module>
diff --git a/login/src/com/google/gct/login/GoogleLogin.java b/login/src/com/google/gct/login/GoogleLogin.java
index d8956f7..549a5e9 100644
--- a/login/src/com/google/gct/login/GoogleLogin.java
+++ b/login/src/com/google/gct/login/GoogleLogin.java
@@ -55,9 +55,7 @@ import java.util.SortedSet;
// TODO: explore changing class to an application service
public class GoogleLogin {
- private static final String CLIENT_ID = "ANDROID_CLIENT_ID";
- private static final String CLIENT_SECRET = "ANDROID_CLIENT_SECRET";
- private ClientIdSecretPair clientInfo;
+ private ClientInfo clientInfo;
private AndroidUiFacade uiFacade;
private AndroidPreferencesOAuthDataStore dataStore;
private CredentialedUserRoster users;
@@ -69,7 +67,7 @@ public class GoogleLogin {
* Constructor
*/
private GoogleLogin() {
- this.clientInfo = getClientIdAndSecretFromExtensionPoints();
+ this.clientInfo = getClientInfo();
this.uiFacade = new AndroidUiFacade();
this.users = new CredentialedUserRoster();
this.dataStore = new AndroidPreferencesOAuthDataStore();
@@ -437,8 +435,8 @@ public class GoogleLogin {
private GoogleLoginState createGoogleLoginState() {
GoogleLoginState state =
new GoogleLoginState(
- clientInfo.getClientId(),
- clientInfo.getClientSecret(),
+ clientInfo.getId(),
+ clientInfo.getInfo(),
OAuthScopeRegistry.getScopes(),
new AndroidPreferencesOAuthDataStore(),
uiFacade,
@@ -449,18 +447,18 @@ public class GoogleLogin {
}
/**
- * Returns the OAuth 2.0 Client ID and Secret for Android Studio in a {@link ClientIdSecretPair}.
- * @return the OAuth 2.0 Client ID and Secret for Android Studio in a {@link ClientIdSecretPair}.
+ * Returns the Client Info for Android Studio in a {@link com.google.gct.login.GoogleLogin.ClientInfo}.
+ * @return the Client Info for Android Studio in a {@link com.google.gct.login.GoogleLogin.ClientInfo}.
*/
- private ClientIdSecretPair getClientIdAndSecretFromExtensionPoints() {
- String clientId = System.getenv().get(CLIENT_ID);
- String clientSecret = System.getenv().get(CLIENT_SECRET);
- if (clientId != null && clientId.trim().length() > 0
- && clientSecret != null && clientSecret.trim().length() > 0) {
- return new ClientIdSecretPair(clientId, clientSecret);
+ private ClientInfo getClientInfo() {
+ String id = LoginContext.getId();
+ String info = LoginContext.getInfo();
+ if (id != null && id.trim().length() > 0
+ && info != null && info.trim().length() > 0) {
+ return new ClientInfo(id, info);
}
- throw new IllegalStateException("The Google OAuth 2.0 Client id and/or secret for Android Studio was not found");
+ throw new IllegalStateException("The client information for Android Studio was not found");
}
// TODO: update code to specify parent
@@ -480,24 +478,24 @@ public class GoogleLogin {
}
/**
- * A pair consisting of the OAuth client ID and OAuth client secret for a client application.
+ * The client information for an application.
*/
@Immutable
- private static class ClientIdSecretPair {
- private final String clientId;
- private final String clientSecret;
+ private static class ClientInfo {
+ private final String id;
+ private final String info;
- public ClientIdSecretPair(String clientId, String clientSecret) {
- this.clientId = clientId;
- this.clientSecret = clientSecret;
+ public ClientInfo(String id, String info) {
+ this.id = id;
+ this.info = info;
}
- public String getClientId() {
- return clientId;
+ public String getId() {
+ return id;
}
- public String getClientSecret() {
- return clientSecret;
+ public String getInfo() {
+ return info;
}
}
@@ -531,7 +529,7 @@ public class GoogleLogin {
}
AuthorizationCodeRequestUrl authCodeRequestUrl =
- new AuthorizationCodeRequestUrl(GoogleOAuthConstants.AUTHORIZATION_SERVER_URL, clientInfo.getClientId())
+ new AuthorizationCodeRequestUrl(GoogleOAuthConstants.AUTHORIZATION_SERVER_URL, clientInfo.getId())
.setRedirectUri(redirectUrl)
.setScopes(OAuthScopeRegistry.getScopes());