Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/files/management/PhabricatorFilesManagementGenerateKeyWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementGenerateKeyWorkflow.php
index 710c3586a6..1d01c6f3b3 100644
--- a/src/applications/files/management/PhabricatorFilesManagementGenerateKeyWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementGenerateKeyWorkflow.php
@@ -1,63 +1,63 @@
<?php
final class PhabricatorFilesManagementGenerateKeyWorkflow
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
$this
->setName('generate-key')
->setSynopsis(
pht('Generate an encryption key.'))
->setArguments(
array(
array(
'name' => 'type',
'param' => 'keytype',
'help' => pht('Select the type of key to generate.'),
),
));
}
public function execute(PhutilArgumentParser $args) {
$type = $args->getArg('type');
- if (!strlen($type)) {
+ if (!phutil_nonempty_string($type)) {
throw new PhutilArgumentUsageException(
pht(
'Specify the type of key to generate with --type.'));
}
$format = PhabricatorFileStorageFormat::getFormat($type);
if (!$format) {
throw new PhutilArgumentUsageException(
pht(
'No key type "%s" exists.',
$type));
}
if (!$format->canGenerateNewKeyMaterial()) {
throw new PhutilArgumentUsageException(
pht(
'Storage format "%s" can not generate keys.',
$format->getStorageFormatName()));
}
$material = $format->generateNewKeyMaterial();
$structure = array(
'name' => 'generated-key-'.Filesystem::readRandomCharacters(12),
'type' => $type,
'material.base64' => $material,
);
$json = id(new PhutilJSON())->encodeFormatted($structure);
echo tsprintf(
"%s: %s\n\n%B\n",
pht('Key Material'),
$format->getStorageFormatName(),
$json);
return 0;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 6:44 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1191
Default Alt Text
(2 KB)

Event Timeline