Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18844676
D14412.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D14412.diff
View Options
diff --git a/src/applications/passphrase/credentialtype/PassphraseCredentialType.php b/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
--- a/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
+++ b/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
@@ -5,8 +5,36 @@
*/
abstract class PassphraseCredentialType extends Phobject {
- abstract public function getCredentialType();
- abstract public function getProvidesType();
+ final public function getCredentialType() {
+ $const = $this->getPhobjectClassConstant('CREDENTIAL_TYPE');
+
+ if (!is_string($const)) {
+ throw new Exception(
+ pht(
+ '%s class "%s" has an invalid %s property.',
+ __CLASS__,
+ get_class($this),
+ 'CREDENTIAL_TYPE'));
+ }
+
+ return $const;
+ }
+
+ final public function getProvidesType() {
+ $const = $this->getPhobjectClassConstant('PROVIDES_TYPE');
+
+ if (!is_string($const)) {
+ throw new Exception(
+ pht(
+ '%s class "%s" has an invalid %s property.',
+ __CLASS__,
+ get_class($this),
+ 'PROVIDES_TYPE'));
+ }
+
+ return "provides/{$const}";
+ }
+
abstract public function getCredentialTypeName();
abstract public function getCredentialTypeDescription();
abstract public function getSecretLabel();
diff --git a/src/applications/passphrase/credentialtype/PassphraseNoteCredentialType.php b/src/applications/passphrase/credentialtype/PassphraseNoteCredentialType.php
--- a/src/applications/passphrase/credentialtype/PassphraseNoteCredentialType.php
+++ b/src/applications/passphrase/credentialtype/PassphraseNoteCredentialType.php
@@ -4,15 +4,7 @@
extends PassphraseCredentialType {
const CREDENTIAL_TYPE = 'note';
- const PROVIDES_TYPE = 'provides/note';
-
- public function getCredentialType() {
- return self::CREDENTIAL_TYPE;
- }
-
- public function getProvidesType() {
- return self::PROVIDES_TYPE;
- }
+ const PROVIDES_TYPE = 'note';
public function getCredentialTypeName() {
return pht('Note');
diff --git a/src/applications/passphrase/credentialtype/PassphrasePasswordCredentialType.php b/src/applications/passphrase/credentialtype/PassphrasePasswordCredentialType.php
--- a/src/applications/passphrase/credentialtype/PassphrasePasswordCredentialType.php
+++ b/src/applications/passphrase/credentialtype/PassphrasePasswordCredentialType.php
@@ -4,15 +4,7 @@
extends PassphraseCredentialType {
const CREDENTIAL_TYPE = 'password';
- const PROVIDES_TYPE = 'provides/password';
-
- public function getCredentialType() {
- return self::CREDENTIAL_TYPE;
- }
-
- public function getProvidesType() {
- return self::PROVIDES_TYPE;
- }
+ const PROVIDES_TYPE = 'password';
public function getCredentialTypeName() {
return pht('Password');
diff --git a/src/applications/passphrase/credentialtype/PassphraseSSHGeneratedKeyCredentialType.php b/src/applications/passphrase/credentialtype/PassphraseSSHGeneratedKeyCredentialType.php
--- a/src/applications/passphrase/credentialtype/PassphraseSSHGeneratedKeyCredentialType.php
+++ b/src/applications/passphrase/credentialtype/PassphraseSSHGeneratedKeyCredentialType.php
@@ -5,10 +5,6 @@
const CREDENTIAL_TYPE = 'ssh-generated-key';
- public function getCredentialType() {
- return self::CREDENTIAL_TYPE;
- }
-
public function getCredentialTypeName() {
return pht('SSH Private Key (Generated)');
}
diff --git a/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyCredentialType.php b/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyCredentialType.php
--- a/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyCredentialType.php
+++ b/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyCredentialType.php
@@ -3,11 +3,7 @@
abstract class PassphraseSSHPrivateKeyCredentialType
extends PassphraseCredentialType {
- const PROVIDES_TYPE = 'provides/ssh-key-file';
-
- final public function getProvidesType() {
- return self::PROVIDES_TYPE;
- }
+ const PROVIDES_TYPE = 'ssh-key-file';
public function hasPublicKey() {
return true;
diff --git a/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyFileCredentialType.php b/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyFileCredentialType.php
--- a/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyFileCredentialType.php
+++ b/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyFileCredentialType.php
@@ -5,10 +5,6 @@
const CREDENTIAL_TYPE = 'ssh-key-file';
- public function getCredentialType() {
- return self::CREDENTIAL_TYPE;
- }
-
public function getCredentialTypeName() {
return pht('SSH Private Key File');
}
diff --git a/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyTextCredentialType.php b/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyTextCredentialType.php
--- a/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyTextCredentialType.php
+++ b/src/applications/passphrase/credentialtype/PassphraseSSHPrivateKeyTextCredentialType.php
@@ -5,10 +5,6 @@
const CREDENTIAL_TYPE = 'ssh-key-text';
- public function getCredentialType() {
- return self::CREDENTIAL_TYPE;
- }
-
public function getCredentialTypeName() {
return pht('SSH Private Key');
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 30, 7:06 AM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
9091333
Default Alt Text
D14412.diff (5 KB)
Attached To
Mode
D14412: Use Phobject class constants for Passphrase credential types
Attached
Detach File
Event Timeline
Log In to Comment