diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1645,6 +1645,7 @@ 'PassphraseSSHPrivateKeyTextCredentialType' => 'applications/passphrase/credentialtype/PassphraseSSHPrivateKeyTextCredentialType.php', 'PassphraseSchemaSpec' => 'applications/passphrase/storage/PassphraseSchemaSpec.php', 'PassphraseSecret' => 'applications/passphrase/storage/PassphraseSecret.php', + 'PassphraseTokenCredentialType' => 'applications/passphrase/credentialtype/PassphraseTokenCredentialType.php', 'PasteConduitAPIMethod' => 'applications/paste/conduit/PasteConduitAPIMethod.php', 'PasteCreateConduitAPIMethod' => 'applications/paste/conduit/PasteCreateConduitAPIMethod.php', 'PasteCreateMailReceiver' => 'applications/paste/mail/PasteCreateMailReceiver.php', @@ -5949,6 +5950,7 @@ 'PassphraseSSHPrivateKeyTextCredentialType' => 'PassphraseSSHPrivateKeyCredentialType', 'PassphraseSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'PassphraseSecret' => 'PassphraseDAO', + 'PassphraseTokenCredentialType' => 'PassphraseCredentialType', 'PasteConduitAPIMethod' => 'ConduitAPIMethod', 'PasteCreateConduitAPIMethod' => 'PasteConduitAPIMethod', 'PasteCreateMailReceiver' => 'PhabricatorMailReceiver', diff --git a/src/applications/passphrase/controller/PassphraseCredentialViewController.php b/src/applications/passphrase/controller/PassphraseCredentialViewController.php --- a/src/applications/passphrase/controller/PassphraseCredentialViewController.php +++ b/src/applications/passphrase/controller/PassphraseCredentialViewController.php @@ -14,20 +14,16 @@ return new Aphront404Response(); } - $type = PassphraseCredentialType::getTypeByConstant( - $credential->getCredentialType()); - if (!$type) { - throw new Exception(pht('Credential has invalid type "%s"!', $type)); - } + $type = $credential->getImplementation(); $timeline = $this->buildTransactionTimeline( $credential, new PassphraseCredentialTransactionQuery()); $timeline->setShouldTerminate(true); - $title = pht('%s %s', 'K'.$credential->getID(), $credential->getName()); + $title = pht('%s %s', $credential->getMonogram(), $credential->getName()); $crumbs = $this->buildApplicationCrumbs(); - $crumbs->addTextCrumb('K'.$credential->getID()); + $crumbs->addTextCrumb($credential->getMonogram()); $crumbs->setBorder(true); $header = $this->buildHeaderView($credential); diff --git a/src/applications/passphrase/credentialtype/PassphraseTokenCredentialType.php b/src/applications/passphrase/credentialtype/PassphraseTokenCredentialType.php new file mode 100644 --- /dev/null +++ b/src/applications/passphrase/credentialtype/PassphraseTokenCredentialType.php @@ -0,0 +1,37 @@ +getCredentialTypeImplementation(); + $credential_type = $object->getImplementation(); if (!$credential_type->shouldRequireUsername()) { break; } diff --git a/src/applications/passphrase/keys/PassphraseAbstractKey.php b/src/applications/passphrase/keys/PassphraseAbstractKey.php --- a/src/applications/passphrase/keys/PassphraseAbstractKey.php +++ b/src/applications/passphrase/keys/PassphraseAbstractKey.php @@ -32,13 +32,13 @@ PassphraseCredential $credential, $provides_type) { - $type = $credential->getCredentialTypeImplementation(); + $type = $credential->getImplementation(); if (!$type) { throw new Exception( pht( 'Credential "%s" is of unknown type "%s"!', - 'K'.$credential->getID(), + $credential->getMonogram(), $credential->getCredentialType())); } @@ -46,7 +46,7 @@ throw new Exception( pht( 'Credential "%s" must provide "%s", but provides "%s"!', - 'K'.$credential->getID(), + $credential->getMonogram(), $provides_type, $type->getProvidesType())); } diff --git a/src/applications/passphrase/query/PassphraseCredentialQuery.php b/src/applications/passphrase/query/PassphraseCredentialQuery.php --- a/src/applications/passphrase/query/PassphraseCredentialQuery.php +++ b/src/applications/passphrase/query/PassphraseCredentialQuery.php @@ -89,6 +89,17 @@ } } + foreach ($page as $key => $credential) { + $type = PassphraseCredentialType::getTypeByConstant( + $credential->getCredentialType()); + if (!$type) { + unset($page[$key]); + continue; + } + + $credential->attachImplementation(clone $type); + } + return $page; } diff --git a/src/applications/passphrase/storage/PassphraseCredential.php b/src/applications/passphrase/storage/PassphraseCredential.php --- a/src/applications/passphrase/storage/PassphraseCredential.php +++ b/src/applications/passphrase/storage/PassphraseCredential.php @@ -25,6 +25,7 @@ protected $spacePHID; private $secret = self::ATTACHABLE; + private $implementation = self::ATTACHABLE; public static function initializeNewCredential(PhabricatorUser $actor) { $app = id(new PhabricatorApplicationQuery()) @@ -98,6 +99,15 @@ return PassphraseCredentialType::getTypeByConstant($type); } + public function attachImplementation(PassphraseCredentialType $impl) { + $this->implementation = $impl; + return $this; + } + + public function getImplementation() { + return $this->assertAttached($this->implementation); + } + /* -( PhabricatorApplicationTransactionInterface )------------------------- */