summaryrefslogtreecommitdiffstats
path: root/lib/private/server.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/server.php')
-rw-r--r--lib/private/server.php60
1 files changed, 49 insertions, 11 deletions
diff --git a/lib/private/server.php b/lib/private/server.php
index ff78536cec0..287b70eb806 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -40,6 +40,7 @@ use bantu\IniGetWrapper\IniGetWrapper;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Db\Db;
use OC\AppFramework\Utility\SimpleContainer;
+use OC\AppFramework\Utility\TimeFactory;
use OC\Command\AsyncBus;
use OC\Diagnostics\EventLogger;
use OC\Diagnostics\NullEventLogger;
@@ -48,6 +49,7 @@ use OC\Diagnostics\QueryLogger;
use OC\Files\Node\Root;
use OC\Files\View;
use OC\Http\Client\ClientService;
+use OC\Lock\DBLockingProvider;
use OC\Lock\MemcacheLockingProvider;
use OC\Lock\NoopLockingProvider;
use OC\Mail\Mailer;
@@ -56,6 +58,7 @@ use OC\Security\Crypto;
use OC\Security\Hasher;
use OC\Security\SecureRandom;
use OC\Security\TrustedDomainHelper;
+use OC\Session\CryptoWrapper;
use OC\Tagging\TagMapper;
use OCP\IServerContainer;
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -159,7 +162,12 @@ class Server extends SimpleContainer implements IServerContainer {
});
$this->registerService('UserSession', function (Server $c) {
$manager = $c->getUserManager();
- $userSession = new \OC\User\Session($manager, new \OC\Session\Memory(''));
+
+ $session = new \OC\Session\Memory('');
+ $cryptoWrapper = $c->getSessionCryptoWrapper();
+ $session = $cryptoWrapper->wrapSession($session);
+
+ $userSession = new \OC\User\Session($manager, $session);
$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
});
@@ -322,14 +330,14 @@ class Server extends SimpleContainer implements IServerContainer {
);
});
$this->registerService('EventLogger', function (Server $c) {
- if (defined('DEBUG') and DEBUG) {
+ if ($c->getSystemConfig()->getValue('debug', false)) {
return new EventLogger();
} else {
return new NullEventLogger();
}
});
- $this->registerService('QueryLogger', function ($c) {
- if (defined('DEBUG') and DEBUG) {
+ $this->registerService('QueryLogger', function (Server $c) {
+ if ($c->getSystemConfig()->getValue('debug', false)) {
return new QueryLogger();
} else {
return new NullQueryLogger();
@@ -434,13 +442,10 @@ class Server extends SimpleContainer implements IServerContainer {
/** @var \OC\Memcache\Factory $memcacheFactory */
$memcacheFactory = $c->getMemCacheFactory();
$memcache = $memcacheFactory->createLocking('lock');
- if (!($memcache instanceof \OC\Memcache\NullCache)) {
- return new MemcacheLockingProvider($memcache);
- }
- throw new HintException(
- 'File locking is enabled but the locking cache class was not found',
- 'Please check the "memcache.locking" setting and make sure the matching PHP module is installed and enabled'
- );
+// if (!($memcache instanceof \OC\Memcache\NullCache)) {
+// return new MemcacheLockingProvider($memcache);
+// }
+ return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger());
}
return new NoopLockingProvider();
});
@@ -462,6 +467,32 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('EventDispatcher', function() {
return new EventDispatcher();
});
+ $this->registerService('CryptoWrapper', function (Server $c) {
+ // FIXME: Instantiiated here due to cyclic dependency
+ $request = new Request(
+ [
+ 'get' => $_GET,
+ 'post' => $_POST,
+ 'files' => $_FILES,
+ 'server' => $_SERVER,
+ 'env' => $_ENV,
+ 'cookies' => $_COOKIE,
+ 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
+ ? $_SERVER['REQUEST_METHOD']
+ : null,
+ ],
+ new SecureRandom(),
+ $c->getCrypto(),
+ $c->getConfig()
+ );
+
+ return new CryptoWrapper(
+ $c->getConfig(),
+ $c->getCrypto(),
+ $c->getSecureRandom(),
+ $request
+ );
+ });
}
/**
@@ -977,4 +1008,11 @@ class Server extends SimpleContainer implements IServerContainer {
public function getEventDispatcher() {
return $this->query('EventDispatcher');
}
+
+ /**
+ * @return \OC\Session\CryptoWrapper
+ */
+ public function getSessionCryptoWrapper() {
+ return $this->query('CryptoWrapper');
+ }
}