Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWorkflow.php
| Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | abstract class ArcanistWorkflow extends Phobject { | ||||
| private $commitMode = self::COMMIT_DISABLE; | private $commitMode = self::COMMIT_DISABLE; | ||||
| private $conduit; | private $conduit; | ||||
| private $conduitURI; | private $conduitURI; | ||||
| private $conduitCredentials; | private $conduitCredentials; | ||||
| private $conduitAuthenticated; | private $conduitAuthenticated; | ||||
| private $forcedConduitVersion; | private $forcedConduitVersion; | ||||
| private $forcedConduitToken; | |||||
| private $conduitTimeout; | private $conduitTimeout; | ||||
| private $userPHID; | private $userPHID; | ||||
| private $userName; | private $userName; | ||||
| private $repositoryAPI; | private $repositoryAPI; | ||||
| private $configurationManager; | private $configurationManager; | ||||
| private $workingCopy; | private $workingCopy; | ||||
| private $arguments; | private $arguments; | ||||
| ▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | /* -( Conduit )------------------------------------------------------------ */ | ||||
| */ | */ | ||||
| final public function forceConduitVersion($version) { | final public function forceConduitVersion($version) { | ||||
| $this->forcedConduitVersion = $version; | $this->forcedConduitVersion = $version; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| /** | /** | ||||
| * Force use of a specific API token. | |||||
| * | |||||
| * Controlled by the --conduit-token flag. | |||||
| * | |||||
| * @param string API token to use. | |||||
| * @return this | |||||
| * @task conduit | |||||
| */ | |||||
| final public function forceConduitToken($token) { | |||||
| $this->forcedConduitToken = $token; | |||||
| return $this; | |||||
| } | |||||
| /** | |||||
| * Get the protocol version the client should identify with. | * Get the protocol version the client should identify with. | ||||
| * | * | ||||
| * @return int Version the client should claim to be. | * @return int Version the client should claim to be. | ||||
| * @task conduit | * @task conduit | ||||
| */ | */ | ||||
| final public function getConduitVersion() { | final public function getConduitVersion() { | ||||
| return nonempty($this->forcedConduitVersion, 6); | return nonempty($this->forcedConduitVersion, 6); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | try { | ||||
| throw new Exception( | throw new Exception( | ||||
| 'Set conduit credentials with setConduitCredentials() before '. | 'Set conduit credentials with setConduitCredentials() before '. | ||||
| 'authenticating conduit!'); | 'authenticating conduit!'); | ||||
| } | } | ||||
| // If we have `token`, this server supports the simpler, new-style | // If we have `token`, this server supports the simpler, new-style | ||||
| // token-based authentication. Use that instead of all the certificate | // token-based authentication. Use that instead of all the certificate | ||||
| // stuff. | // stuff. | ||||
| $token = null; | |||||
| if (isset($credentials['token'])) { | if (isset($credentials['token'])) { | ||||
| $token = $credentials['token']; | |||||
| } | |||||
| if ($this->forcedConduitToken) { | |||||
| $token = $this->forcedConduitToken; | |||||
| } | |||||
| if (strlen($token)) { | |||||
| $conduit = $this->getConduit(); | $conduit = $this->getConduit(); | ||||
| $conduit->setConduitToken($credentials['token']); | $conduit->setConduitToken($token); | ||||
| try { | try { | ||||
| $result = $this->getConduit()->callMethodSynchronous( | $result = $this->getConduit()->callMethodSynchronous( | ||||
| 'user.whoami', | 'user.whoami', | ||||
| array()); | array()); | ||||
| $this->userName = $result['userName']; | $this->userName = $result['userName']; | ||||
| $this->userPHID = $result['phid']; | $this->userPHID = $result['phid']; | ||||
| ▲ Show 20 Lines • Show All 1,614 Lines • Show Last 20 Lines | |||||