libv8 5.3.332.38.5 → 5.6.326.50.0beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (352) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +2 -0
  4. data/ext/libv8/builder.rb +2 -2
  5. data/lib/libv8/version.rb +1 -1
  6. data/patches/0001-Build-a-standalone-static-library.patch +4 -4
  7. data/patches/0002-Don-t-compile-unnecessary-stuff.patch +16 -11
  8. data/patches/0003-Use-the-fPIC-flag-for-the-static-library.patch +4 -4
  9. data/patches/{0005-Do-not-embed-debug-symbols-in-macOS-libraries.patch → 0004-Do-not-embed-debug-symbols-in-macOS-libraries.patch} +4 -4
  10. data/vendor/depot_tools/.gitignore +4 -0
  11. data/vendor/depot_tools/OWNERS +0 -2
  12. data/vendor/depot_tools/PRESUBMIT.py +20 -23
  13. data/vendor/depot_tools/README.gclient.md +3 -3
  14. data/vendor/depot_tools/README.git-cl.md +13 -12
  15. data/vendor/depot_tools/README.md +2 -3
  16. data/vendor/depot_tools/WATCHLISTS +0 -1
  17. data/vendor/depot_tools/appengine_mapper.py +23 -0
  18. data/vendor/depot_tools/apply_issue.py +2 -8
  19. data/vendor/depot_tools/bootstrap/win/README.md +1 -8
  20. data/vendor/depot_tools/bootstrap/win/git_bootstrap.py +6 -16
  21. data/vendor/depot_tools/bootstrap/win/git_version.txt +1 -1
  22. data/vendor/depot_tools/bootstrap/win/git_version_bleeding_edge.txt +1 -1
  23. data/vendor/depot_tools/checkout.py +20 -433
  24. data/vendor/depot_tools/cipd +73 -0
  25. data/vendor/depot_tools/cipd.bat +12 -0
  26. data/vendor/depot_tools/cipd.ps1 +57 -0
  27. data/vendor/depot_tools/cipd_client_version +1 -0
  28. data/vendor/depot_tools/clang_format.py +9 -6
  29. data/vendor/depot_tools/clang_format_merge_driver +8 -0
  30. data/vendor/depot_tools/clang_format_merge_driver.bat +11 -0
  31. data/vendor/depot_tools/clang_format_merge_driver.py +67 -0
  32. data/vendor/depot_tools/codereview.settings +3 -2
  33. data/vendor/depot_tools/commit_queue.py +1 -1
  34. data/vendor/depot_tools/cpplint.py +2 -0
  35. data/vendor/depot_tools/fetch.py +1 -54
  36. data/vendor/depot_tools/fetch_configs/android.py +2 -2
  37. data/vendor/depot_tools/fetch_configs/breakpad.py +2 -3
  38. data/vendor/depot_tools/fetch_configs/chromium.py +2 -3
  39. data/vendor/depot_tools/fetch_configs/crashpad.py +2 -2
  40. data/vendor/depot_tools/fetch_configs/dart.py +2 -3
  41. data/vendor/depot_tools/fetch_configs/dartino.py +2 -3
  42. data/vendor/depot_tools/fetch_configs/dartium.py +2 -3
  43. data/vendor/depot_tools/fetch_configs/depot_tools.py +3 -6
  44. data/vendor/depot_tools/fetch_configs/gyp.py +2 -3
  45. data/vendor/depot_tools/fetch_configs/infra.py +2 -2
  46. data/vendor/depot_tools/fetch_configs/infra_internal.py +2 -2
  47. data/vendor/depot_tools/fetch_configs/ios.py +2 -2
  48. data/vendor/depot_tools/fetch_configs/ios_internal.py +2 -3
  49. data/vendor/depot_tools/fetch_configs/mojo.py +2 -3
  50. data/vendor/depot_tools/fetch_configs/nacl.py +2 -3
  51. data/vendor/depot_tools/fetch_configs/naclports.py +2 -3
  52. data/vendor/depot_tools/fetch_configs/pdfium.py +2 -2
  53. data/vendor/depot_tools/fetch_configs/skia.py +2 -2
  54. data/vendor/depot_tools/fetch_configs/skia_buildbot.py +2 -2
  55. data/vendor/depot_tools/fetch_configs/syzygy.py +2 -2
  56. data/vendor/depot_tools/fetch_configs/v8.py +2 -3
  57. data/vendor/depot_tools/fetch_configs/webrtc.py +5 -3
  58. data/vendor/depot_tools/fetch_configs/webrtc_android.py +2 -2
  59. data/vendor/depot_tools/fetch_configs/webrtc_ios.py +2 -2
  60. data/vendor/depot_tools/fix_encoding.py +6 -6
  61. data/vendor/depot_tools/gclient.py +136 -368
  62. data/vendor/depot_tools/gclient_scm.py +108 -647
  63. data/vendor/depot_tools/gclient_utils.py +22 -86
  64. data/vendor/depot_tools/gerrit_client.py +105 -0
  65. data/vendor/depot_tools/gerrit_util.py +174 -67
  66. data/vendor/depot_tools/git-crrev-parse +6 -7
  67. data/vendor/depot_tools/git-gs +1 -1
  68. data/vendor/depot_tools/git_cache.py +68 -18
  69. data/vendor/depot_tools/git_cherry_pick_upload.py +4 -4
  70. data/vendor/depot_tools/git_cl.py +1028 -961
  71. data/vendor/depot_tools/git_common.py +2 -3
  72. data/vendor/depot_tools/git_drover.py +0 -1
  73. data/vendor/depot_tools/git_footers.py +3 -43
  74. data/vendor/depot_tools/git_rebase_update.py +9 -1
  75. data/vendor/depot_tools/git_squash_branch.py +1 -1
  76. data/vendor/depot_tools/infra/config/cq.cfg +8 -1
  77. data/vendor/depot_tools/infra/config/recipes.cfg +1 -1
  78. data/vendor/depot_tools/man/html/depot_tools.html +3 -11
  79. data/vendor/depot_tools/man/html/depot_tools_tutorial.html +9 -9
  80. data/vendor/depot_tools/man/html/git-cherry-pick-upload.html +2 -2
  81. data/vendor/depot_tools/man/html/git-drover.html +17 -17
  82. data/vendor/depot_tools/man/html/git-footers.html +2 -2
  83. data/vendor/depot_tools/man/html/git-freeze.html +4 -4
  84. data/vendor/depot_tools/man/html/git-hyper-blame.html +2 -2
  85. data/vendor/depot_tools/man/html/git-map-branches.html +2 -2
  86. data/vendor/depot_tools/man/html/git-map.html +2 -2
  87. data/vendor/depot_tools/man/html/git-mark-merge-base.html +2 -2
  88. data/vendor/depot_tools/man/html/git-nav-downstream.html +2 -2
  89. data/vendor/depot_tools/man/html/git-nav-upstream.html +2 -2
  90. data/vendor/depot_tools/man/html/git-new-branch.html +2 -2
  91. data/vendor/depot_tools/man/html/git-rebase-update.html +2 -2
  92. data/vendor/depot_tools/man/html/git-rename-branch.html +2 -2
  93. data/vendor/depot_tools/man/html/git-reparent-branch.html +2 -2
  94. data/vendor/depot_tools/man/html/git-retry.html +3 -3
  95. data/vendor/depot_tools/man/html/git-squash-branch.html +3 -3
  96. data/vendor/depot_tools/man/html/git-thaw.html +2 -2
  97. data/vendor/depot_tools/man/html/git-upstream-diff.html +3 -3
  98. data/vendor/depot_tools/man/man1/git-cherry-pick-upload.1 +4 -4
  99. data/vendor/depot_tools/man/man1/git-drover.1 +19 -19
  100. data/vendor/depot_tools/man/man1/git-footers.1 +4 -4
  101. data/vendor/depot_tools/man/man1/git-freeze.1 +6 -6
  102. data/vendor/depot_tools/man/man1/git-hyper-blame.1 +4 -4
  103. data/vendor/depot_tools/man/man1/git-map-branches.1 +4 -4
  104. data/vendor/depot_tools/man/man1/git-map.1 +4 -4
  105. data/vendor/depot_tools/man/man1/git-mark-merge-base.1 +4 -4
  106. data/vendor/depot_tools/man/man1/git-nav-downstream.1 +4 -4
  107. data/vendor/depot_tools/man/man1/git-nav-upstream.1 +4 -4
  108. data/vendor/depot_tools/man/man1/git-new-branch.1 +4 -4
  109. data/vendor/depot_tools/man/man1/git-rebase-update.1 +4 -4
  110. data/vendor/depot_tools/man/man1/git-rename-branch.1 +4 -4
  111. data/vendor/depot_tools/man/man1/git-reparent-branch.1 +4 -4
  112. data/vendor/depot_tools/man/man1/git-retry.1 +5 -5
  113. data/vendor/depot_tools/man/man1/git-squash-branch.1 +5 -5
  114. data/vendor/depot_tools/man/man1/git-thaw.1 +4 -4
  115. data/vendor/depot_tools/man/man1/git-upstream-diff.1 +5 -5
  116. data/vendor/depot_tools/man/man7/depot_tools.7 +5 -10
  117. data/vendor/depot_tools/man/man7/depot_tools_tutorial.7 +4 -4
  118. data/vendor/depot_tools/man/src/depot_tools.txt +1 -1
  119. data/vendor/depot_tools/man/src/depot_tools_tutorial.txt +7 -7
  120. data/vendor/depot_tools/man/src/filter_demo_output.py +2 -2
  121. data/vendor/depot_tools/man/src/git-footers.demo.1.sh +1 -1
  122. data/vendor/depot_tools/man/src/git-retry.txt +1 -1
  123. data/vendor/depot_tools/man/src/git-squash-branch.txt +2 -2
  124. data/vendor/depot_tools/man/src/git-upstream-diff.txt +1 -1
  125. data/vendor/depot_tools/my_activity.py +6 -3
  126. data/vendor/depot_tools/my_reviews.py +1 -1
  127. data/vendor/depot_tools/ninja +2 -2
  128. data/vendor/depot_tools/ninja-linux32 +0 -0
  129. data/vendor/depot_tools/ninja-linux64 +0 -0
  130. data/vendor/depot_tools/ninja-mac +0 -0
  131. data/vendor/depot_tools/ninja.exe +0 -0
  132. data/vendor/depot_tools/owners.py +14 -3
  133. data/vendor/depot_tools/presubmit_canned_checks.py +46 -67
  134. data/vendor/depot_tools/presubmit_support.py +109 -371
  135. data/vendor/depot_tools/pylintrc +83 -56
  136. data/vendor/depot_tools/recipe_modules/OWNERS +1 -0
  137. data/vendor/depot_tools/recipe_modules/bot_update/__init__.py +18 -9
  138. data/vendor/depot_tools/recipe_modules/bot_update/api.py +56 -55
  139. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/basic.json +3 -7
  140. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/basic_output_manifest.json +3 -7
  141. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/basic_with_branch_heads.json +3 -7
  142. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/buildbot.json +52 -0
  143. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/clobber.json +19 -10
  144. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/gerrit_no_rebase_patch_ref.json +19 -10
  145. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/gerrit_no_reset.json +19 -10
  146. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/no_shallow.json +19 -10
  147. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/reset_root_solution_revision.json +19 -10
  148. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/trychange.json +3 -7
  149. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/trychange_oauth2.json +2 -54
  150. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/trychange_oauth2_buildbot.json +56 -0
  151. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/{forced.json → trychange_oauth2_json.json} +6 -9
  152. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/trychange_oauth2_json_win.json +54 -0
  153. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/tryjob.json +9 -9
  154. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/tryjob_fail.json +9 -9
  155. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/tryjob_fail_patch.json +9 -9
  156. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/tryjob_fail_patch_download.json +9 -9
  157. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/tryjob_gerrit_angle.json +20 -10
  158. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/tryjob_gerrit_angle_deprecated.json +59 -0
  159. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/tryjob_v8.json +9 -9
  160. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/tryjob_v8_head_by_default.json +20 -10
  161. data/vendor/depot_tools/recipe_modules/bot_update/example.py +45 -63
  162. data/vendor/depot_tools/recipe_modules/bot_update/resources/bot_update.py +210 -807
  163. data/vendor/depot_tools/recipe_modules/bot_update/test_api.py +34 -45
  164. data/vendor/depot_tools/recipe_modules/cipd/api.py +59 -84
  165. data/vendor/depot_tools/recipe_modules/cipd/example.expected/basic.json +71 -117
  166. data/vendor/depot_tools/recipe_modules/cipd/example.expected/describe-failed.json +14 -60
  167. data/vendor/depot_tools/recipe_modules/cipd/example.expected/describe-many-instances.json +71 -117
  168. data/vendor/depot_tools/recipe_modules/cipd/example.expected/mac64.json +71 -117
  169. data/vendor/depot_tools/recipe_modules/cipd/example.expected/win64.json +71 -117
  170. data/vendor/depot_tools/recipe_modules/cipd/example.py +2 -12
  171. data/vendor/depot_tools/recipe_modules/cipd/test_api.py +0 -9
  172. data/vendor/depot_tools/recipe_modules/depot_tools/api.py +6 -0
  173. data/vendor/depot_tools/recipe_modules/depot_tools/example.expected/basic.json +7 -0
  174. data/vendor/depot_tools/recipe_modules/depot_tools/example.expected/win.json +7 -0
  175. data/vendor/depot_tools/recipe_modules/depot_tools/example.py +3 -0
  176. data/vendor/depot_tools/recipe_modules/gclient/__init__.py +4 -0
  177. data/vendor/depot_tools/recipe_modules/gclient/api.py +9 -22
  178. data/vendor/depot_tools/recipe_modules/gclient/config.py +18 -5
  179. data/vendor/depot_tools/recipe_modules/gclient/example.expected/basic.json +14 -14
  180. data/vendor/depot_tools/recipe_modules/gclient/example.expected/buildbot.json +211 -0
  181. data/vendor/depot_tools/recipe_modules/gclient/example.expected/revision.json +16 -14
  182. data/vendor/depot_tools/recipe_modules/gclient/example.expected/tryserver.json +16 -14
  183. data/vendor/depot_tools/recipe_modules/gclient/example.py +13 -11
  184. data/vendor/depot_tools/recipe_modules/gerrit/__init__.py +6 -0
  185. data/vendor/depot_tools/recipe_modules/gerrit/api.py +63 -0
  186. data/vendor/depot_tools/recipe_modules/gerrit/example.expected/basic.json +64 -0
  187. data/vendor/depot_tools/recipe_modules/gerrit/example.py +35 -0
  188. data/vendor/depot_tools/recipe_modules/gerrit/test_api.py +24 -0
  189. data/vendor/depot_tools/recipe_modules/git/__init__.py +4 -0
  190. data/vendor/depot_tools/recipe_modules/git/api.py +155 -142
  191. data/vendor/depot_tools/recipe_modules/git/example.expected/basic.json +43 -17
  192. data/vendor/depot_tools/recipe_modules/git/example.expected/basic_branch.json +43 -17
  193. data/vendor/depot_tools/recipe_modules/git/example.expected/basic_file_name.json +43 -17
  194. data/vendor/depot_tools/recipe_modules/git/example.expected/basic_hash.json +43 -17
  195. data/vendor/depot_tools/recipe_modules/git/example.expected/basic_ref.json +43 -17
  196. data/vendor/depot_tools/recipe_modules/git/example.expected/basic_submodule_update_force.json +43 -17
  197. data/vendor/depot_tools/recipe_modules/git/example.expected/can_fail_build.json +13 -13
  198. data/vendor/depot_tools/recipe_modules/git/example.expected/cannot_fail_build.json +43 -17
  199. data/vendor/depot_tools/recipe_modules/git/example.expected/cat-file_test.json +45 -19
  200. data/vendor/depot_tools/recipe_modules/git/example.expected/count-objects_delta.json +45 -19
  201. data/vendor/depot_tools/recipe_modules/git/example.expected/count-objects_failed.json +43 -17
  202. data/vendor/depot_tools/recipe_modules/git/example.expected/count-objects_with_bad_output.json +43 -17
  203. data/vendor/depot_tools/recipe_modules/git/example.expected/count-objects_with_bad_output_fails_build.json +8 -8
  204. data/vendor/depot_tools/recipe_modules/git/example.expected/curl_trace_file.json +44 -18
  205. data/vendor/depot_tools/recipe_modules/git/example.expected/git-cache-checkout.json +48 -22
  206. data/vendor/depot_tools/recipe_modules/git/example.expected/platform_win.json +43 -17
  207. data/vendor/depot_tools/recipe_modules/git/example.expected/rebase_failed.json +42 -16
  208. data/vendor/depot_tools/recipe_modules/git/example.expected/remote_not_origin.json +43 -17
  209. data/vendor/depot_tools/recipe_modules/git/example.expected/set_got_revision.json +43 -17
  210. data/vendor/depot_tools/recipe_modules/git/example.py +9 -3
  211. data/vendor/depot_tools/recipe_modules/git_cl/__init__.py +4 -0
  212. data/vendor/depot_tools/recipe_modules/git_cl/api.py +8 -8
  213. data/vendor/depot_tools/recipe_modules/git_cl/example.py +1 -1
  214. data/vendor/depot_tools/recipe_modules/gsutil/__init__.py +4 -0
  215. data/vendor/depot_tools/recipe_modules/gsutil/api.py +196 -0
  216. data/vendor/depot_tools/recipe_modules/gsutil/example.expected/basic.json +186 -0
  217. data/vendor/depot_tools/recipe_modules/gsutil/example.py +77 -0
  218. data/vendor/depot_tools/recipe_modules/gsutil/resources/gsutil_smart_retry.py +69 -0
  219. data/vendor/depot_tools/recipe_modules/infra_paths/__init__.py +3 -0
  220. data/vendor/depot_tools/recipe_modules/infra_paths/api.py +20 -3
  221. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/basic.json +3 -1
  222. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_buildbot_linux.json +3 -1
  223. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_buildbot_mac.json +3 -1
  224. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_buildbot_win.json +3 -1
  225. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_kitchen_linux.json +3 -1
  226. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_kitchen_mac.json +3 -1
  227. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_kitchen_win.json +3 -1
  228. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_swarmbucket_linux.json +3 -1
  229. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_swarmbucket_mac.json +3 -1
  230. data/vendor/depot_tools/recipe_modules/infra_paths/example.expected/paths_swarmbucket_win.json +3 -1
  231. data/vendor/depot_tools/recipe_modules/infra_paths/example.py +6 -1
  232. data/vendor/depot_tools/recipe_modules/infra_paths/path_config.py +4 -6
  233. data/vendor/depot_tools/recipe_modules/rietveld/__init__.py +5 -0
  234. data/vendor/depot_tools/recipe_modules/rietveld/api.py +12 -9
  235. data/vendor/depot_tools/recipe_modules/rietveld/example.expected/basic.json +2 -24
  236. data/vendor/depot_tools/recipe_modules/rietveld/example.expected/buildbot.json +30 -0
  237. data/vendor/depot_tools/recipe_modules/rietveld/example.py +12 -6
  238. data/vendor/depot_tools/recipe_modules/tryserver/__init__.py +4 -0
  239. data/vendor/depot_tools/recipe_modules/tryserver/api.py +46 -70
  240. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/set_failure_hash_with_no_steps.json +8 -0
  241. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/{with_svn_patch.json → with_gerrit_patch.json} +1 -31
  242. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/with_gerrit_patch_deprecated.json +39 -0
  243. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/with_git_patch.json +2 -2
  244. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/with_git_patch_luci.json +8 -0
  245. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/with_rietveld_patch.json +3 -3
  246. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/with_rietveld_patch_new.json +3 -3
  247. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/with_wrong_patch.json +1 -1
  248. data/vendor/depot_tools/recipe_modules/tryserver/example.expected/with_wrong_patch_new.json +1 -1
  249. data/vendor/depot_tools/recipe_modules/tryserver/example.py +35 -5
  250. data/vendor/depot_tools/recipes.py +52 -28
  251. data/vendor/depot_tools/repo +216 -69
  252. data/vendor/depot_tools/rietveld.py +20 -15
  253. data/vendor/depot_tools/roll_dep.py +1 -1
  254. data/vendor/depot_tools/scm.py +11 -826
  255. data/vendor/depot_tools/subprocess2.py +5 -5
  256. data/vendor/depot_tools/third_party/cq_client/README.depot_tools.md +2 -0
  257. data/vendor/depot_tools/third_party/cq_client/README.md +5 -1
  258. data/vendor/depot_tools/third_party/cq_client/cq.pb.go +183 -104
  259. data/vendor/depot_tools/third_party/cq_client/cq.proto +43 -27
  260. data/vendor/depot_tools/third_party/cq_client/cq_pb2.py +95 -29
  261. data/vendor/depot_tools/third_party/cq_client/testdata/cq_both.cfg +67 -0
  262. data/vendor/depot_tools/third_party/cq_client/testdata/cq_gerrit.cfg +1 -2
  263. data/vendor/depot_tools/third_party/cq_client/testdata/cq_rietveld.cfg +0 -3
  264. data/vendor/depot_tools/third_party/upload.py +44 -24
  265. data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +0 -5
  266. metadata +38 -93
  267. data/patches/0004-Reinterpret-thread-hash-for-FreeBSD-too.patch +0 -25
  268. data/vendor/depot_tools/git-auto-svn +0 -6
  269. data/vendor/depot_tools/git_auto_svn.py +0 -122
  270. data/vendor/depot_tools/man/html/git-auto-svn.html +0 -837
  271. data/vendor/depot_tools/man/man1/git-auto-svn.1 +0 -113
  272. data/vendor/depot_tools/man/src/_git-auto-svn_desc.helper.txt +0 -1
  273. data/vendor/depot_tools/man/src/git-auto-svn.txt +0 -69
  274. data/vendor/depot_tools/recipe_modules/bot_update/example.expected/off.json +0 -43
  275. data/vendor/depot_tools/recipe_modules/cipd/example.expected/install-failed.json +0 -31
  276. data/vendor/depot_tools/recipe_modules/cipd/resources/bootstrap.py +0 -218
  277. data/vendor/depot_tools/recipe_modules/tryserver/test_api.py +0 -7
  278. data/vendor/depot_tools/third_party/gsutil/CHECKSUM +0 -1
  279. data/vendor/depot_tools/third_party/gsutil/COPYING +0 -202
  280. data/vendor/depot_tools/third_party/gsutil/LICENSE.third_party +0 -295
  281. data/vendor/depot_tools/third_party/gsutil/MANIFEST.in +0 -5
  282. data/vendor/depot_tools/third_party/gsutil/README +0 -38
  283. data/vendor/depot_tools/third_party/gsutil/README.chromium +0 -25
  284. data/vendor/depot_tools/third_party/gsutil/README.pkg +0 -49
  285. data/vendor/depot_tools/third_party/gsutil/ReleaseNotes.txt +0 -825
  286. data/vendor/depot_tools/third_party/gsutil/VERSION +0 -1
  287. data/vendor/depot_tools/third_party/gsutil/gslib/README +0 -5
  288. data/vendor/depot_tools/third_party/gsutil/gslib/__init__.py +0 -22
  289. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/__init__.py +0 -15
  290. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/acls.py +0 -234
  291. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/anon.py +0 -57
  292. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/command_opts.py +0 -116
  293. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/dev.py +0 -139
  294. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/metadata.py +0 -186
  295. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/naming.py +0 -173
  296. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/prod.py +0 -160
  297. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/projects.py +0 -130
  298. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/subdirs.py +0 -110
  299. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/support.py +0 -86
  300. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/versioning.py +0 -242
  301. data/vendor/depot_tools/third_party/gsutil/gslib/addlhelp/wildcards.py +0 -170
  302. data/vendor/depot_tools/third_party/gsutil/gslib/bucket_listing_ref.py +0 -175
  303. data/vendor/depot_tools/third_party/gsutil/gslib/command.py +0 -725
  304. data/vendor/depot_tools/third_party/gsutil/gslib/command_runner.py +0 -102
  305. data/vendor/depot_tools/third_party/gsutil/gslib/commands/__init__.py +0 -15
  306. data/vendor/depot_tools/third_party/gsutil/gslib/commands/cat.py +0 -131
  307. data/vendor/depot_tools/third_party/gsutil/gslib/commands/chacl.py +0 -523
  308. data/vendor/depot_tools/third_party/gsutil/gslib/commands/config.py +0 -662
  309. data/vendor/depot_tools/third_party/gsutil/gslib/commands/cp.py +0 -1819
  310. data/vendor/depot_tools/third_party/gsutil/gslib/commands/disablelogging.py +0 -101
  311. data/vendor/depot_tools/third_party/gsutil/gslib/commands/enablelogging.py +0 -149
  312. data/vendor/depot_tools/third_party/gsutil/gslib/commands/getacl.py +0 -82
  313. data/vendor/depot_tools/third_party/gsutil/gslib/commands/getcors.py +0 -121
  314. data/vendor/depot_tools/third_party/gsutil/gslib/commands/getdefacl.py +0 -86
  315. data/vendor/depot_tools/third_party/gsutil/gslib/commands/getlogging.py +0 -137
  316. data/vendor/depot_tools/third_party/gsutil/gslib/commands/getversioning.py +0 -116
  317. data/vendor/depot_tools/third_party/gsutil/gslib/commands/getwebcfg.py +0 -122
  318. data/vendor/depot_tools/third_party/gsutil/gslib/commands/help.py +0 -218
  319. data/vendor/depot_tools/third_party/gsutil/gslib/commands/ls.py +0 -578
  320. data/vendor/depot_tools/third_party/gsutil/gslib/commands/mb.py +0 -172
  321. data/vendor/depot_tools/third_party/gsutil/gslib/commands/mv.py +0 -159
  322. data/vendor/depot_tools/third_party/gsutil/gslib/commands/perfdiag.py +0 -903
  323. data/vendor/depot_tools/third_party/gsutil/gslib/commands/rb.py +0 -113
  324. data/vendor/depot_tools/third_party/gsutil/gslib/commands/rm.py +0 -237
  325. data/vendor/depot_tools/third_party/gsutil/gslib/commands/setacl.py +0 -138
  326. data/vendor/depot_tools/third_party/gsutil/gslib/commands/setcors.py +0 -145
  327. data/vendor/depot_tools/third_party/gsutil/gslib/commands/setdefacl.py +0 -105
  328. data/vendor/depot_tools/third_party/gsutil/gslib/commands/setmeta.py +0 -420
  329. data/vendor/depot_tools/third_party/gsutil/gslib/commands/setversioning.py +0 -114
  330. data/vendor/depot_tools/third_party/gsutil/gslib/commands/setwebcfg.py +0 -190
  331. data/vendor/depot_tools/third_party/gsutil/gslib/commands/update.py +0 -305
  332. data/vendor/depot_tools/third_party/gsutil/gslib/commands/version.py +0 -150
  333. data/vendor/depot_tools/third_party/gsutil/gslib/exception.py +0 -76
  334. data/vendor/depot_tools/third_party/gsutil/gslib/help_provider.py +0 -81
  335. data/vendor/depot_tools/third_party/gsutil/gslib/name_expansion.py +0 -550
  336. data/vendor/depot_tools/third_party/gsutil/gslib/no_op_auth_plugin.py +0 -30
  337. data/vendor/depot_tools/third_party/gsutil/gslib/plurality_checkable_iterator.py +0 -56
  338. data/vendor/depot_tools/third_party/gsutil/gslib/project_id.py +0 -67
  339. data/vendor/depot_tools/third_party/gsutil/gslib/storage_uri_builder.py +0 -56
  340. data/vendor/depot_tools/third_party/gsutil/gslib/thread_pool.py +0 -79
  341. data/vendor/depot_tools/third_party/gsutil/gslib/util.py +0 -167
  342. data/vendor/depot_tools/third_party/gsutil/gslib/wildcard_iterator.py +0 -498
  343. data/vendor/depot_tools/third_party/gsutil/gsutil +0 -384
  344. data/vendor/depot_tools/third_party/gsutil/gsutil.spec.in +0 -75
  345. data/vendor/depot_tools/third_party/gsutil/oauth2_plugin/__init__.py +0 -22
  346. data/vendor/depot_tools/third_party/gsutil/oauth2_plugin/oauth2_client.py +0 -630
  347. data/vendor/depot_tools/third_party/gsutil/oauth2_plugin/oauth2_client_test.py +0 -374
  348. data/vendor/depot_tools/third_party/gsutil/oauth2_plugin/oauth2_helper.py +0 -103
  349. data/vendor/depot_tools/third_party/gsutil/oauth2_plugin/oauth2_plugin.py +0 -24
  350. data/vendor/depot_tools/third_party/gsutil/pkg_util.py +0 -60
  351. data/vendor/depot_tools/third_party/gsutil/plugins/__init__.py +0 -0
  352. data/vendor/depot_tools/third_party/gsutil/plugins/sso_auth.py +0 -105
@@ -1,22 +0,0 @@
1
- # Copyright 2011 Google Inc. All Rights Reserved.
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a
4
- # copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish, dis-
7
- # tribute, sublicense, and/or sell copies of the Software, and to permit
8
- # persons to whom the Software is furnished to do so, subject to the fol-
9
- # lowing conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included
12
- # in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
- # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16
- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17
- # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
- # IN THE SOFTWARE.
21
-
22
- """Package marker file."""
@@ -1,630 +0,0 @@
1
- # Copyright 2010 Google Inc. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (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
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """An OAuth2 client library.
16
-
17
- This library provides a client implementation of the OAuth2 protocol (see
18
- http://code.google.com/apis/accounts/docs/OAuth2.html).
19
-
20
- **** Experimental API ****
21
-
22
- This module is experimental and is subject to modification or removal without
23
- notice.
24
- """
25
-
26
- # This implementation is inspired by the implementation in
27
- # http://code.google.com/p/google-api-python-client/source/browse/oauth2client/,
28
- # with the following main differences:
29
- # - This library uses the fancy_urllib monkey patch for urllib to correctly
30
- # implement SSL certificate validation.
31
- # - This library does not assume that client code is using the httplib2 library
32
- # to make HTTP requests.
33
- # - This library implements caching of access tokens independent of refresh
34
- # tokens (in the python API client oauth2client, there is a single class that
35
- # encapsulates both refresh and access tokens).
36
-
37
-
38
- import cgi
39
- import datetime
40
- import errno
41
- from hashlib import sha1
42
- import logging
43
- import os
44
- import tempfile
45
- import threading
46
- import urllib
47
- import urllib2
48
- import urlparse
49
-
50
- from boto import cacerts
51
- from third_party import fancy_urllib
52
-
53
- try:
54
- import json
55
- except ImportError:
56
- try:
57
- # Try to import from django, should work on App Engine
58
- from django.utils import simplejson as json
59
- except ImportError:
60
- # Try for simplejson
61
- import simplejson as json
62
-
63
- LOG = logging.getLogger('oauth2_client')
64
- # Lock used for checking/exchanging refresh token, so multithreaded
65
- # operation doesn't attempt concurrent refreshes.
66
- token_exchange_lock = threading.Lock()
67
-
68
- class Error(Exception):
69
- """Base exception for the OAuth2 module."""
70
- pass
71
-
72
-
73
- class AccessTokenRefreshError(Error):
74
- """Error trying to exchange a refresh token into an access token."""
75
- pass
76
-
77
-
78
- class AuthorizationCodeExchangeError(Error):
79
- """Error trying to exchange an authorization code into a refresh token."""
80
- pass
81
-
82
-
83
- class TokenCache(object):
84
- """Interface for OAuth2 token caches."""
85
-
86
- def PutToken(self, key, value):
87
- raise NotImplementedError
88
-
89
- def GetToken(self, key):
90
- raise NotImplementedError
91
-
92
-
93
- class NoopTokenCache(TokenCache):
94
- """A stub implementation of TokenCache that does nothing."""
95
-
96
- def PutToken(self, key, value):
97
- pass
98
-
99
- def GetToken(self, key):
100
- return None
101
-
102
-
103
- class InMemoryTokenCache(TokenCache):
104
- """An in-memory token cache.
105
-
106
- The cache is implemented by a python dict, and inherits the thread-safety
107
- properties of dict.
108
- """
109
-
110
- def __init__(self):
111
- super(InMemoryTokenCache, self).__init__()
112
- self.cache = dict()
113
-
114
- def PutToken(self, key, value):
115
- LOG.info('InMemoryTokenCache.PutToken: key=%s', key)
116
- self.cache[key] = value
117
-
118
- def GetToken(self, key):
119
- value = self.cache.get(key, None)
120
- LOG.info('InMemoryTokenCache.GetToken: key=%s%s present',
121
- key, ' not' if value is None else '')
122
- return value
123
-
124
-
125
- class FileSystemTokenCache(TokenCache):
126
- """An implementation of a token cache that persists tokens on disk.
127
-
128
- Each token object in the cache is stored in serialized form in a separate
129
- file. The cache file's name can be configured via a path pattern that is
130
- parameterized by the key under which a value is cached and optionally the
131
- current processes uid as obtained by os.getuid().
132
-
133
- Since file names are generally publicly visible in the system, it is important
134
- that the cache key does not leak information about the token's value. If
135
- client code computes cache keys from token values, a cryptographically strong
136
- one-way function must be used.
137
- """
138
-
139
- def __init__(self, path_pattern=None):
140
- """Creates a FileSystemTokenCache.
141
-
142
- Args:
143
- path_pattern: Optional string argument to specify the path pattern for
144
- cache files. The argument should be a path with format placeholders
145
- '%(key)s' and optionally '%(uid)s'. If the argument is omitted, the
146
- default pattern
147
- <tmpdir>/oauth2client-tokencache.%(uid)s.%(key)s
148
- is used, where <tmpdir> is replaced with the system temp dir as
149
- obtained from tempfile.gettempdir().
150
- """
151
- super(FileSystemTokenCache, self).__init__()
152
- self.path_pattern = path_pattern
153
- if not path_pattern:
154
- self.path_pattern = os.path.join(
155
- tempfile.gettempdir(), 'oauth2_client-tokencache.%(uid)s.%(key)s')
156
-
157
- def CacheFileName(self, key):
158
- uid = '_'
159
- try:
160
- # os.getuid() doesn't seem to work in Windows
161
- uid = str(os.getuid())
162
- except:
163
- pass
164
- return self.path_pattern % {'key': key, 'uid': uid}
165
-
166
- def PutToken(self, key, value):
167
- """Serializes the value to the key's filename.
168
-
169
- To ensure that written tokens aren't leaked to a different users, we
170
- a) unlink an existing cache file, if any (to ensure we don't fall victim
171
- to symlink attacks and the like),
172
- b) create a new file with O_CREAT | O_EXCL (to ensure nobody is trying to
173
- race us)
174
- If either of these steps fail, we simply give up (but log a warning). Not
175
- caching access tokens is not catastrophic, and failure to create a file
176
- can happen for either of the following reasons:
177
- - someone is attacking us as above, in which case we want to default to
178
- safe operation (not write the token);
179
- - another legitimate process is racing us; in this case one of the two
180
- will win and write the access token, which is fine;
181
- - we don't have permission to remove the old file or write to the
182
- specified directory, in which case we can't recover
183
-
184
- Args:
185
- key: the refresh_token hash key to store.
186
- value: the access_token value to serialize.
187
- """
188
-
189
- cache_file = self.CacheFileName(key)
190
- LOG.info('FileSystemTokenCache.PutToken: key=%s, cache_file=%s',
191
- key, cache_file)
192
- try:
193
- os.unlink(cache_file)
194
- except:
195
- # Ignore failure to unlink the file; if the file exists and can't be
196
- # unlinked, the subsequent open with O_CREAT | O_EXCL will fail.
197
- pass
198
-
199
- flags = os.O_RDWR | os.O_CREAT | os.O_EXCL
200
-
201
- # Accommodate Windows; stolen from python2.6/tempfile.py.
202
- if hasattr(os, 'O_NOINHERIT'):
203
- flags |= os.O_NOINHERIT
204
- if hasattr(os, 'O_BINARY'):
205
- flags |= os.O_BINARY
206
-
207
- try:
208
- fd = os.open(cache_file, flags, 0600)
209
- except (OSError, IOError), e:
210
- LOG.warning('FileSystemTokenCache.PutToken: '
211
- 'Failed to create cache file %s: %s', cache_file, e)
212
- return
213
- f = os.fdopen(fd, 'w+b')
214
- f.write(value.Serialize())
215
- f.close()
216
-
217
- def GetToken(self, key):
218
- """Returns a deserialized access token from the key's filename."""
219
- value = None
220
- cache_file = self.CacheFileName(key)
221
- try:
222
- f = open(cache_file)
223
- value = AccessToken.UnSerialize(f.read())
224
- f.close()
225
- except (IOError, OSError), e:
226
- if e.errno != errno.ENOENT:
227
- LOG.warning('FileSystemTokenCache.GetToken: '
228
- 'Failed to read cache file %s: %s', cache_file, e)
229
- except Exception, e:
230
- LOG.warning('FileSystemTokenCache.GetToken: '
231
- 'Failed to read cache file %s (possibly corrupted): %s',
232
- cache_file, e)
233
-
234
- LOG.info('FileSystemTokenCache.GetToken: key=%s%s present (cache_file=%s)',
235
- key, ' not' if value is None else '', cache_file)
236
- return value
237
-
238
-
239
- class OAuth2Provider(object):
240
- """Encapsulates information about an OAuth2 provider."""
241
-
242
- def __init__(self, label, authorization_uri, token_uri):
243
- """Creates an OAuth2Provider.
244
-
245
- Args:
246
- label: A string identifying this oauth2 provider, e.g. "Google".
247
- authorization_uri: The provider's authorization URI.
248
- token_uri: The provider's token endpoint URI.
249
- """
250
- self.label = label
251
- self.authorization_uri = authorization_uri
252
- self.token_uri = token_uri
253
-
254
-
255
- class OAuth2Client(object):
256
- """An OAuth2 client."""
257
-
258
- def __init__(self, provider, client_id, client_secret,
259
- url_opener=None,
260
- proxy=None,
261
- access_token_cache=None,
262
- datetime_strategy=datetime.datetime):
263
- """Creates an OAuth2Client.
264
-
265
- Args:
266
- provider: The OAuth2Provider provider this client will authenticate
267
- against.
268
- client_id: The OAuth2 client ID of this client.
269
- client_secret: The OAuth2 client secret of this client.
270
- url_opener: An optinal urllib2.OpenerDirector to use for making HTTP
271
- requests to the OAuth2 provider's token endpoint. The provided
272
- url_opener *must* be configured to validate server SSL certificates
273
- for requests to https connections, and to correctly handle proxying of
274
- https requests. If this argument is omitted or None, a suitable
275
- opener based on fancy_urllib is used.
276
- proxy: An optional string specifying a HTTP proxy to be used, in the form
277
- '<proxy>:<port>'. This option is only effective if the url_opener has
278
- been configured with a fancy_urllib.FancyProxyHandler (this is the
279
- case for the default url_opener).
280
- access_token_cache: An optional instance of a TokenCache. If omitted or
281
- None, an InMemoryTokenCache is used.
282
- datetime_strategy: datetime module strategy to use.
283
- """
284
- self.provider = provider
285
- self.client_id = client_id
286
- self.client_secret = client_secret
287
- # datetime_strategy is used to invoke utcnow() on; it is injected into the
288
- # constructor for unit testing purposes.
289
- self.datetime_strategy = datetime_strategy
290
- self._proxy = proxy
291
-
292
- self.access_token_cache = access_token_cache or InMemoryTokenCache()
293
-
294
- self.ca_certs_file = os.path.join(
295
- os.path.dirname(os.path.abspath(cacerts.__file__)), 'cacerts.txt')
296
-
297
- if url_opener is None:
298
- # TODO(Google): set user agent?
299
- url_opener = urllib2.build_opener(
300
- fancy_urllib.FancyProxyHandler(),
301
- fancy_urllib.FancyRedirectHandler(),
302
- fancy_urllib.FancyHTTPSHandler())
303
- self.url_opener = url_opener
304
-
305
- def _TokenRequest(self, request):
306
- """Make a requst to this client's provider's token endpoint.
307
-
308
- Args:
309
- request: A dict with the request parameteres.
310
- Returns:
311
- A tuple (response, error) where,
312
- - response is the parsed JSON response received from the token endpoint,
313
- or None if no parseable response was received, and
314
- - error is None if the request succeeded or
315
- an Exception if an error occurred.
316
- """
317
-
318
- body = urllib.urlencode(request)
319
- LOG.debug('_TokenRequest request: %s', body)
320
- response = None
321
- try:
322
- request = fancy_urllib.FancyRequest(
323
- self.provider.token_uri, data=body)
324
- if self._proxy:
325
- request.set_proxy(self._proxy, 'http')
326
-
327
- request.set_ssl_info(ca_certs=self.ca_certs_file)
328
- result = self.url_opener.open(request)
329
- resp_body = result.read()
330
- LOG.debug('_TokenRequest response: %s', resp_body)
331
- except urllib2.HTTPError, e:
332
- try:
333
- response = json.loads(e.read())
334
- except:
335
- pass
336
- return (response, e)
337
-
338
- try:
339
- response = json.loads(resp_body)
340
- except ValueError, e:
341
- return (None, e)
342
-
343
- return (response, None)
344
-
345
- def GetAccessToken(self, refresh_token):
346
- """Given a RefreshToken, obtains a corresponding access token.
347
-
348
- First, this client's access token cache is checked for an existing,
349
- not-yet-expired access token for the provided refresh token. If none is
350
- found, the client obtains a fresh access token for the provided refresh
351
- token from the OAuth2 provider's token endpoint.
352
-
353
- Args:
354
- refresh_token: The RefreshToken object which to get an access token for.
355
- Returns:
356
- The cached or freshly obtained AccessToken.
357
- Raises:
358
- AccessTokenRefreshError if an error occurs.
359
- """
360
- # Ensure only one thread at a time attempts to get (and possibly refresh)
361
- # the access token. This doesn't prevent concurrent refresh attempts across
362
- # multiple gsutil instances, but at least protects against multiple threads
363
- # simultaneously attempting to refresh when gsutil -m is used.
364
- token_exchange_lock.acquire()
365
- try:
366
- cache_key = refresh_token.CacheKey()
367
- LOG.info('GetAccessToken: checking cache for key %s', cache_key)
368
- access_token = self.access_token_cache.GetToken(cache_key)
369
- LOG.debug('GetAccessToken: token from cache: %s', access_token)
370
- if access_token is None or access_token.ShouldRefresh():
371
- LOG.info('GetAccessToken: fetching fresh access token...')
372
- access_token = self.FetchAccessToken(refresh_token)
373
- LOG.debug('GetAccessToken: fresh access token: %s', access_token)
374
- self.access_token_cache.PutToken(cache_key, access_token)
375
- return access_token
376
- finally:
377
- token_exchange_lock.release()
378
-
379
- def FetchAccessToken(self, refresh_token):
380
- """Fetches an access token from the provider's token endpoint.
381
-
382
- Given a RefreshToken, fetches an access token from this client's OAuth2
383
- provider's token endpoint.
384
-
385
- Args:
386
- refresh_token: The RefreshToken object which to get an access token for.
387
- Returns:
388
- The fetched AccessToken.
389
- Raises:
390
- AccessTokenRefreshError: if an error occurs.
391
- """
392
- request = {
393
- 'grant_type': 'refresh_token',
394
- 'client_id': self.client_id,
395
- 'client_secret': self.client_secret,
396
- 'refresh_token': refresh_token.refresh_token,
397
- }
398
- LOG.debug('FetchAccessToken request: %s', request)
399
-
400
- response, error = self._TokenRequest(request)
401
- LOG.debug(
402
- 'FetchAccessToken response (error = %s): %s', error, response)
403
-
404
- if error:
405
- oauth2_error = ''
406
- if response and response['error']:
407
- oauth2_error = '; OAuth2 error: %s' % response['error']
408
- raise AccessTokenRefreshError(
409
- 'Failed to exchange refresh token into access token; '
410
- 'request failed: %s%s' % (error, oauth2_error))
411
-
412
- if 'access_token' not in response:
413
- raise AccessTokenRefreshError(
414
- 'Failed to exchange refresh token into access token; response: %s' %
415
- response)
416
-
417
- token_expiry = None
418
- if 'expires_in' in response:
419
- token_expiry = (
420
- self.datetime_strategy.utcnow() +
421
- datetime.timedelta(seconds=int(response['expires_in'])))
422
-
423
- return AccessToken(response['access_token'], token_expiry,
424
- datetime_strategy=self.datetime_strategy)
425
-
426
- def GetAuthorizationUri(self, redirect_uri, scopes, extra_params=None):
427
- """Gets the OAuth2 authorization URI and the specified scope(s).
428
-
429
- Applications should navigate/redirect the user's user agent to this URI. The
430
- user will be shown an approval UI requesting the user to approve access of
431
- this client to the requested scopes under the identity of the authenticated
432
- end user.
433
-
434
- The application should expect the user agent to be redirected to the
435
- specified redirect_uri after the user's approval/disapproval.
436
-
437
- Installed applications may use the special redirect_uri
438
- 'urn:ietf:wg:oauth:2.0:oob' to indicate that instead of redirecting the
439
- browser, the user be shown a confirmation page with a verification code.
440
- The application should query the user for this code.
441
-
442
- Args:
443
- redirect_uri: Either the string 'urn:ietf:wg:oauth:2.0:oob' for a
444
- non-web-based application, or a URI that handles the callback from the
445
- authorization server.
446
- scopes: A list of strings specifying the OAuth scopes the application
447
- requests access to.
448
- extra_params: Optional dictionary of additional parameters to be passed to
449
- the OAuth2 authorization URI.
450
- Returns:
451
- The authorization URI for the specified scopes as a string.
452
- """
453
-
454
- request = {
455
- 'response_type': 'code',
456
- 'client_id': self.client_id,
457
- 'redirect_uri': redirect_uri,
458
- 'scope': ' '.join(scopes),
459
- }
460
-
461
- if extra_params:
462
- request.update(extra_params)
463
- url_parts = list(urlparse.urlparse(self.provider.authorization_uri))
464
- # 4 is the index of the query part
465
- request.update(dict(cgi.parse_qsl(url_parts[4])))
466
- url_parts[4] = urllib.urlencode(request)
467
- return urlparse.urlunparse(url_parts)
468
-
469
- def ExchangeAuthorizationCode(self, code, redirect_uri, scopes):
470
- """Exchanges an authorization code for a refresh token.
471
-
472
- Invokes this client's OAuth2 provider's token endpoint to exchange an
473
- authorization code into a refresh token.
474
-
475
- Args:
476
- code: the authrorization code.
477
- redirect_uri: Either the string 'urn:ietf:wg:oauth:2.0:oob' for a
478
- non-web-based application, or a URI that handles the callback from the
479
- authorization server.
480
- scopes: A list of strings specifying the OAuth scopes the application
481
- requests access to.
482
- Returns:
483
- A tuple consting of the resulting RefreshToken and AccessToken.
484
- Raises:
485
- AuthorizationCodeExchangeError: if an error occurs.
486
- """
487
- request = {
488
- 'grant_type': 'authorization_code',
489
- 'client_id': self.client_id,
490
- 'client_secret': self.client_secret,
491
- 'code': code,
492
- 'redirect_uri': redirect_uri,
493
- 'scope': ' '.join(scopes),
494
- }
495
- LOG.debug('ExchangeAuthorizationCode request: %s', request)
496
-
497
- response, error = self._TokenRequest(request)
498
- LOG.debug(
499
- 'ExchangeAuthorizationCode response (error = %s): %s',
500
- error, response)
501
-
502
- if error:
503
- oauth2_error = ''
504
- if response and response['error']:
505
- oauth2_error = '; OAuth2 error: %s' % response['error']
506
- raise AuthorizationCodeExchangeError(
507
- 'Failed to exchange refresh token into access token; '
508
- 'request failed: %s%s' % (str(error), oauth2_error))
509
-
510
- if not 'access_token' in response:
511
- raise AuthorizationCodeExchangeError(
512
- 'Failed to exchange authorization code into access token; '
513
- 'response: %s' % response)
514
-
515
- token_expiry = None
516
- if 'expires_in' in response:
517
- token_expiry = (
518
- self.datetime_strategy.utcnow() +
519
- datetime.timedelta(seconds=int(response['expires_in'])))
520
-
521
- access_token = AccessToken(response['access_token'], token_expiry,
522
- datetime_strategy=self.datetime_strategy)
523
-
524
- refresh_token = None
525
- refresh_token_string = response.get('refresh_token', None)
526
-
527
- token_exchange_lock.acquire()
528
- try:
529
- if refresh_token_string:
530
- refresh_token = RefreshToken(self, refresh_token_string)
531
- self.access_token_cache.PutToken(refresh_token.CacheKey(), access_token)
532
- finally:
533
- token_exchange_lock.release()
534
-
535
- return (refresh_token, access_token)
536
-
537
-
538
- class AccessToken(object):
539
- """Encapsulates an OAuth2 access token."""
540
-
541
- def __init__(self, token, expiry, datetime_strategy=datetime.datetime):
542
- self.token = token
543
- self.expiry = expiry
544
- self.datetime_strategy = datetime_strategy
545
-
546
- @staticmethod
547
- def UnSerialize(query):
548
- """Creates an AccessToken object from its serialized form."""
549
-
550
- def GetValue(d, key):
551
- return (d.get(key, [None]))[0]
552
- kv = cgi.parse_qs(query)
553
- if not kv['token']:
554
- return None
555
- expiry = None
556
- expiry_tuple = GetValue(kv, 'expiry')
557
- if expiry_tuple:
558
- try:
559
- expiry = datetime.datetime(
560
- *[int(n) for n in expiry_tuple.split(',')])
561
- except:
562
- return None
563
- return AccessToken(GetValue(kv, 'token'), expiry)
564
-
565
- def Serialize(self):
566
- """Serializes this object as URI-encoded key-value pairs."""
567
- # There's got to be a better way to serialize a datetime. Unfortunately,
568
- # there is no reliable way to convert into a unix epoch.
569
- kv = {'token': self.token}
570
- if self.expiry:
571
- t = self.expiry
572
- tupl = (t.year, t.month, t.day, t.hour, t.minute, t.second, t.microsecond)
573
- kv['expiry'] = ','.join([str(i) for i in tupl])
574
- return urllib.urlencode(kv)
575
-
576
- def ShouldRefresh(self, time_delta=300):
577
- """Whether the access token needs to be refreshed.
578
-
579
- Args:
580
- time_delta: refresh access token when it expires within time_delta secs.
581
-
582
- Returns:
583
- True if the token is expired or about to expire, False if the
584
- token should be expected to work. Note that the token may still
585
- be rejected, e.g. if it has been revoked server-side.
586
- """
587
- if self.expiry is None:
588
- return False
589
- return (self.datetime_strategy.utcnow()
590
- + datetime.timedelta(seconds=time_delta) > self.expiry)
591
-
592
- def __eq__(self, other):
593
- return self.token == other.token and self.expiry == other.expiry
594
-
595
- def __ne__(self, other):
596
- return not self.__eq__(other)
597
-
598
- def __str__(self):
599
- return 'AccessToken(token=%s, expiry=%sZ)' % (self.token, self.expiry)
600
-
601
-
602
- class RefreshToken(object):
603
- """Encapsulates an OAuth2 refresh token."""
604
-
605
- def __init__(self, oauth2_client, refresh_token):
606
- self.oauth2_client = oauth2_client
607
- self.refresh_token = refresh_token
608
-
609
- def CacheKey(self):
610
- """Computes a cache key for this refresh token.
611
-
612
- The cache key is computed as the SHA1 hash of the token, and as such
613
- satisfies the FileSystemTokenCache requirement that cache keys do not leak
614
- information about token values.
615
-
616
- Returns:
617
- A hash key for this refresh token.
618
- """
619
- h = sha1()
620
- h.update(self.refresh_token)
621
- return h.hexdigest()
622
-
623
- def GetAuthorizationHeader(self):
624
- """Gets the access token HTTP authorication header value.
625
-
626
- Returns:
627
- The value of an Authorization HTTP header that authenticates
628
- requests with an OAuth2 access token based on this refresh token.
629
- """
630
- return 'Bearer %s' % self.oauth2_client.GetAccessToken(self).token