@@ -29,46 +29,46 @@ |
||
29 | 29 | use \OCP\IUserManager; |
30 | 30 | |
31 | 31 | class UserController extends Controller { |
32 | - /** |
|
33 | - * @var IUserManager |
|
34 | - */ |
|
35 | - protected $userManager; |
|
32 | + /** |
|
33 | + * @var IUserManager |
|
34 | + */ |
|
35 | + protected $userManager; |
|
36 | 36 | |
37 | - public function __construct($appName, |
|
38 | - IRequest $request, |
|
39 | - IUserManager $userManager |
|
40 | - ) { |
|
41 | - parent::__construct($appName, $request); |
|
42 | - $this->userManager = $userManager; |
|
43 | - } |
|
37 | + public function __construct($appName, |
|
38 | + IRequest $request, |
|
39 | + IUserManager $userManager |
|
40 | + ) { |
|
41 | + parent::__construct($appName, $request); |
|
42 | + $this->userManager = $userManager; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Lookup user display names |
|
47 | - * |
|
48 | - * @NoAdminRequired |
|
49 | - * |
|
50 | - * @param array $users |
|
51 | - * |
|
52 | - * @return JSONResponse |
|
53 | - */ |
|
54 | - public function getDisplayNames($users) { |
|
55 | - $result = array(); |
|
45 | + /** |
|
46 | + * Lookup user display names |
|
47 | + * |
|
48 | + * @NoAdminRequired |
|
49 | + * |
|
50 | + * @param array $users |
|
51 | + * |
|
52 | + * @return JSONResponse |
|
53 | + */ |
|
54 | + public function getDisplayNames($users) { |
|
55 | + $result = array(); |
|
56 | 56 | |
57 | - foreach ($users as $user) { |
|
58 | - $userObject = $this->userManager->get($user); |
|
59 | - if (is_object($userObject)) { |
|
60 | - $result[$user] = $userObject->getDisplayName(); |
|
61 | - } else { |
|
62 | - $result[$user] = $user; |
|
63 | - } |
|
64 | - } |
|
57 | + foreach ($users as $user) { |
|
58 | + $userObject = $this->userManager->get($user); |
|
59 | + if (is_object($userObject)) { |
|
60 | + $result[$user] = $userObject->getDisplayName(); |
|
61 | + } else { |
|
62 | + $result[$user] = $user; |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - $json = array( |
|
67 | - 'users' => $result, |
|
68 | - 'status' => 'success' |
|
69 | - ); |
|
66 | + $json = array( |
|
67 | + 'users' => $result, |
|
68 | + 'status' => 'success' |
|
69 | + ); |
|
70 | 70 | |
71 | - return new JSONResponse($json); |
|
71 | + return new JSONResponse($json); |
|
72 | 72 | |
73 | - } |
|
73 | + } |
|
74 | 74 | } |
@@ -34,28 +34,28 @@ |
||
34 | 34 | |
35 | 35 | class RemoveCertificate extends Base { |
36 | 36 | |
37 | - /** @var ICertificateManager */ |
|
38 | - protected $certificateManager; |
|
39 | - |
|
40 | - public function __construct(ICertificateManager $certificateManager) { |
|
41 | - $this->certificateManager = $certificateManager; |
|
42 | - parent::__construct(); |
|
43 | - } |
|
44 | - |
|
45 | - protected function configure() { |
|
46 | - $this |
|
47 | - ->setName('security:certificates:remove') |
|
48 | - ->setDescription('remove trusted certificate') |
|
49 | - ->addArgument( |
|
50 | - 'name', |
|
51 | - InputArgument::REQUIRED, |
|
52 | - 'the file name of the certificate to remove' |
|
53 | - ); |
|
54 | - } |
|
55 | - |
|
56 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
57 | - $name = $input->getArgument('name'); |
|
58 | - |
|
59 | - $this->certificateManager->removeCertificate($name); |
|
60 | - } |
|
37 | + /** @var ICertificateManager */ |
|
38 | + protected $certificateManager; |
|
39 | + |
|
40 | + public function __construct(ICertificateManager $certificateManager) { |
|
41 | + $this->certificateManager = $certificateManager; |
|
42 | + parent::__construct(); |
|
43 | + } |
|
44 | + |
|
45 | + protected function configure() { |
|
46 | + $this |
|
47 | + ->setName('security:certificates:remove') |
|
48 | + ->setDescription('remove trusted certificate') |
|
49 | + ->addArgument( |
|
50 | + 'name', |
|
51 | + InputArgument::REQUIRED, |
|
52 | + 'the file name of the certificate to remove' |
|
53 | + ); |
|
54 | + } |
|
55 | + |
|
56 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
57 | + $name = $input->getArgument('name'); |
|
58 | + |
|
59 | + $this->certificateManager->removeCertificate($name); |
|
60 | + } |
|
61 | 61 | } |
@@ -34,64 +34,64 @@ |
||
34 | 34 | |
35 | 35 | class ListCertificates extends Base { |
36 | 36 | |
37 | - /** @var ICertificateManager */ |
|
38 | - protected $certificateManager; |
|
39 | - /** @var IL10N */ |
|
40 | - protected $l; |
|
37 | + /** @var ICertificateManager */ |
|
38 | + protected $certificateManager; |
|
39 | + /** @var IL10N */ |
|
40 | + protected $l; |
|
41 | 41 | |
42 | - public function __construct(ICertificateManager $certificateManager, IL10N $l) { |
|
43 | - $this->certificateManager = $certificateManager; |
|
44 | - $this->l = $l; |
|
45 | - parent::__construct(); |
|
46 | - } |
|
42 | + public function __construct(ICertificateManager $certificateManager, IL10N $l) { |
|
43 | + $this->certificateManager = $certificateManager; |
|
44 | + $this->l = $l; |
|
45 | + parent::__construct(); |
|
46 | + } |
|
47 | 47 | |
48 | - protected function configure() { |
|
49 | - $this |
|
50 | - ->setName('security:certificates') |
|
51 | - ->setDescription('list trusted certificates'); |
|
52 | - parent::configure(); |
|
53 | - } |
|
48 | + protected function configure() { |
|
49 | + $this |
|
50 | + ->setName('security:certificates') |
|
51 | + ->setDescription('list trusted certificates'); |
|
52 | + parent::configure(); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
56 | - $outputType = $input->getOption('output'); |
|
57 | - if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { |
|
58 | - $certificates = array_map(function (ICertificate $certificate) { |
|
59 | - return [ |
|
60 | - 'name' => $certificate->getName(), |
|
61 | - 'common_name' => $certificate->getCommonName(), |
|
62 | - 'organization' => $certificate->getOrganization(), |
|
63 | - 'expire' => $certificate->getExpireDate()->format(\DateTime::ATOM), |
|
64 | - 'issuer' => $certificate->getIssuerName(), |
|
65 | - 'issuer_organization' => $certificate->getIssuerOrganization(), |
|
66 | - 'issue_date' => $certificate->getIssueDate()->format(\DateTime::ATOM) |
|
67 | - ]; |
|
68 | - }, $this->certificateManager->listCertificates()); |
|
69 | - if ($outputType === self::OUTPUT_FORMAT_JSON) { |
|
70 | - $output->writeln(json_encode(array_values($certificates))); |
|
71 | - } else { |
|
72 | - $output->writeln(json_encode(array_values($certificates), JSON_PRETTY_PRINT)); |
|
73 | - } |
|
74 | - } else { |
|
75 | - $table = new Table($output); |
|
76 | - $table->setHeaders([ |
|
77 | - 'File Name', |
|
78 | - 'Common Name', |
|
79 | - 'Organization', |
|
80 | - 'Valid Until', |
|
81 | - 'Issued By' |
|
82 | - ]); |
|
55 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
56 | + $outputType = $input->getOption('output'); |
|
57 | + if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { |
|
58 | + $certificates = array_map(function (ICertificate $certificate) { |
|
59 | + return [ |
|
60 | + 'name' => $certificate->getName(), |
|
61 | + 'common_name' => $certificate->getCommonName(), |
|
62 | + 'organization' => $certificate->getOrganization(), |
|
63 | + 'expire' => $certificate->getExpireDate()->format(\DateTime::ATOM), |
|
64 | + 'issuer' => $certificate->getIssuerName(), |
|
65 | + 'issuer_organization' => $certificate->getIssuerOrganization(), |
|
66 | + 'issue_date' => $certificate->getIssueDate()->format(\DateTime::ATOM) |
|
67 | + ]; |
|
68 | + }, $this->certificateManager->listCertificates()); |
|
69 | + if ($outputType === self::OUTPUT_FORMAT_JSON) { |
|
70 | + $output->writeln(json_encode(array_values($certificates))); |
|
71 | + } else { |
|
72 | + $output->writeln(json_encode(array_values($certificates), JSON_PRETTY_PRINT)); |
|
73 | + } |
|
74 | + } else { |
|
75 | + $table = new Table($output); |
|
76 | + $table->setHeaders([ |
|
77 | + 'File Name', |
|
78 | + 'Common Name', |
|
79 | + 'Organization', |
|
80 | + 'Valid Until', |
|
81 | + 'Issued By' |
|
82 | + ]); |
|
83 | 83 | |
84 | - $rows = array_map(function (ICertificate $certificate) { |
|
85 | - return [ |
|
86 | - $certificate->getName(), |
|
87 | - $certificate->getCommonName(), |
|
88 | - $certificate->getOrganization(), |
|
89 | - $this->l->l('date', $certificate->getExpireDate()), |
|
90 | - $certificate->getIssuerName() |
|
91 | - ]; |
|
92 | - }, $this->certificateManager->listCertificates()); |
|
93 | - $table->setRows($rows); |
|
94 | - $table->render(); |
|
95 | - } |
|
96 | - } |
|
84 | + $rows = array_map(function (ICertificate $certificate) { |
|
85 | + return [ |
|
86 | + $certificate->getName(), |
|
87 | + $certificate->getCommonName(), |
|
88 | + $certificate->getOrganization(), |
|
89 | + $this->l->l('date', $certificate->getExpireDate()), |
|
90 | + $certificate->getIssuerName() |
|
91 | + ]; |
|
92 | + }, $this->certificateManager->listCertificates()); |
|
93 | + $table->setRows($rows); |
|
94 | + $table->render(); |
|
95 | + } |
|
96 | + } |
|
97 | 97 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | protected function execute(InputInterface $input, OutputInterface $output) { |
56 | 56 | $outputType = $input->getOption('output'); |
57 | 57 | if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { |
58 | - $certificates = array_map(function (ICertificate $certificate) { |
|
58 | + $certificates = array_map(function(ICertificate $certificate) { |
|
59 | 59 | return [ |
60 | 60 | 'name' => $certificate->getName(), |
61 | 61 | 'common_name' => $certificate->getCommonName(), |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'Issued By' |
82 | 82 | ]); |
83 | 83 | |
84 | - $rows = array_map(function (ICertificate $certificate) { |
|
84 | + $rows = array_map(function(ICertificate $certificate) { |
|
85 | 85 | return [ |
86 | 86 | $certificate->getName(), |
87 | 87 | $certificate->getCommonName(), |
@@ -33,36 +33,36 @@ |
||
33 | 33 | |
34 | 34 | class ImportCertificate extends Base { |
35 | 35 | |
36 | - /** @var ICertificateManager */ |
|
37 | - protected $certificateManager; |
|
36 | + /** @var ICertificateManager */ |
|
37 | + protected $certificateManager; |
|
38 | 38 | |
39 | - public function __construct(ICertificateManager $certificateManager) { |
|
40 | - $this->certificateManager = $certificateManager; |
|
41 | - parent::__construct(); |
|
42 | - } |
|
39 | + public function __construct(ICertificateManager $certificateManager) { |
|
40 | + $this->certificateManager = $certificateManager; |
|
41 | + parent::__construct(); |
|
42 | + } |
|
43 | 43 | |
44 | - protected function configure() { |
|
45 | - $this |
|
46 | - ->setName('security:certificates:import') |
|
47 | - ->setDescription('import trusted certificate') |
|
48 | - ->addArgument( |
|
49 | - 'path', |
|
50 | - InputArgument::REQUIRED, |
|
51 | - 'path to the certificate to import' |
|
52 | - ); |
|
53 | - } |
|
44 | + protected function configure() { |
|
45 | + $this |
|
46 | + ->setName('security:certificates:import') |
|
47 | + ->setDescription('import trusted certificate') |
|
48 | + ->addArgument( |
|
49 | + 'path', |
|
50 | + InputArgument::REQUIRED, |
|
51 | + 'path to the certificate to import' |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
56 | - $path = $input->getArgument('path'); |
|
55 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
56 | + $path = $input->getArgument('path'); |
|
57 | 57 | |
58 | - if (!file_exists($path)) { |
|
59 | - $output->writeln('<error>certificate not found</error>'); |
|
60 | - return; |
|
61 | - } |
|
58 | + if (!file_exists($path)) { |
|
59 | + $output->writeln('<error>certificate not found</error>'); |
|
60 | + return; |
|
61 | + } |
|
62 | 62 | |
63 | - $certData = file_get_contents($path); |
|
64 | - $name = basename($path); |
|
63 | + $certData = file_get_contents($path); |
|
64 | + $name = basename($path); |
|
65 | 65 | |
66 | - $this->certificateManager->addCertificate($certData, $name); |
|
67 | - } |
|
66 | + $this->certificateManager->addCertificate($certData, $name); |
|
67 | + } |
|
68 | 68 | } |
@@ -37,69 +37,69 @@ |
||
37 | 37 | * @package OC\Core\Command\Integrity |
38 | 38 | */ |
39 | 39 | class SignCore extends Command { |
40 | - /** @var Checker */ |
|
41 | - private $checker; |
|
42 | - /** @var FileAccessHelper */ |
|
43 | - private $fileAccessHelper; |
|
40 | + /** @var Checker */ |
|
41 | + private $checker; |
|
42 | + /** @var FileAccessHelper */ |
|
43 | + private $fileAccessHelper; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param Checker $checker |
|
47 | - * @param FileAccessHelper $fileAccessHelper |
|
48 | - */ |
|
49 | - public function __construct(Checker $checker, |
|
50 | - FileAccessHelper $fileAccessHelper) { |
|
51 | - parent::__construct(null); |
|
52 | - $this->checker = $checker; |
|
53 | - $this->fileAccessHelper = $fileAccessHelper; |
|
54 | - } |
|
45 | + /** |
|
46 | + * @param Checker $checker |
|
47 | + * @param FileAccessHelper $fileAccessHelper |
|
48 | + */ |
|
49 | + public function __construct(Checker $checker, |
|
50 | + FileAccessHelper $fileAccessHelper) { |
|
51 | + parent::__construct(null); |
|
52 | + $this->checker = $checker; |
|
53 | + $this->fileAccessHelper = $fileAccessHelper; |
|
54 | + } |
|
55 | 55 | |
56 | - protected function configure() { |
|
57 | - $this |
|
58 | - ->setName('integrity:sign-core') |
|
59 | - ->setDescription('Sign core using a private key.') |
|
60 | - ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') |
|
61 | - ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing') |
|
62 | - ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Path of core to sign'); |
|
63 | - } |
|
56 | + protected function configure() { |
|
57 | + $this |
|
58 | + ->setName('integrity:sign-core') |
|
59 | + ->setDescription('Sign core using a private key.') |
|
60 | + ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') |
|
61 | + ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing') |
|
62 | + ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Path of core to sign'); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * {@inheritdoc } |
|
67 | - */ |
|
68 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
69 | - $privateKeyPath = $input->getOption('privateKey'); |
|
70 | - $keyBundlePath = $input->getOption('certificate'); |
|
71 | - $path = $input->getOption('path'); |
|
72 | - if(is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { |
|
73 | - $output->writeln('--privateKey, --certificate and --path are required.'); |
|
74 | - return null; |
|
75 | - } |
|
65 | + /** |
|
66 | + * {@inheritdoc } |
|
67 | + */ |
|
68 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
69 | + $privateKeyPath = $input->getOption('privateKey'); |
|
70 | + $keyBundlePath = $input->getOption('certificate'); |
|
71 | + $path = $input->getOption('path'); |
|
72 | + if(is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { |
|
73 | + $output->writeln('--privateKey, --certificate and --path are required.'); |
|
74 | + return null; |
|
75 | + } |
|
76 | 76 | |
77 | - $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
|
78 | - $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
|
77 | + $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
|
78 | + $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
|
79 | 79 | |
80 | - if($privateKey === false) { |
|
81 | - $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
|
82 | - return null; |
|
83 | - } |
|
80 | + if($privateKey === false) { |
|
81 | + $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
|
82 | + return null; |
|
83 | + } |
|
84 | 84 | |
85 | - if($keyBundle === false) { |
|
86 | - $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
|
87 | - return null; |
|
88 | - } |
|
85 | + if($keyBundle === false) { |
|
86 | + $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
|
87 | + return null; |
|
88 | + } |
|
89 | 89 | |
90 | - $rsa = new RSA(); |
|
91 | - $rsa->loadKey($privateKey); |
|
92 | - $x509 = new X509(); |
|
93 | - $x509->loadX509($keyBundle); |
|
94 | - $x509->setPrivateKey($rsa); |
|
90 | + $rsa = new RSA(); |
|
91 | + $rsa->loadKey($privateKey); |
|
92 | + $x509 = new X509(); |
|
93 | + $x509->loadX509($keyBundle); |
|
94 | + $x509->setPrivateKey($rsa); |
|
95 | 95 | |
96 | - try { |
|
97 | - $this->checker->writeCoreSignature($x509, $rsa, $path); |
|
98 | - $output->writeln('Successfully signed "core"'); |
|
99 | - } catch (\Exception $e){ |
|
100 | - $output->writeln('Error: ' . $e->getMessage()); |
|
101 | - return 1; |
|
102 | - } |
|
103 | - return 0; |
|
104 | - } |
|
96 | + try { |
|
97 | + $this->checker->writeCoreSignature($x509, $rsa, $path); |
|
98 | + $output->writeln('Successfully signed "core"'); |
|
99 | + } catch (\Exception $e){ |
|
100 | + $output->writeln('Error: ' . $e->getMessage()); |
|
101 | + return 1; |
|
102 | + } |
|
103 | + return 0; |
|
104 | + } |
|
105 | 105 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $privateKeyPath = $input->getOption('privateKey'); |
70 | 70 | $keyBundlePath = $input->getOption('certificate'); |
71 | 71 | $path = $input->getOption('path'); |
72 | - if(is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { |
|
72 | + if (is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { |
|
73 | 73 | $output->writeln('--privateKey, --certificate and --path are required.'); |
74 | 74 | return null; |
75 | 75 | } |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
78 | 78 | $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
79 | 79 | |
80 | - if($privateKey === false) { |
|
80 | + if ($privateKey === false) { |
|
81 | 81 | $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
82 | 82 | return null; |
83 | 83 | } |
84 | 84 | |
85 | - if($keyBundle === false) { |
|
85 | + if ($keyBundle === false) { |
|
86 | 86 | $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
87 | 87 | return null; |
88 | 88 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | try { |
97 | 97 | $this->checker->writeCoreSignature($x509, $rsa, $path); |
98 | 98 | $output->writeln('Successfully signed "core"'); |
99 | - } catch (\Exception $e){ |
|
100 | - $output->writeln('Error: ' . $e->getMessage()); |
|
99 | + } catch (\Exception $e) { |
|
100 | + $output->writeln('Error: '.$e->getMessage()); |
|
101 | 101 | return 1; |
102 | 102 | } |
103 | 103 | return 0; |
@@ -38,76 +38,76 @@ |
||
38 | 38 | * @package OC\Core\Command\Integrity |
39 | 39 | */ |
40 | 40 | class SignApp extends Command { |
41 | - /** @var Checker */ |
|
42 | - private $checker; |
|
43 | - /** @var FileAccessHelper */ |
|
44 | - private $fileAccessHelper; |
|
45 | - /** @var IURLGenerator */ |
|
46 | - private $urlGenerator; |
|
41 | + /** @var Checker */ |
|
42 | + private $checker; |
|
43 | + /** @var FileAccessHelper */ |
|
44 | + private $fileAccessHelper; |
|
45 | + /** @var IURLGenerator */ |
|
46 | + private $urlGenerator; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param Checker $checker |
|
50 | - * @param FileAccessHelper $fileAccessHelper |
|
51 | - * @param IURLGenerator $urlGenerator |
|
52 | - */ |
|
53 | - public function __construct(Checker $checker, |
|
54 | - FileAccessHelper $fileAccessHelper, |
|
55 | - IURLGenerator $urlGenerator) { |
|
56 | - parent::__construct(null); |
|
57 | - $this->checker = $checker; |
|
58 | - $this->fileAccessHelper = $fileAccessHelper; |
|
59 | - $this->urlGenerator = $urlGenerator; |
|
60 | - } |
|
48 | + /** |
|
49 | + * @param Checker $checker |
|
50 | + * @param FileAccessHelper $fileAccessHelper |
|
51 | + * @param IURLGenerator $urlGenerator |
|
52 | + */ |
|
53 | + public function __construct(Checker $checker, |
|
54 | + FileAccessHelper $fileAccessHelper, |
|
55 | + IURLGenerator $urlGenerator) { |
|
56 | + parent::__construct(null); |
|
57 | + $this->checker = $checker; |
|
58 | + $this->fileAccessHelper = $fileAccessHelper; |
|
59 | + $this->urlGenerator = $urlGenerator; |
|
60 | + } |
|
61 | 61 | |
62 | - protected function configure() { |
|
63 | - $this |
|
64 | - ->setName('integrity:sign-app') |
|
65 | - ->setDescription('Signs an app using a private key.') |
|
66 | - ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Application to sign') |
|
67 | - ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') |
|
68 | - ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing'); |
|
69 | - } |
|
62 | + protected function configure() { |
|
63 | + $this |
|
64 | + ->setName('integrity:sign-app') |
|
65 | + ->setDescription('Signs an app using a private key.') |
|
66 | + ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Application to sign') |
|
67 | + ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') |
|
68 | + ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing'); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * {@inheritdoc } |
|
73 | - */ |
|
74 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
75 | - $path = $input->getOption('path'); |
|
76 | - $privateKeyPath = $input->getOption('privateKey'); |
|
77 | - $keyBundlePath = $input->getOption('certificate'); |
|
78 | - if(is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { |
|
79 | - $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); |
|
80 | - $output->writeln('This command requires the --path, --privateKey and --certificate.'); |
|
81 | - $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); |
|
82 | - $output->writeln('For more information please consult the documentation: '. $documentationUrl); |
|
83 | - return null; |
|
84 | - } |
|
71 | + /** |
|
72 | + * {@inheritdoc } |
|
73 | + */ |
|
74 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
75 | + $path = $input->getOption('path'); |
|
76 | + $privateKeyPath = $input->getOption('privateKey'); |
|
77 | + $keyBundlePath = $input->getOption('certificate'); |
|
78 | + if(is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { |
|
79 | + $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); |
|
80 | + $output->writeln('This command requires the --path, --privateKey and --certificate.'); |
|
81 | + $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); |
|
82 | + $output->writeln('For more information please consult the documentation: '. $documentationUrl); |
|
83 | + return null; |
|
84 | + } |
|
85 | 85 | |
86 | - $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
|
87 | - $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
|
86 | + $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
|
87 | + $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
|
88 | 88 | |
89 | - if($privateKey === false) { |
|
90 | - $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
|
91 | - return null; |
|
92 | - } |
|
89 | + if($privateKey === false) { |
|
90 | + $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
|
91 | + return null; |
|
92 | + } |
|
93 | 93 | |
94 | - if($keyBundle === false) { |
|
95 | - $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
|
96 | - return null; |
|
97 | - } |
|
94 | + if($keyBundle === false) { |
|
95 | + $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
|
96 | + return null; |
|
97 | + } |
|
98 | 98 | |
99 | - $rsa = new RSA(); |
|
100 | - $rsa->loadKey($privateKey); |
|
101 | - $x509 = new X509(); |
|
102 | - $x509->loadX509($keyBundle); |
|
103 | - $x509->setPrivateKey($rsa); |
|
104 | - try { |
|
105 | - $this->checker->writeAppSignature($path, $x509, $rsa); |
|
106 | - $output->writeln('Successfully signed "'.$path.'"'); |
|
107 | - } catch (\Exception $e){ |
|
108 | - $output->writeln('Error: ' . $e->getMessage()); |
|
109 | - return 1; |
|
110 | - } |
|
111 | - return 0; |
|
112 | - } |
|
99 | + $rsa = new RSA(); |
|
100 | + $rsa->loadKey($privateKey); |
|
101 | + $x509 = new X509(); |
|
102 | + $x509->loadX509($keyBundle); |
|
103 | + $x509->setPrivateKey($rsa); |
|
104 | + try { |
|
105 | + $this->checker->writeAppSignature($path, $x509, $rsa); |
|
106 | + $output->writeln('Successfully signed "'.$path.'"'); |
|
107 | + } catch (\Exception $e){ |
|
108 | + $output->writeln('Error: ' . $e->getMessage()); |
|
109 | + return 1; |
|
110 | + } |
|
111 | + return 0; |
|
112 | + } |
|
113 | 113 | } |
@@ -75,23 +75,23 @@ discard block |
||
75 | 75 | $path = $input->getOption('path'); |
76 | 76 | $privateKeyPath = $input->getOption('privateKey'); |
77 | 77 | $keyBundlePath = $input->getOption('certificate'); |
78 | - if(is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { |
|
78 | + if (is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { |
|
79 | 79 | $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); |
80 | 80 | $output->writeln('This command requires the --path, --privateKey and --certificate.'); |
81 | 81 | $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); |
82 | - $output->writeln('For more information please consult the documentation: '. $documentationUrl); |
|
82 | + $output->writeln('For more information please consult the documentation: '.$documentationUrl); |
|
83 | 83 | return null; |
84 | 84 | } |
85 | 85 | |
86 | 86 | $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
87 | 87 | $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
88 | 88 | |
89 | - if($privateKey === false) { |
|
89 | + if ($privateKey === false) { |
|
90 | 90 | $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
91 | 91 | return null; |
92 | 92 | } |
93 | 93 | |
94 | - if($keyBundle === false) { |
|
94 | + if ($keyBundle === false) { |
|
95 | 95 | $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
96 | 96 | return null; |
97 | 97 | } |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | try { |
105 | 105 | $this->checker->writeAppSignature($path, $x509, $rsa); |
106 | 106 | $output->writeln('Successfully signed "'.$path.'"'); |
107 | - } catch (\Exception $e){ |
|
108 | - $output->writeln('Error: ' . $e->getMessage()); |
|
107 | + } catch (\Exception $e) { |
|
108 | + $output->writeln('Error: '.$e->getMessage()); |
|
109 | 109 | return 1; |
110 | 110 | } |
111 | 111 | return 0; |
@@ -34,34 +34,34 @@ |
||
34 | 34 | * @package OC\Core\Command\Integrity |
35 | 35 | */ |
36 | 36 | class CheckCore extends Base { |
37 | - /** |
|
38 | - * @var Checker |
|
39 | - */ |
|
40 | - private $checker; |
|
37 | + /** |
|
38 | + * @var Checker |
|
39 | + */ |
|
40 | + private $checker; |
|
41 | 41 | |
42 | - public function __construct(Checker $checker) { |
|
43 | - parent::__construct(); |
|
44 | - $this->checker = $checker; |
|
45 | - } |
|
42 | + public function __construct(Checker $checker) { |
|
43 | + parent::__construct(); |
|
44 | + $this->checker = $checker; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * {@inheritdoc } |
|
49 | - */ |
|
50 | - protected function configure() { |
|
51 | - parent::configure(); |
|
52 | - $this |
|
53 | - ->setName('integrity:check-core') |
|
54 | - ->setDescription('Check integrity of core code using a signature.'); |
|
55 | - } |
|
47 | + /** |
|
48 | + * {@inheritdoc } |
|
49 | + */ |
|
50 | + protected function configure() { |
|
51 | + parent::configure(); |
|
52 | + $this |
|
53 | + ->setName('integrity:check-core') |
|
54 | + ->setDescription('Check integrity of core code using a signature.'); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * {@inheritdoc } |
|
59 | - */ |
|
60 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | - $result = $this->checker->verifyCoreSignature(); |
|
62 | - $this->writeArrayInOutputFormat($input, $output, $result); |
|
63 | - if (count($result)>0){ |
|
64 | - return 1; |
|
65 | - } |
|
66 | - } |
|
57 | + /** |
|
58 | + * {@inheritdoc } |
|
59 | + */ |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | + $result = $this->checker->verifyCoreSignature(); |
|
62 | + $this->writeArrayInOutputFormat($input, $output, $result); |
|
63 | + if (count($result)>0){ |
|
64 | + return 1; |
|
65 | + } |
|
66 | + } |
|
67 | 67 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | protected function execute(InputInterface $input, OutputInterface $output) { |
61 | 61 | $result = $this->checker->verifyCoreSignature(); |
62 | 62 | $this->writeArrayInOutputFormat($input, $output, $result); |
63 | - if (count($result)>0){ |
|
63 | + if (count($result) > 0) { |
|
64 | 64 | return 1; |
65 | 65 | } |
66 | 66 | } |
@@ -32,44 +32,44 @@ |
||
32 | 32 | use Symfony\Component\Console\Input\InputArgument; |
33 | 33 | |
34 | 34 | class LastSeen extends Command { |
35 | - /** @var IUserManager */ |
|
36 | - protected $userManager; |
|
35 | + /** @var IUserManager */ |
|
36 | + protected $userManager; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IUserManager $userManager |
|
40 | - */ |
|
41 | - public function __construct(IUserManager $userManager) { |
|
42 | - $this->userManager = $userManager; |
|
43 | - parent::__construct(); |
|
44 | - } |
|
38 | + /** |
|
39 | + * @param IUserManager $userManager |
|
40 | + */ |
|
41 | + public function __construct(IUserManager $userManager) { |
|
42 | + $this->userManager = $userManager; |
|
43 | + parent::__construct(); |
|
44 | + } |
|
45 | 45 | |
46 | - protected function configure() { |
|
47 | - $this |
|
48 | - ->setName('user:lastseen') |
|
49 | - ->setDescription('shows when the user was logged in last time') |
|
50 | - ->addArgument( |
|
51 | - 'uid', |
|
52 | - InputArgument::REQUIRED, |
|
53 | - 'the username' |
|
54 | - ); |
|
55 | - } |
|
46 | + protected function configure() { |
|
47 | + $this |
|
48 | + ->setName('user:lastseen') |
|
49 | + ->setDescription('shows when the user was logged in last time') |
|
50 | + ->addArgument( |
|
51 | + 'uid', |
|
52 | + InputArgument::REQUIRED, |
|
53 | + 'the username' |
|
54 | + ); |
|
55 | + } |
|
56 | 56 | |
57 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
58 | - $user = $this->userManager->get($input->getArgument('uid')); |
|
59 | - if(is_null($user)) { |
|
60 | - $output->writeln('<error>User does not exist</error>'); |
|
61 | - return; |
|
62 | - } |
|
57 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
58 | + $user = $this->userManager->get($input->getArgument('uid')); |
|
59 | + if(is_null($user)) { |
|
60 | + $output->writeln('<error>User does not exist</error>'); |
|
61 | + return; |
|
62 | + } |
|
63 | 63 | |
64 | - $lastLogin = $user->getLastLogin(); |
|
65 | - if($lastLogin === 0) { |
|
66 | - $output->writeln('User ' . $user->getUID() . |
|
67 | - ' has never logged in, yet.'); |
|
68 | - } else { |
|
69 | - $date = new \DateTime(); |
|
70 | - $date->setTimestamp($lastLogin); |
|
71 | - $output->writeln($user->getUID() . |
|
72 | - '`s last login: ' . $date->format('d.m.Y H:i')); |
|
73 | - } |
|
74 | - } |
|
64 | + $lastLogin = $user->getLastLogin(); |
|
65 | + if($lastLogin === 0) { |
|
66 | + $output->writeln('User ' . $user->getUID() . |
|
67 | + ' has never logged in, yet.'); |
|
68 | + } else { |
|
69 | + $date = new \DateTime(); |
|
70 | + $date->setTimestamp($lastLogin); |
|
71 | + $output->writeln($user->getUID() . |
|
72 | + '`s last login: ' . $date->format('d.m.Y H:i')); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | } |
@@ -56,20 +56,20 @@ |
||
56 | 56 | |
57 | 57 | protected function execute(InputInterface $input, OutputInterface $output) { |
58 | 58 | $user = $this->userManager->get($input->getArgument('uid')); |
59 | - if(is_null($user)) { |
|
59 | + if (is_null($user)) { |
|
60 | 60 | $output->writeln('<error>User does not exist</error>'); |
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $lastLogin = $user->getLastLogin(); |
65 | - if($lastLogin === 0) { |
|
66 | - $output->writeln('User ' . $user->getUID() . |
|
65 | + if ($lastLogin === 0) { |
|
66 | + $output->writeln('User '.$user->getUID(). |
|
67 | 67 | ' has never logged in, yet.'); |
68 | 68 | } else { |
69 | 69 | $date = new \DateTime(); |
70 | 70 | $date->setTimestamp($lastLogin); |
71 | - $output->writeln($user->getUID() . |
|
72 | - '`s last login: ' . $date->format('d.m.Y H:i')); |
|
71 | + $output->writeln($user->getUID(). |
|
72 | + '`s last login: '.$date->format('d.m.Y H:i')); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
@@ -32,58 +32,58 @@ |
||
32 | 32 | use Symfony\Component\Console\Output\OutputInterface; |
33 | 33 | |
34 | 34 | class ListCommand extends Base { |
35 | - /** @var IUserManager */ |
|
36 | - protected $userManager; |
|
35 | + /** @var IUserManager */ |
|
36 | + protected $userManager; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IUserManager $userManager |
|
40 | - */ |
|
41 | - public function __construct(IUserManager $userManager) { |
|
42 | - $this->userManager = $userManager; |
|
43 | - parent::__construct(); |
|
44 | - } |
|
38 | + /** |
|
39 | + * @param IUserManager $userManager |
|
40 | + */ |
|
41 | + public function __construct(IUserManager $userManager) { |
|
42 | + $this->userManager = $userManager; |
|
43 | + parent::__construct(); |
|
44 | + } |
|
45 | 45 | |
46 | - protected function configure() { |
|
47 | - $this |
|
48 | - ->setName('user:list') |
|
49 | - ->setDescription('list configured users') |
|
50 | - ->addOption( |
|
51 | - 'limit', |
|
52 | - 'l', |
|
53 | - InputOption::VALUE_OPTIONAL, |
|
54 | - 'Number of users to retrieve', |
|
55 | - 500 |
|
56 | - )->addOption( |
|
57 | - 'offset', |
|
58 | - 'o', |
|
59 | - InputOption::VALUE_OPTIONAL, |
|
60 | - 'Offset for retrieving users', |
|
61 | - 0 |
|
62 | - )->addOption( |
|
63 | - 'output', |
|
64 | - null, |
|
65 | - InputOption::VALUE_OPTIONAL, |
|
66 | - 'Output format (plain, json or json_pretty, default is plain)', |
|
67 | - $this->defaultOutputFormat |
|
68 | - ); |
|
69 | - } |
|
46 | + protected function configure() { |
|
47 | + $this |
|
48 | + ->setName('user:list') |
|
49 | + ->setDescription('list configured users') |
|
50 | + ->addOption( |
|
51 | + 'limit', |
|
52 | + 'l', |
|
53 | + InputOption::VALUE_OPTIONAL, |
|
54 | + 'Number of users to retrieve', |
|
55 | + 500 |
|
56 | + )->addOption( |
|
57 | + 'offset', |
|
58 | + 'o', |
|
59 | + InputOption::VALUE_OPTIONAL, |
|
60 | + 'Offset for retrieving users', |
|
61 | + 0 |
|
62 | + )->addOption( |
|
63 | + 'output', |
|
64 | + null, |
|
65 | + InputOption::VALUE_OPTIONAL, |
|
66 | + 'Output format (plain, json or json_pretty, default is plain)', |
|
67 | + $this->defaultOutputFormat |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | |
71 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
72 | - $users = $this->userManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
73 | - $this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users)); |
|
74 | - } |
|
71 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
72 | + $users = $this->userManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
73 | + $this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users)); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param IUser[] $users |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - private function formatUsers(array $users) { |
|
81 | - $keys = array_map(function (IUser $user) { |
|
82 | - return $user->getUID(); |
|
83 | - }, $users); |
|
84 | - $values = array_map(function (IUser $user) { |
|
85 | - return $user->getDisplayName(); |
|
86 | - }, $users); |
|
87 | - return array_combine($keys, $values); |
|
88 | - } |
|
76 | + /** |
|
77 | + * @param IUser[] $users |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + private function formatUsers(array $users) { |
|
81 | + $keys = array_map(function (IUser $user) { |
|
82 | + return $user->getUID(); |
|
83 | + }, $users); |
|
84 | + $values = array_map(function (IUser $user) { |
|
85 | + return $user->getDisplayName(); |
|
86 | + }, $users); |
|
87 | + return array_combine($keys, $values); |
|
88 | + } |
|
89 | 89 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | protected function execute(InputInterface $input, OutputInterface $output) { |
72 | - $users = $this->userManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
72 | + $users = $this->userManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset')); |
|
73 | 73 | $this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users)); |
74 | 74 | } |
75 | 75 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * @return array |
79 | 79 | */ |
80 | 80 | private function formatUsers(array $users) { |
81 | - $keys = array_map(function (IUser $user) { |
|
81 | + $keys = array_map(function(IUser $user) { |
|
82 | 82 | return $user->getUID(); |
83 | 83 | }, $users); |
84 | - $values = array_map(function (IUser $user) { |
|
84 | + $values = array_map(function(IUser $user) { |
|
85 | 85 | return $user->getDisplayName(); |
86 | 86 | }, $users); |
87 | 87 | return array_combine($keys, $values); |