Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(893)

Unified Diff: google-oauth-client-java6/src/main/java/com/google/api/client/extensions/java6/auth/oauth2/FilePersistedCredential.java

Issue 6242068: [oauth] FileCredentialStore implementation of CredentialStore interface (Closed) Base URL: https://google-oauth-java-client.googlecode.com/hg/
Patch Set: Changing the changeset to 1.11 Created 1 year, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: google-oauth-client-java6/src/main/java/com/google/api/client/extensions/java6/auth/oauth2/FilePersistedCredential.java
===================================================================
new file mode 100644
--- /dev/null
+++ b/google-oauth-client-java6/src/main/java/com/google/api/client/extensions/java6/auth/oauth2/FilePersistedCredential.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011 Google Inc.
rmistry 2012/06/20 13:45:39 2012
rafael.naufal 2012/06/29 20:19:03 Done.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.api.client.extensions.java6.auth.oauth2;
+
+import com.google.api.client.auth.oauth2.Credential;
+import com.google.api.client.json.GenericJson;
+import com.google.api.client.util.Key;
+
+/**
+ * Persisted credential implementation to be used exclusively with
+ * {@link FileCredentialStore}.
+ *
+ * @author Rafael Naufal
+ */
+public class FilePersistedCredential extends GenericJson {
+
+ /** Access token or {@code null} for none. */
+ @Key("access_token")
+ private String accessToken;
+
+ /** Refresh token {@code null} for none. */
+ @Key("refresh_token")
+ private String refreshToken;
+
+ /** Expiration time in milliseconds {@code null} for none. */
+ @Key("expiration_time_millis")
+ private Long expirationTimeMillis;
+
+ /**
+ * Store information from the credential.
+ *
+ * @param userId
+ * user ID whose credential needs to be stored
+ * @param credential
+ * credential whose {@link Credential#getAccessToken access
+ * token}, {@link Credential#getRefreshToken refresh token}, and
+ * {@link Credential#getExpirationTimeMilliseconds expiration
+ * time} need to be stored
+ */
+ void store(String userId, Credential credential) {
+ this.accessToken = credential.getAccessToken();
+ this.refreshToken = credential.getRefreshToken();
+ this.expirationTimeMillis = credential.getExpirationTimeMilliseconds();
+ }
+
+ /**
+ * @param credential
+ * credential whose {@link Credential#setAccessToken access
+ * token}, {@link Credential#setRefreshToken refresh token}, and
+ * {@link Credential#setExpirationTimeMilliseconds expiration
+ * time} need to be set if the credential already exists in
+ * storage
+ */
+ void load(String userId, Credential credential) {
+ credential.setAccessToken(this.accessToken);
+ credential.setRefreshToken(this.refreshToken);
+ credential.setExpirationTimeMilliseconds(this.expirationTimeMillis);
+ }
+
+ /** Returns the access token. */
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ /** Returns the refresh token. */
+ public String getRefreshToken() {
+ return refreshToken;
+ }
+
+ /** Returns the expiration time in millis. */
+ public Long getExpirationTimeMillis() {
+ return expirationTimeMillis;
+ }
+}

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1278:e6ce13d99bf5