[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/almanac/management/ -> AlmanacManagementUntrustKeyWorkflow.php (source)

   1  <?php
   2  
   3  final class AlmanacManagementUntrustKeyWorkflow
   4    extends AlmanacManagementWorkflow {
   5  
   6    public function didConstruct() {
   7      $this
   8        ->setName('untrust-key')
   9        ->setSynopsis(pht('Revoke trust of a public key.'))
  10        ->setArguments(
  11          array(
  12            array(
  13              'name' => 'id',
  14              'param' => 'id',
  15              'help' => pht('ID of the key to revoke trust for.'),
  16            ),
  17          ));
  18    }
  19  
  20    public function execute(PhutilArgumentParser $args) {
  21      $console = PhutilConsole::getConsole();
  22  
  23      $id = $args->getArg('id');
  24      if (!$id) {
  25        throw new PhutilArgumentUsageException(
  26          pht('Specify a public key to revoke trust for with --id.'));
  27      }
  28  
  29      $key = id(new PhabricatorAuthSSHKeyQuery())
  30        ->setViewer($this->getViewer())
  31        ->withIDs(array($id))
  32        ->executeOne();
  33      if (!$key) {
  34        throw new PhutilArgumentUsageException(
  35          pht('No public key exists with ID "%s".', $id));
  36      }
  37  
  38      if (!$key->getIsTrusted()) {
  39        throw new PhutilArgumentUsageException(
  40          pht('Public key with ID %s is not trusted.', $id));
  41      }
  42  
  43      $key->setIsTrusted(0);
  44      $key->save();
  45  
  46      $console->writeOut(
  47        "**<bg:green> %s </bg>** %s\n",
  48        pht('TRUST REVOKED'),
  49        pht('Trust has been revoked for public key %s.', $id));
  50    }
  51  
  52  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1