@@ -19,15 +19,10 @@ | |||
* | |||
*/ | |||
use OCA\Encryption\AppInfo\Encryption; | |||
namespace OCA\Encryption\AppInfo; | |||
if (!OC::$CLI) { | |||
if (!\OC::$CLI) { | |||
$di = \OC::$server; | |||
$app = new Encryption('encryption', | |||
[], | |||
$di->getEncryptionManager(), | |||
$di->getConfig()); | |||
$app->boot(); | |||
$app = new Application(); | |||
} | |||
@@ -36,7 +36,7 @@ use OCP\Encryption\IManager; | |||
use OCP\IConfig; | |||
class Encryption extends \OCP\AppFramework\App { | |||
class Application extends \OCP\AppFramework\App { | |||
/** | |||
* @var IManager | |||
*/ | |||
@@ -49,19 +49,11 @@ class Encryption extends \OCP\AppFramework\App { | |||
/** | |||
* @param $appName | |||
* @param array $urlParams | |||
* @param IManager $encryptionManager | |||
* @param IConfig $config | |||
*/ | |||
public function __construct($appName, $urlParams = array(), IManager $encryptionManager, IConfig $config) { | |||
parent::__construct($appName, $urlParams); | |||
$this->encryptionManager = $encryptionManager; | |||
$this->config = $config; | |||
} | |||
/** | |||
* | |||
*/ | |||
public function boot() { | |||
public function __construct($urlParams = array()) { | |||
parent::__construct('encryption', $urlParams); | |||
$this->encryptionManager = \OC::$server->getEncryptionManager(); | |||
$this->config = \OC::$server->getConfig(); | |||
$this->registerServices(); | |||
$this->registerEncryptionModule(); | |||
$this->registerHooks(); | |||
@@ -153,6 +145,16 @@ class Encryption extends \OCP\AppFramework\App { | |||
$server->getEncryptionKeyStorage(\OCA\Encryption\Crypto\Encryption::ID)); | |||
}); | |||
$container->registerService('RecoveryController', function (IAppContainer $c) { | |||
$server = $c->getServer(); | |||
return new \OCA\Encryption\Controller\RecoveryController( | |||
$c->getAppName(), | |||
$server->getRequest(), | |||
$server->getConfig(), | |||
$server->getL10N($c->getAppName()), | |||
$c->query('Recovery')); | |||
}); | |||
$container->registerService('UserSetup', | |||
function (IAppContainer $c) { | |||
$server = $c->getServer(); |
@@ -20,17 +20,17 @@ | |||
*/ | |||
use OCP\AppFramework\App; | |||
namespace OCA\Encryption\AppInfo; | |||
(new App('encryption'))->registerRoutes($this, array('routes' => array( | |||
(new Application())->registerRoutes($this, array('routes' => array( | |||
[ | |||
'name' => 'recovery#adminRecovery', | |||
'name' => 'Recovery#adminRecovery', | |||
'url' => '/ajax/adminRecovery', | |||
'verb' => 'POST' | |||
], | |||
[ | |||
'name' => 'recovery#userRecovery', | |||
'name' => 'Recovery#userRecovery', | |||
'url' => '/ajax/userRecovery', | |||
'verb' => 'POST' | |||
] |
@@ -17,7 +17,7 @@ $(document).ready(function(){ | |||
var confirmPassword = $( '#repeatEncryptionRecoveryPassword' ).val(); | |||
OC.msg.startSaving('#encryptionSetRecoveryKey .msg'); | |||
$.post( | |||
OC.filePath( 'files_encryption', 'ajax', 'adminrecovery.php' ) | |||
OC.generateUrl('/apps/encryption/ajax/adminRecovery') | |||
, { adminEnableRecovery: recoveryStatus, recoveryPassword: recoveryPassword, confirmPassword: confirmPassword } | |||
, function( result ) { | |||
OC.msg.finishedSaving('#encryptionSetRecoveryKey .msg', result); | |||
@@ -44,7 +44,7 @@ $(document).ready(function(){ | |||
var confirmNewPassword = $('#repeatedNewEncryptionRecoveryPassword').val(); | |||
OC.msg.startSaving('#encryptionChangeRecoveryKey .msg'); | |||
$.post( | |||
OC.filePath( 'files_encryption', 'ajax', 'changeRecoveryPassword.php' ) | |||
OC.filePath( 'encryption', 'ajax', 'changeRecoveryPassword.php' ) | |||
, { oldPassword: oldRecoveryPassword, newPassword: newRecoveryPassword, confirmPassword: confirmNewPassword } | |||
, function( data ) { | |||
OC.msg.finishedSaving('#encryptionChangeRecoveryKey .msg', data); |
@@ -193,7 +193,7 @@ class KeyManager { | |||
if ($encryptedKey) { | |||
$this->setPrivateKey($uid, $encryptedKey); | |||
$this->config->setAppValue('encryption', 'recoveryAdminEnabled', 1); | |||
$this->config->setAppValue('encryption', 'recoveryAdminEnabled', 0); | |||
return true; | |||
} | |||
return false; |
@@ -18,7 +18,4 @@ $recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 're | |||
$tmpl->assign('recoveryEnabled', $recoveryAdminEnabled); | |||
$tmpl->assign('initStatus', KeyManager::$session->get('initStatus')); | |||
\OCP\Util::addscript('files_encryption', 'settings-admin'); | |||
\OCP\Util::addscript('core', 'multiselect'); | |||
return $tmpl->fetchPage(); |
@@ -1,6 +1,8 @@ | |||
<?php | |||
/** @var array $_ */ | |||
/** @var OC_L10N $l */ | |||
/** @var array $_ */ | |||
/** @var OC_L10N $l */ | |||
script('encryption', 'settings-admin'); | |||
script('core', 'multiselect'); | |||
?> | |||
<form id="encryption" class="section"> | |||
<h2><?php p($l->t('ownCloud basic encryption module')); ?></h2> |
@@ -66,12 +66,15 @@ class Manager implements \OCP\Encryption\IManager { | |||
public function registerEncryptionModule(IEncryptionModule $module) { | |||
$id = $module->getId(); | |||
$name = $module->getDisplayName(); | |||
// FIXME why do we load the same encryption module multiple times | |||
/* | |||
if (isset($this->encryptionModules[$id])) { | |||
$message = 'Id "' . $id . '" already used by encryption module "' . $name . '"'; | |||
throw new Exceptions\ModuleAlreadyExistsException($message); | |||
} | |||
*/ | |||
$defaultEncryptionModuleId = $this->getDefaultEncryptionModuleId(); | |||
if (empty($defaultEncryptionModuleId)) { |
@@ -172,6 +172,18 @@ interface IServerContainer { | |||
*/ | |||
function getL10N($app, $lang = null); | |||
/** | |||
* @return \OC\Encryption\Manager | |||
*/ | |||
function getEncryptionManager(); | |||
/** | |||
* @param string $encryptionModuleId encryption module ID | |||
* | |||
* @return \OCP\Encryption\Keys\IStorage | |||
*/ | |||
function getEncryptionKeyStorage($encryptionModuleId); | |||
/** | |||
* Returns the URL generator | |||
* |