Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: pkg/oauth2/lib/src/credentials.dart

Issue 12379021: Make oauth2 warning-clean. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library credentials; 5 library credentials;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:json' as JSON; 8 import 'dart:json' as JSON;
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 final List<String> scopes; 43 final List<String> scopes;
44 44
45 /// The date at which these credentials will expire. This is likely to be a 45 /// The date at which these credentials will expire. This is likely to be a
46 /// few seconds earlier than the server's idea of the expiration date. 46 /// few seconds earlier than the server's idea of the expiration date.
47 final DateTime expiration; 47 final DateTime expiration;
48 48
49 /// Whether or not these credentials have expired. Note that it's possible the 49 /// Whether or not these credentials have expired. Note that it's possible the
50 /// credentials will expire shortly after this is called. However, since the 50 /// credentials will expire shortly after this is called. However, since the
51 /// client's expiration date is kept a few seconds earlier than the server's, 51 /// client's expiration date is kept a few seconds earlier than the server's,
52 /// there should be enough leeway to rely on this. 52 /// there should be enough leeway to rely on this.
53 bool get isExpired => expiration != null && new DateTime.now() > expiration; 53 bool get isExpired => expiration != null &&
54 new DateTime.now().isAfter(expiration);
54 55
55 /// Whether it's possible to refresh these credentials. 56 /// Whether it's possible to refresh these credentials.
56 bool get canRefresh => refreshToken != null && tokenEndpoint != null; 57 bool get canRefresh => refreshToken != null && tokenEndpoint != null;
57 58
58 /// Creates a new set of credentials. 59 /// Creates a new set of credentials.
59 /// 60 ///
60 /// This class is usually not constructed directly; rather, it's accessed via 61 /// This class is usually not constructed directly; rather, it's accessed via
61 /// [Client.credentials] after a [Client] is created by 62 /// [Client.credentials] after a [Client] is created by
62 /// [AuthorizationCodeGrant]. Alternately, it may be loaded from a serialized 63 /// [AuthorizationCodeGrant]. Alternately, it may be loaded from a serialized
63 /// form via [Credentials.fromJson]. 64 /// form via [Credentials.fromJson].
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (credentials.refreshToken != null) return credentials; 184 if (credentials.refreshToken != null) return credentials;
184 return new Credentials( 185 return new Credentials(
185 credentials.accessToken, 186 credentials.accessToken,
186 this.refreshToken, 187 this.refreshToken,
187 credentials.tokenEndpoint, 188 credentials.tokenEndpoint,
188 credentials.scopes, 189 credentials.scopes,
189 credentials.expiration); 190 credentials.expiration);
190 }); 191 });
191 } 192 }
192 } 193 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698