Exemplo n.º 1
0
 /**
  * Sets the default options to the client
  */
 private function setDefaultOptions()
 {
     // Either use user bundle or the system bundle if nothing is specified
     if ($this->certificateManager->listCertificates() !== []) {
         $this->client->setDefaultOption('verify', $this->certificateManager->getAbsoluteBundlePath());
     } else {
         $this->client->setDefaultOption('verify', $this->certificateManager->getAbsoluteBundlePath(null));
     }
     $this->client->setDefaultOption('headers/User-Agent', 'ownCloud Server Crawler');
     if ($this->getProxyUri() !== '') {
         $this->client->setDefaultOption('proxy', $this->getProxyUri());
     }
 }
Exemplo n.º 2
0
 /**
  * Sets the default options to the client
  */
 private function setDefaultOptions()
 {
     // Either use default bundle or the user bundle if nothing is specified
     if ($this->certificateManager->listCertificates() !== []) {
         $dataDir = $this->config->getSystemValue('datadirectory');
         $this->client->setDefaultOption('verify', $dataDir . '/' . $this->certificateManager->getCertificateBundle());
     } else {
         $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/config/ca-bundle.crt');
     }
     $this->client->setDefaultOption('headers/User-Agent', 'ownCloud Server Crawler');
     if ($this->getProxyUri() !== '') {
         $this->client->setDefaultOption('proxy', $this->getProxyUri());
     }
 }
Exemplo n.º 3
0
 /**
  * Sets the default options to the client
  */
 private function setDefaultOptions()
 {
     // Either use user bundle or the system bundle if nothing is specified
     if ($this->certificateManager->listCertificates() !== []) {
         $this->client->setDefaultOption('verify', $this->certificateManager->getAbsoluteBundlePath());
     } else {
         // If the instance is not yet setup we need to use the static path as
         // $this->certificateManager->getAbsoluteBundlePath() tries to instantiiate
         // a view
         if ($this->config->getSystemValue('installed', false)) {
             $this->client->setDefaultOption('verify', $this->certificateManager->getAbsoluteBundlePath(null));
         } else {
             $this->client->setDefaultOption('verify', \OC::$SERVERROOT . '/resources/config/ca-bundle.crt');
         }
     }
     $this->client->setDefaultOption('headers/User-Agent', 'ownCloud Server Crawler');
     if ($this->getProxyUri() !== '') {
         $this->client->setDefaultOption('proxy', $this->getProxyUri());
     }
 }
Exemplo n.º 4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputType = $input->getOption('output');
     if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
         $certificates = array_map(function (ICertificate $certificate) {
             return ['name' => $certificate->getName(), 'common_name' => $certificate->getCommonName(), 'organization' => $certificate->getOrganization(), 'expire' => $certificate->getExpireDate()->format(\DateTime::ATOM), 'issuer' => $certificate->getIssuerName(), 'issuer_organization' => $certificate->getIssuerOrganization(), 'issue_date' => $certificate->getIssueDate()->format(\DateTime::ATOM)];
         }, $this->certificateManager->listCertificates());
         if ($outputType === self::OUTPUT_FORMAT_JSON) {
             $output->writeln(json_encode(array_values($certificates)));
         } else {
             $output->writeln(json_encode(array_values($certificates), JSON_PRETTY_PRINT));
         }
     } else {
         $table = new Table($output);
         $table->setHeaders(['File Name', 'Common Name', 'Organization', 'Valid Until', 'Issued By']);
         $rows = array_map(function (ICertificate $certificate) {
             return [$certificate->getName(), $certificate->getCommonName(), $certificate->getOrganization(), $this->l->l('date', $certificate->getExpireDate()), $certificate->getIssuerName()];
         }, $this->certificateManager->listCertificates());
         $table->setRows($rows);
         $table->render();
     }
 }