Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/storage/PhabricatorAuthSSHKey.php
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | public function attachObject(PhabricatorSSHPublicKeyInterface $object) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function generatePHID() { | public function generatePHID() { | ||||
return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
PhabricatorAuthSSHKeyPHIDType::TYPECONST); | PhabricatorAuthSSHKeyPHIDType::TYPECONST); | ||||
} | } | ||||
public function getURI() { | |||||
$id = $this->getID(); | |||||
return "/auth/sshkey/view/{$id}/"; | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
); | ); | ||||
} | } | ||||
public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
if (!$this->getIsActive()) { | |||||
if ($capability == PhabricatorPolicyCapability::CAN_EDIT) { | |||||
return PhabricatorPolicies::POLICY_NOONE; | |||||
} | |||||
} | |||||
return $this->getObject()->getPolicy($capability); | return $this->getObject()->getPolicy($capability); | ||||
} | } | ||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | ||||
if (!$this->getIsActive()) { | |||||
return false; | |||||
} | |||||
return $this->getObject()->hasAutomaticCapability($capability, $viewer); | return $this->getObject()->hasAutomaticCapability($capability, $viewer); | ||||
} | } | ||||
public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
if (!$this->getIsACtive()) { | |||||
return pht( | |||||
'Deactivated SSH keys can not be edited or reactivated.'); | |||||
} | |||||
return pht( | return pht( | ||||
'SSH keys inherit the policies of the user or object they authenticate.'); | 'SSH keys inherit the policies of the user or object they authenticate.'); | ||||
} | } | ||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */ | /* -( PhabricatorDestructibleInterface )----------------------------------- */ | ||||
public function destroyObjectPermanently( | public function destroyObjectPermanently( | ||||
PhabricatorDestructionEngine $engine) { | PhabricatorDestructionEngine $engine) { | ||||
$this->openTransaction(); | $this->openTransaction(); | ||||
$this->delete(); | $this->delete(); | ||||
$this->saveTransaction(); | $this->saveTransaction(); | ||||
} | } | ||||
} | } |