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

Side by Side Diff: third_party/gsutil/oauth2_plugin/oauth2_client.py

Issue 212553007: Replaced boto certificate (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Nits Created 6 years, 8 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
« no previous file with comments | « third_party/gsutil/README.chromium ('k') | 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 2010 Google Inc. All Rights Reserved. 1 # Copyright 2010 Google Inc. All Rights Reserved.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 from django.utils import simplejson as json 58 from django.utils import simplejson as json
59 except ImportError: 59 except ImportError:
60 # Try for simplejson 60 # Try for simplejson
61 import simplejson as json 61 import simplejson as json
62 62
63 LOG = logging.getLogger('oauth2_client') 63 LOG = logging.getLogger('oauth2_client')
64 # Lock used for checking/exchanging refresh token, so multithreaded 64 # Lock used for checking/exchanging refresh token, so multithreaded
65 # operation doesn't attempt concurrent refreshes. 65 # operation doesn't attempt concurrent refreshes.
66 token_exchange_lock = threading.Lock() 66 token_exchange_lock = threading.Lock()
67 67
68 # SHA1 sum of the CA certificates file imported from boto.
69 CACERTS_FILE_SHA1SUM = 'ed024a78d9327f8669b3b117d9eac9e3c9460e9b'
70
71 class Error(Exception): 68 class Error(Exception):
72 """Base exception for the OAuth2 module.""" 69 """Base exception for the OAuth2 module."""
73 pass 70 pass
74 71
75 72
76 class AccessTokenRefreshError(Error): 73 class AccessTokenRefreshError(Error):
77 """Error trying to exchange a refresh token into an access token.""" 74 """Error trying to exchange a refresh token into an access token."""
78 pass 75 pass
79 76
80 77
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 # constructor for unit testing purposes. 288 # constructor for unit testing purposes.
292 self.datetime_strategy = datetime_strategy 289 self.datetime_strategy = datetime_strategy
293 self._proxy = proxy 290 self._proxy = proxy
294 291
295 self.access_token_cache = access_token_cache or InMemoryTokenCache() 292 self.access_token_cache = access_token_cache or InMemoryTokenCache()
296 293
297 self.ca_certs_file = os.path.join( 294 self.ca_certs_file = os.path.join(
298 os.path.dirname(os.path.abspath(cacerts.__file__)), 'cacerts.txt') 295 os.path.dirname(os.path.abspath(cacerts.__file__)), 'cacerts.txt')
299 296
300 if url_opener is None: 297 if url_opener is None:
301 # Check that the cert file distributed with boto has not been tampered
302 # with.
303 h = sha1()
304 h.update(file(self.ca_certs_file).read())
305 actual_sha1 = h.hexdigest()
306 if actual_sha1 != CACERTS_FILE_SHA1SUM:
307 raise Error(
308 'CA certificates file does not have expected SHA1 sum; '
309 'expected: %s, actual: %s' % (CACERTS_FILE_SHA1SUM, actual_sha1))
310 # TODO(Google): set user agent? 298 # TODO(Google): set user agent?
311 url_opener = urllib2.build_opener( 299 url_opener = urllib2.build_opener(
312 fancy_urllib.FancyProxyHandler(), 300 fancy_urllib.FancyProxyHandler(),
313 fancy_urllib.FancyRedirectHandler(), 301 fancy_urllib.FancyRedirectHandler(),
314 fancy_urllib.FancyHTTPSHandler()) 302 fancy_urllib.FancyHTTPSHandler())
315 self.url_opener = url_opener 303 self.url_opener = url_opener
316 304
317 def _TokenRequest(self, request): 305 def _TokenRequest(self, request):
318 """Make a requst to this client's provider's token endpoint. 306 """Make a requst to this client's provider's token endpoint.
319 307
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 return h.hexdigest() 621 return h.hexdigest()
634 622
635 def GetAuthorizationHeader(self): 623 def GetAuthorizationHeader(self):
636 """Gets the access token HTTP authorication header value. 624 """Gets the access token HTTP authorication header value.
637 625
638 Returns: 626 Returns:
639 The value of an Authorization HTTP header that authenticates 627 The value of an Authorization HTTP header that authenticates
640 requests with an OAuth2 access token based on this refresh token. 628 requests with an OAuth2 access token based on this refresh token.
641 """ 629 """
642 return 'Bearer %s' % self.oauth2_client.GetAccessToken(self).token 630 return 'Bearer %s' % self.oauth2_client.GetAccessToken(self).token
OLDNEW
« no previous file with comments | « third_party/gsutil/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698