2011-10-21 11:02:11 -04:00
|
|
|
<?php
|
|
|
|
|
|
2013-03-02 06:18:28 -05:00
|
|
|
OC::$CLASSPATH['OCA\Encryption\Crypt'] = 'files_encryption/lib/crypt.php';
|
|
|
|
|
OC::$CLASSPATH['OCA\Encryption\Hooks'] = 'files_encryption/hooks/hooks.php';
|
|
|
|
|
OC::$CLASSPATH['OCA\Encryption\Util'] = 'files_encryption/lib/util.php';
|
|
|
|
|
OC::$CLASSPATH['OCA\Encryption\Keymanager'] = 'files_encryption/lib/keymanager.php';
|
|
|
|
|
OC::$CLASSPATH['OCA\Encryption\Stream'] = 'files_encryption/lib/stream.php';
|
|
|
|
|
OC::$CLASSPATH['OCA\Encryption\Proxy'] = 'files_encryption/lib/proxy.php';
|
|
|
|
|
OC::$CLASSPATH['OCA\Encryption\Session'] = 'files_encryption/lib/session.php';
|
2013-03-08 19:04:33 -05:00
|
|
|
OC::$CLASSPATH['OCA\Encryption\Capabilities'] = 'files_encryption/lib/capabilities.php';
|
2013-05-09 13:36:18 -04:00
|
|
|
OC::$CLASSPATH['OCA\Encryption\Helper'] = 'files_encryption/lib/helper.php';
|
2011-10-21 11:02:11 -04:00
|
|
|
|
2013-05-31 14:34:43 -04:00
|
|
|
if (!OC_Config::getValue('maintenance', false)) {
|
2013-05-30 16:41:30 -04:00
|
|
|
OC_FileProxy::register(new OCA\Encryption\Proxy());
|
2011-10-21 11:02:11 -04:00
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
// User related hooks
|
|
|
|
|
OCA\Encryption\Helper::registerUserHooks();
|
2011-10-21 11:02:11 -04:00
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
// Sharing related hooks
|
|
|
|
|
OCA\Encryption\Helper::registerShareHooks();
|
2013-01-14 14:07:28 -05:00
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
// Filesystem related hooks
|
|
|
|
|
OCA\Encryption\Helper::registerFilesystemHooks();
|
2013-04-27 14:18:05 -04:00
|
|
|
|
2013-06-27 08:09:22 -04:00
|
|
|
// App manager related hooks
|
|
|
|
|
OCA\Encryption\Helper::registerAppHooks();
|
|
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
stream_wrapper_register('crypt', 'OCA\Encryption\Stream');
|
2013-04-10 11:37:03 -04:00
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
// check if we are logged in
|
|
|
|
|
if (OCP\User::isLoggedIn()) {
|
2013-05-31 06:56:08 -04:00
|
|
|
|
2013-05-31 14:34:43 -04:00
|
|
|
// ensure filesystem is loaded
|
|
|
|
|
if (!\OC\Files\Filesystem::$loaded) {
|
|
|
|
|
\OC_Util::setupFS();
|
|
|
|
|
}
|
2013-05-31 06:56:08 -04:00
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
$view = new OC_FilesystemView('/');
|
2013-06-21 04:37:51 -04:00
|
|
|
|
2013-07-01 06:16:36 -04:00
|
|
|
$sessionReady = OCA\Encryption\Helper::checkRequirements();
|
|
|
|
|
if($sessionReady) {
|
2013-06-21 04:37:51 -04:00
|
|
|
$session = new \OCA\Encryption\Session($view);
|
|
|
|
|
}
|
2013-05-15 08:32:50 -04:00
|
|
|
|
2013-06-13 07:17:35 -04:00
|
|
|
$user = \OCP\USER::getUser();
|
2013-05-30 16:41:30 -04:00
|
|
|
// check if user has a private key
|
2013-06-21 04:37:51 -04:00
|
|
|
if ($sessionReady === false
|
|
|
|
|
|| (!$view->file_exists('/' . $user . '/files_encryption/' . $user . '.private.key')
|
|
|
|
|
&& OCA\Encryption\Crypt::mode() === 'server')
|
2013-05-30 16:41:30 -04:00
|
|
|
) {
|
2013-05-15 08:32:50 -04:00
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
// Force the user to log-in again if the encryption key isn't unlocked
|
|
|
|
|
// (happens when a user is logged in before the encryption app is
|
|
|
|
|
// enabled)
|
|
|
|
|
OCP\User::logout();
|
2013-05-15 08:32:50 -04:00
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
header("Location: " . OC::$WEBROOT . '/');
|
2013-05-15 08:32:50 -04:00
|
|
|
|
2013-05-30 16:41:30 -04:00
|
|
|
exit();
|
|
|
|
|
}
|
2013-05-15 08:32:50 -04:00
|
|
|
}
|
2013-05-30 16:41:30 -04:00
|
|
|
} else {
|
|
|
|
|
// logout user if we are in maintenance to force re-login
|
|
|
|
|
OCP\User::logout();
|
2013-05-15 08:32:50 -04:00
|
|
|
}
|
2012-02-22 16:20:46 -05:00
|
|
|
|
2013-02-09 12:01:38 -05:00
|
|
|
// Register settings scripts
|
2013-05-27 11:26:58 -04:00
|
|
|
OCP\App::registerAdmin('files_encryption', 'settings-admin');
|
|
|
|
|
OCP\App::registerPersonal('files_encryption', 'settings-personal');
|
2013-05-09 13:36:18 -04:00
|
|
|
|