]> source.dussan.org Git - nextcloud-server.git/commitdiff
reformat code
authorFlorin Peter <github@florin-peter.de>
Mon, 3 Jun 2013 16:42:13 +0000 (18:42 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Thu, 13 Jun 2013 11:32:52 +0000 (13:32 +0200)
Conflicts:

apps/files_encryption/lib/session.php
apps/files_encryption/lib/util.php

apps/files_encryption/ajax/updatePrivateKeyPassword.php
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/crypt.php
apps/files_encryption/lib/helper.php
apps/files_encryption/lib/session.php
apps/files_encryption/lib/util.php
apps/files_encryption/settings-personal.php
apps/files_encryption/templates/settings-admin.php
apps/files_encryption/tests/crypt.php
apps/files_encryption/tests/share.php

index e0b3d55d8b3abc16f2e5c2eb1fe15ce5e5a978d2..49f97dd3231425b046953db51e8d7a144769b73d 100644 (file)
@@ -29,7 +29,7 @@ $user = \OCP\User::getUser();
 $proxyStatus = \OC_FileProxy::$enabled;
 \OC_FileProxy::$enabled = false;
 
-$keyPath = '/' . $user . '/files_encryption/'.$user.'.private.key';
+$keyPath = '/' . $user . '/files_encryption/' . $user . '.private.key';
 
 $encryptedKey = $view->file_get_contents($keyPath);
 $decryptedKey = \OCA\Encryption\Crypt::decryptPrivateKey($encryptedKey, $oldPassword);
index 10beb86da1166bf98b2900406d0bab0c6a2f278b..7698b95cfd36b9c897722df0d37c6fb7d1b544b4 100644 (file)
@@ -62,8 +62,9 @@ class Hooks {
 \r
                $privateKey = Crypt::decryptPrivateKey($encryptedKey, $params['password']);\r
 \r
-               if($privateKey === false) {\r
-                       \OCP\Util::writeLog('Encryption library', 'Private key for user "' . $params['uid'] . '" is not valid! Maybe the user password was changed from outside if so please change it back to gain access', \OCP\Util::ERROR);\r
+               if ($privateKey === false) {\r
+                       \OCP\Util::writeLog('Encryption library', 'Private key for user "' . $params['uid']\r
+                                                                                                         . '" is not valid! Maybe the user password was changed from outside if so please change it back to gain access', \OCP\Util::ERROR);\r
                }\r
 \r
                $session = new \OCA\Encryption\Session($view);\r
@@ -349,7 +350,7 @@ class Hooks {
                        $sharingEnabled = \OCP\Share::isEnabled();\r
 \r
                        // get the path including mount point only if not a shared folder\r
-                       if(strncmp($path, '/Shared' , strlen('/Shared') !== 0)) {\r
+                       if (strncmp($path, '/Shared', strlen('/Shared') !== 0)) {\r
                                // get path including the the storage mount point\r
                                $path = $util->getPathWithMountPoint($params['itemSource']);\r
                        }\r
@@ -426,14 +427,14 @@ class Hooks {
                        }\r
 \r
                        // get the path including mount point only if not a shared folder\r
-                       if(strncmp($path, '/Shared' , strlen('/Shared') !== 0)) {\r
+                       if (strncmp($path, '/Shared', strlen('/Shared') !== 0)) {\r
                                // get path including the the storage mount point\r
                                $path = $util->getPathWithMountPoint($params['itemSource']);\r
                        }\r
 \r
                        // if we unshare a folder we need a list of all (sub-)files\r
                        if ($params['itemType'] === 'folder') {\r
-                               $allFiles = $util->getAllFiles( $path );\r
+                               $allFiles = $util->getAllFiles($path);\r
                        } else {\r
                                $allFiles = array($path);\r
                        }\r
index 1f1dac3238b7fc97be9147ba6f9527510e26cad8..cd41390d1c56f21cefc9eda88c13ca91ed3dafb1 100755 (executable)
@@ -365,9 +365,9 @@ class Crypt {
 \r
                // check if this a valid private key\r
                $res = openssl_pkey_get_private($plainKey);\r
-               if(is_resource($res)) {\r
+               if (is_resource($res)) {\r
                        $sslInfo = openssl_pkey_get_details($res);\r
-                       if(!isset($sslInfo['key'])) {\r
+                       if (!isset($sslInfo['key'])) {\r
                                $plainKey = false;\r
                        }\r
                } else {\r
index 3fd18c7d26486a8f0e3ff78957f6b1d0571f6a5b..c603aa1677d05332398e93487c3e0a467479a0b9 100755 (executable)
@@ -74,7 +74,7 @@ class Helper {
                if (!$util->ready()) {
 
                        \OCP\Util::writeLog('Encryption library', 'User account "' . $util->getUserId()
-                                                                                                . '" is not ready for encryption; configuration started', \OCP\Util::DEBUG);
+                                                                                                         . '" is not ready for encryption; configuration started', \OCP\Util::DEBUG);
 
                        if (!$util->setupServerSide($password)) {
                                return false;
index 6b118582f7a827a38b1b92aae61f890f1922fca0..617c13c461b1137408dbbe0ccac675626589ab98 100644 (file)
@@ -90,7 +90,9 @@ class Session {
 
                        $encryptedKey = $this->view->file_get_contents(
                                '/owncloud_private_key/' . $publicShareKeyId . '.private.key');
-                       $privateKey = Crypt::symmetricDecryptFileContent($encryptedKey, '');
+
+                       $privateKey = Crypt::decryptPrivateKey($encryptedKey, '');
+
                        $this->setPublicSharePrivateKey($privateKey);
 
                        \OC_FileProxy::$enabled = $proxyStatus;
@@ -123,6 +125,7 @@ class Session {
                if (\OCA\Encryption\Helper::isPublicAccess()) {
                        return $this->getPublicSharePrivateKey();
                } else {
+
                        if (isset($_SESSION['privateKey']) && !empty($_SESSION['privateKey'])) {
                                return $_SESSION['privateKey'];
                        } else {
index ec239d2deb6757e3a36d79fc6989565513c86617..f274ae1d863f0ee36b39e482508cc3f8ff2a092b 100644 (file)
@@ -305,7 +305,7 @@ class Util {
                if (\OCP\DB::isError($result)) {
                        \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                } else {
-                       if($result->numRows() > 0) {
+                       if ($result->numRows() > 0) {
                                $row = $result->fetchRow();
                                if (isset($row['recovery_enabled'])) {
                                        $recoveryEnabled[] = $row['recovery_enabled'];
@@ -445,7 +445,7 @@ class Util {
 
                                                        // If the file uses old
                                                        // encryption system
-                                               } elseif ( Crypt::isLegacyEncryptedContent( $data, $relPath ) ) {
+                                               } elseif (Crypt::isLegacyEncryptedContent($data, $relPath)) {
 
                                                        $found['legacy'][] = array(
                                                                'name' => $file,
@@ -576,7 +576,9 @@ class Util {
                // get relative path
                $relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
 
-               if (isset($pathParts[2]) && $pathParts[2] === 'files' && $this->view->file_exists($path) && $this->isEncryptedPath($path)) {
+               if (isset($pathParts[2]) && $pathParts[2] === 'files' && $this->view->file_exists($path)
+                       && $this->isEncryptedPath($path)
+               ) {
 
                        // get the size from filesystem
                        $fullPath = $this->view->getLocalFile($path);
@@ -646,7 +648,7 @@ class Util {
                return $result;
        }
 
-       
+
        /**
         * @param $path
         * @return bool
@@ -690,28 +692,32 @@ class Util {
                                $relPath = $plainFile['path'];
 
                                //relative to /data
-                               $rawPath = '/'.$this->userId . '/files/' . $plainFile['path'];
+                               $rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
 
                                // Open plain file handle for binary reading
-                               $plainHandle = $this->view->fopen( $rawPath, 'rb' );
+                               $plainHandle = $this->view->fopen($rawPath, 'rb');
 
                                // Open enc file handle for binary writing, with same filename as original plain file
-                               $encHandle = fopen( 'crypt://' . $relPath.'.tmp', 'wb' );
+                               $encHandle = fopen('crypt://' . $relPath . '.tmp', 'wb');
 
                                // Move plain file to a temporary location
-                               $size = stream_copy_to_stream( $plainHandle, $encHandle );
+                               $size = stream_copy_to_stream($plainHandle, $encHandle);
 
                                fclose($encHandle);
 
                                $fakeRoot = $this->view->getRoot();
-                               $this->view->chroot('/'.$this->userId.'/files');
+                               $this->view->chroot('/' . $this->userId . '/files');
 
                                $this->view->rename($relPath . '.tmp', $relPath);
 
                                $this->view->chroot($fakeRoot);
 
                                // Add the file to the cache
-                               \OC\Files\Filesystem::putFileInfo( $relPath, array( 'encrypted' => true, 'size' => $size, 'unencrypted_size' => $size ) );
+                               \OC\Files\Filesystem::putFileInfo($relPath, array(
+                                                                                                                                'encrypted' => true,
+                                                                                                                                'size' => $size,
+                                                                                                                                'unencrypted_size' => $size
+                                                                                                                       ));
                        }
 
                        // Encrypt legacy encrypted files
@@ -822,7 +828,7 @@ class Util {
                if (\OCP\DB::isError($result)) {
                        \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                } else {
-                       if($result->numRows() > 0) {
+                       if ($result->numRows() > 0) {
                                $row = $result->fetchRow();
                                $path = substr($row['path'], strlen('files'));
                        }
@@ -1113,7 +1119,7 @@ class Util {
                if (\OCP\DB::isError($result)) {
                        \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                } else {
-                       if($result->numRows() > 0) {
+                       if ($result->numRows() > 0) {
                                $row = $result->fetchRow();
                                if (isset($row['migration_status'])) {
                                        $migrationStatus[] = $row['migration_status'];
@@ -1199,7 +1205,8 @@ class Util {
 
                $result = array();
 
-               $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath($this->userFilesDir . '/' . $dir));
+               $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath(
+                       $this->userFilesDir . '/' . $dir));
 
                // handling for re shared folders
                $pathSplit = explode('/', $dir);
@@ -1260,7 +1267,7 @@ class Util {
                if (\OCP\DB::isError($result)) {
                        \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                } else {
-                       if($result->numRows() > 0) {
+                       if ($result->numRows() > 0) {
                                $row = $result->fetchRow();
                        }
                }
@@ -1286,7 +1293,7 @@ class Util {
                if (\OCP\DB::isError($result)) {
                        \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                } else {
-                       if($result->numRows() > 0) {
+                       if ($result->numRows() > 0) {
                                $row = $result->fetchRow();
                        }
                }
@@ -1311,7 +1318,7 @@ class Util {
                if (\OCP\DB::isError($result)) {
                        \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                } else {
-                       if($result->numRows() > 0) {
+                       if ($result->numRows() > 0) {
                                $source = $result->fetchRow();
                        }
                }
@@ -1332,7 +1339,7 @@ class Util {
                                if (\OCP\DB::isError($result)) {
                                        \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                                } else {
-                                       if($result->numRows() > 0) {
+                                       if ($result->numRows() > 0) {
                                                $item = $result->fetchRow();
                                        }
                                }
@@ -1542,7 +1549,7 @@ class Util {
                list($storage, $internalPath) = \OC\Files\Cache\Cache::getById($id);
                $mount = \OC\Files\Filesystem::getMountByStorageId($storage);
                $mountPoint = $mount[0]->getMountPoint();
-               $path = \OC\Files\Filesystem::normalizePath($mountPoint.'/'.$internalPath);
+               $path = \OC\Files\Filesystem::normalizePath($mountPoint . '/' . $internalPath);
 
                // reformat the path to be relative e.g. /user/files/folder becomes /folder/
                $relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
index d23a4cfdde3e0ecf2e360c7d8ad326a7cb008e3c..3aa8b399355006661df22b0eedf3563a24c7050c 100644 (file)
@@ -26,7 +26,7 @@ $recoveryEnabledForUser = $util->recoveryEnabledForUser();
 \r
 $tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);\r
 $tmpl->assign('recoveryEnabledForUser', $recoveryEnabledForUser);\r
-$tmpl->assign("privateKeySet" , $privateKeySet);\r
+$tmpl->assign('privateKeySet', $privateKeySet);\r
 \r
 return $tmpl->fetchPage();\r
 \r
index 18fea1845f42189f9fce958377cd5984c5e1cccb..c420b006c4572132b9a58ac87dd7f4129e8a6c56 100644 (file)
@@ -1,54 +1,56 @@
 <form id="encryption">
        <fieldset class="personalblock">
-               
+
                <p>
-                       <strong><?php p($l->t( 'Encryption' )); ?></strong>
-                       <br />
+                       <strong><?php p($l->t('Encryption')); ?></strong>
+                       <br/>
                </p>
+
                <p>
-                       <?php p($l->t( "Enable encryption passwords recovery key (allow sharing to recovery key):" )); ?>
-                       <br />
-                       <br />
-                       <input type="password" name="recoveryPassword" id="recoveryPassword" />
-                       <label for="recoveryPassword"><?php p($l->t( "Recovery account password" )); ?></label>
-                       <br />
-                       <input 
-                       type='radio'
-                       name='adminEnableRecovery'
-                       value='1'
-                       <?php echo ( $_["recoveryEnabled"] == 1 ? 'checked="checked"' : 'disabled' ); ?> />
-                       <?php p($l->t( "Enabled" )); ?>
-                       <br />
-                       
-                       <input 
-                       type='radio'
-                       name='adminEnableRecovery'
-                       value='0'
-                       <?php echo ( $_["recoveryEnabled"] == 0 ? 'checked="checked"' : 'disabled' ); ?> />
-                       <?php p($l->t( "Disabled" )); ?>
+                       <?php p($l->t("Enable encryption passwords recovery key (allow sharing to recovery key):")); ?>
+                       <br/>
+                       <br/>
+                       <input type="password" name="recoveryPassword" id="recoveryPassword"/>
+                       <label for="recoveryPassword"><?php p($l->t("Recovery account password")); ?></label>
+                       <br/>
+                       <input
+                               type='radio'
+                               name='adminEnableRecovery'
+                               value='1'
+                               <?php echo($_["recoveryEnabled"] == 1 ? 'checked="checked"' : 'disabled'); ?> />
+                       <?php p($l->t("Enabled")); ?>
+                       <br/>
+
+                       <input
+                               type='radio'
+                               name='adminEnableRecovery'
+                               value='0'
+                               <?php echo($_["recoveryEnabled"] == 0 ? 'checked="checked"' : 'disabled'); ?> />
+                       <?php p($l->t("Disabled")); ?>
                </p>
-               <br /><br />
+               <br/><br/>
+
                <p>
-                       <strong><?php p($l->t( "Change encryption passwords recovery key:" )); ?></strong>
-                       <br /><br />
-                       <input 
+                       <strong><?php p($l->t("Change encryption passwords recovery key:")); ?></strong>
+                       <br/><br/>
+                       <input
                                type="password"
                                name="changeRecoveryPassword"
                                id="oldRecoveryPassword"
-                               <?php echo ( $_["recoveryEnabled"] == 0 ? 'disabled' : '' ); ?> />
-                       <label for="oldRecoveryPassword"><?php p($l->t( "Old Recovery account password" )); ?></label>
-                       <br />
-                       <input 
+                               <?php echo($_["recoveryEnabled"] == 0 ? 'disabled' : ''); ?> />
+                       <label for="oldRecoveryPassword"><?php p($l->t("Old Recovery account password")); ?></label>
+                       <br/>
+                       <input
                                type="password"
                                name="changeRecoveryPassword"
                                id="newRecoveryPassword"
-                               <?php echo ( $_["recoveryEnabled"] == 0 ? 'disabled' : '' ); ?> />
-                       <label for="newRecoveryPassword"><?php p($l->t( "New Recovery account password" )); ?></label>
-                       <br />
+                               <?php echo($_["recoveryEnabled"] == 0 ? 'disabled' : ''); ?> />
+                       <label for="newRecoveryPassword"><?php p($l->t("New Recovery account password")); ?></label>
+                       <br/>
                        <button
                                type="button"
                                name="submitChangeRecoveryKey"
-                               disabled><?php p($l->t( "Change Password" )); ?>
+                               disabled><?php p($l->t("Change Password")); ?>
                        </button>
                        <span class="msg"></span>
                </p>
index a203f78bc545acc0eb25a911959c318aaa9f74ca..42605eaa9eb546a930acfa35ef857b808729634d 100755 (executable)
@@ -92,8 +92,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
                // reset app files_trashbin
                if ($this->stateFilesTrashbin) {
                        OC_App::enable('files_trashbin');
-               }
-               else {
+               } else {
                        OC_App::disable('files_trashbin');
                }
        }
index 28f0de4941bef0e4dddaec413a90001a590a943b..9a0d542c6d55320ad751cd5a9d9ed113dc8f24be 100755 (executable)
@@ -111,8 +111,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
                // reset app files_trashbin
                if ($this->stateFilesTrashbin) {
                        OC_App::enable('files_trashbin');
-               }
-               else {
+               } else {
                        OC_App::disable('files_trashbin');
                }
        }