don't read certificates if ownCloud is not installed

This commit is contained in:
Bjoern Schiessle 2015-08-06 16:51:31 +02:00
parent 289e9130f3
commit 37513f9411
4 changed files with 22 additions and 4 deletions

View file

@ -27,6 +27,7 @@ namespace OC\Security;
use OC\Files\Filesystem;
use OCP\ICertificateManager;
use OCP\IConfig;
/**
* Manage trusted certificates for users
@ -42,13 +43,20 @@ class CertificateManager implements ICertificateManager {
*/
protected $view;
/**
* @var IConfig
*/
protected $config;
/**
* @param string $uid
* @param \OC\Files\View $view relative zu data/
* @param IConfig $config
*/
public function __construct($uid, \OC\Files\View $view) {
public function __construct($uid, \OC\Files\View $view, IConfig $config) {
$this->uid = $uid;
$this->view = $view;
$this->config = $config;
}
/**
@ -57,6 +65,11 @@ class CertificateManager implements ICertificateManager {
* @return \OCP\ICertificate[]
*/
public function listCertificates() {
if (!$this->config->getSystemValue('installed', false)) {
return array();
}
$path = $this->getPathToCertificates() . 'uploads/';
if (!$this->view->is_dir($path)) {
return array();

View file

@ -339,7 +339,7 @@ class Server extends SimpleContainer implements IServerContainer {
$uid = $user ? $user : null;
return new ClientService(
$c->getConfig(),
new \OC\Security\CertificateManager($uid, new View())
new \OC\Security\CertificateManager($uid, new View(), $c->getConfig())
);
});
$this->registerService('EventLogger', function (Server $c) {
@ -852,7 +852,7 @@ class Server extends SimpleContainer implements IServerContainer {
}
$userId = $user->getUID();
}
return new CertificateManager($userId, new View());
return new CertificateManager($userId, new View(), $this->getConfig());
}
/**

View file

@ -1145,6 +1145,7 @@ class OC_Util {
* @throws \OC\HintException If the test file can't get written.
*/
public function isHtaccessWorking(\OCP\IConfig $config) {
if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) {
return true;
}

View file

@ -26,7 +26,11 @@ class CertificateManagerTest extends \Test\TestCase {
\OC\Files\Filesystem::tearDown();
\OC_Util::setupFS($this->username);
$this->certificateManager = new CertificateManager($this->username, new \OC\Files\View());
$config = $this->getMock('OCP\IConfig');
$config->expects($this->any())->method('getSystemValue')
->with('installed', false)->willReturn(true);
$this->certificateManager = new CertificateManager($this->username, new \OC\Files\View(), $config);
}
protected function tearDown() {