Path: blob/master/src/applications/passphrase/controller/PassphraseCredentialPublicController.php
12262 views
<?php12final class PassphraseCredentialPublicController3extends PassphraseController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();7$id = $request->getURIData('id');89$credential = id(new PassphraseCredentialQuery())10->setViewer($viewer)11->withIDs(array($id))12->requireCapabilities(13array(14PhabricatorPolicyCapability::CAN_VIEW,15))16->executeOne();17if (!$credential) {18return new Aphront404Response();19}2021$type = PassphraseCredentialType::getTypeByConstant(22$credential->getCredentialType());23if (!$type) {24throw new Exception(pht('Credential has invalid type "%s"!', $type));25}2627if (!$type->hasPublicKey()) {28throw new Exception(pht('Credential has no public key!'));29}3031$view_uri = '/'.$credential->getMonogram();3233$public_key = $type->getPublicKey($viewer, $credential);3435$body = id(new PHUIFormLayoutView())36->appendChild(37id(new AphrontFormTextAreaControl())38->setLabel(pht('Public Key'))39->setReadOnly(true)40->setValue($public_key));4142return $this->newDialog()43->setWidth(AphrontDialogView::WIDTH_FORM)44->setTitle(pht('Public Key (%s)', $credential->getMonogram()))45->appendChild($body)46->addCancelButton($view_uri, pht('Done'));4748}4950}515253