summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/stream.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-11-10 12:46:53 +0100
committerVincent Petry <pvince81@owncloud.com>2014-11-10 12:46:53 +0100
commit676b911b22c97eacddc53a2ff5a8333846c981e2 (patch)
tree397a6fa5032f25e7169fd6d4e579dd0d89f2fd01 /apps/files_encryption/lib/stream.php
parent0d00e247c374318d502cb0501fce3093320fa5a3 (diff)
parenta10ae2816eac4ab9b891972567d20e15dd2cb202 (diff)
downloadnextcloud-server-676b911b22c97eacddc53a2ff5a8333846c981e2.tar.gz
nextcloud-server-676b911b22c97eacddc53a2ff5a8333846c981e2.zip
Merge pull request #12027 from owncloud/cleanup_exceptions
[encryption] clean up encryption exceptions
Diffstat (limited to 'apps/files_encryption/lib/stream.php')
-rw-r--r--apps/files_encryption/lib/stream.php22
1 files changed, 12 insertions, 10 deletions
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 931aa08cb2c..672a5878a24 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -2,10 +2,11 @@
/**
* ownCloud
*
- * @author Bjoern Schiessle, Robin Appelman
- * @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com>
- * 2012 Sam Tuke <samtuke@owncloud.com>,
- * 2011 Robin Appelman <icewind1991@gmail.com>
+ * @copyright (C) 2014 ownCloud, Inc.
+ *
+ * @author Bjoern Schiessle <schiessle@owncloud.com>
+ * @author Robin Appelman <icewind@owncloud.com>
+ * @author Sam Tuke <samtuke@owncloud.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@@ -30,7 +31,7 @@
*/
namespace OCA\Encryption;
-use OCA\Encryption\Exceptions\EncryptionException;
+use OCA\Encryption\Exception\EncryptionException;
/**
* Provides 'crypt://' stream wrapper protocol.
@@ -91,6 +92,7 @@ class Stream {
* @param int $options
* @param string $opened_path
* @return bool
+ * @throw \OCA\Encryption\Exception\EncryptionException
*/
public function stream_open($path, $mode, $options, &$opened_path) {
@@ -109,7 +111,7 @@ class Stream {
$this->privateKey = $this->session->getPrivateKey();
if ($this->privateKey === false) {
throw new EncryptionException('Session does not contain a private key, maybe your login password changed?',
- EncryptionException::NO_PRIVATE_KEY_AVAILABLE);
+ EncryptionException::PRIVATE_KEY_MISSING);
}
$normalizedPath = \OC\Files\Filesystem::normalizePath(str_replace('crypt://', '', $path));
@@ -249,7 +251,7 @@ class Stream {
/**
* @param int $count
* @return bool|string
- * @throws \OCA\Encryption\Exceptions\EncryptionException
+ * @throws \OCA\Encryption\Exception\EncryptionException
*/
public function stream_read($count) {
@@ -257,7 +259,7 @@ class Stream {
if ($count !== Crypt::BLOCKSIZE) {
\OCP\Util::writeLog('Encryption library', 'PHP "bug" 21641 no longer holds, decryption system requires refactoring', \OCP\Util::FATAL);
- throw new \OCA\Encryption\Exceptions\EncryptionException('expected a blog size of 8192 byte', 20);
+ throw new EncryptionException('expected a blog size of 8192 byte', EncryptionException::UNEXPECTED_BLOG_SIZE);
}
// Get the data from the file handle
@@ -365,14 +367,14 @@ class Stream {
/**
* write header at beginning of encrypted file
*
- * @throws Exceptions\EncryptionException
+ * @throws Exception\EncryptionException
*/
private function writeHeader() {
$header = Crypt::generateHeader();
if (strlen($header) > Crypt::BLOCKSIZE) {
- throw new Exceptions\EncryptionException('max header size exceeded', 30);
+ throw new EncryptionException('max header size exceeded', EncryptionException::ENCRYPTION_HEADER_TO_LARGE);
}
$paddedHeader = str_pad($header, Crypt::BLOCKSIZE, self::PADDING_CHAR, STR_PAD_RIGHT);