Path: blob/master/src/applications/almanac/management/AlmanacManagementUntrustKeyWorkflow.php
12256 views
<?php12final class AlmanacManagementUntrustKeyWorkflow3extends AlmanacManagementWorkflow {45protected function didConstruct() {6$this7->setName('untrust-key')8->setSynopsis(pht('Revoke trust of a public key.'))9->setArguments(10array(11array(12'name' => 'id',13'param' => 'id',14'help' => pht('ID of the key to revoke trust for.'),15),16));17}1819public function execute(PhutilArgumentParser $args) {20$console = PhutilConsole::getConsole();2122$id = $args->getArg('id');23if (!$id) {24throw new PhutilArgumentUsageException(25pht('Specify a public key to revoke trust for with --id.'));26}2728$key = id(new PhabricatorAuthSSHKeyQuery())29->setViewer($this->getViewer())30->withIDs(array($id))31->executeOne();32if (!$key) {33throw new PhutilArgumentUsageException(34pht('No public key exists with ID "%s".', $id));35}3637if (!$key->getIsTrusted()) {38throw new PhutilArgumentUsageException(39pht('Public key with ID %s is not trusted.', $id));40}4142$key->setIsTrusted(0);43$key->save();4445PhabricatorAuthSSHKeyQuery::deleteSSHKeyCache();4647$console->writeOut(48"**<bg:green> %s </bg>** %s\n",49pht('TRUST REVOKED'),50pht('Trust has been revoked for public key %s.', $id));51}5253}545556