[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorAuthSSHKey 4 extends PhabricatorAuthDAO 5 implements PhabricatorPolicyInterface { 6 7 protected $objectPHID; 8 protected $name; 9 protected $keyType; 10 protected $keyIndex; 11 protected $keyBody; 12 protected $keyComment = ''; 13 protected $isTrusted = 0; 14 15 private $object = self::ATTACHABLE; 16 17 public function getConfiguration() { 18 return array( 19 self::CONFIG_COLUMN_SCHEMA => array( 20 'name' => 'text255', 21 'keyType' => 'text255', 22 'keyIndex' => 'bytes12', 23 'keyBody' => 'text', 24 'keyComment' => 'text255', 25 'isTrusted' => 'bool', 26 ), 27 self::CONFIG_KEY_SCHEMA => array( 28 'key_object' => array( 29 'columns' => array('objectPHID'), 30 ), 31 'key_unique' => array( 32 'columns' => array('keyIndex'), 33 'unique' => true, 34 ), 35 ), 36 ) + parent::getConfiguration(); 37 } 38 39 public function save() { 40 $this->setKeyIndex($this->toPublicKey()->getHash()); 41 return parent::save(); 42 } 43 44 public function toPublicKey() { 45 return PhabricatorAuthSSHPublicKey::newFromStoredKey($this); 46 } 47 48 public function getEntireKey() { 49 $parts = array( 50 $this->getKeyType(), 51 $this->getKeyBody(), 52 $this->getKeyComment(), 53 ); 54 return trim(implode(' ', $parts)); 55 } 56 57 public function getObject() { 58 return $this->assertAttached($this->object); 59 } 60 61 public function attachObject(PhabricatorSSHPublicKeyInterface $object) { 62 $this->object = $object; 63 return $this; 64 } 65 66 67 68 69 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 70 71 72 public function getCapabilities() { 73 return array( 74 PhabricatorPolicyCapability::CAN_VIEW, 75 PhabricatorPolicyCapability::CAN_EDIT, 76 ); 77 } 78 79 public function getPolicy($capability) { 80 return $this->getObject()->getPolicy($capability); 81 } 82 83 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 84 return $this->getObject()->hasAutomaticCapability($capability, $viewer); 85 } 86 87 public function describeAutomaticCapability($capability) { 88 return pht( 89 'SSH keys inherit the policies of the user or object they authenticate.'); 90 } 91 92 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |