Passed
Push — master ( 0f9b88...fa914f )
by Roeland
14:25 queued 12s
created
lib/private/Cache/CappedMemoryCache.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -30,66 +30,66 @@
 block discarded – undo
30 30
  * Uses a simple FIFO expiry mechanism
31 31
  */
32 32
 class CappedMemoryCache implements ICache, \ArrayAccess {
33
-	private $capacity;
34
-	private $cache = [];
35
-
36
-	public function __construct($capacity = 512) {
37
-		$this->capacity = $capacity;
38
-	}
39
-
40
-	public function hasKey($key) {
41
-		return isset($this->cache[$key]);
42
-	}
43
-
44
-	public function get($key) {
45
-		return isset($this->cache[$key]) ? $this->cache[$key] : null;
46
-	}
47
-
48
-	public function set($key, $value, $ttl = 0) {
49
-		if (is_null($key)) {
50
-			$this->cache[] = $value;
51
-		} else {
52
-			$this->cache[$key] = $value;
53
-		}
54
-		$this->garbageCollect();
55
-	}
56
-
57
-	public function remove($key) {
58
-		unset($this->cache[$key]);
59
-		return true;
60
-	}
61
-
62
-	public function clear($prefix = '') {
63
-		$this->cache = [];
64
-		return true;
65
-	}
66
-
67
-	public function offsetExists($offset) {
68
-		return $this->hasKey($offset);
69
-	}
70
-
71
-	public function &offsetGet($offset) {
72
-		return $this->cache[$offset];
73
-	}
74
-
75
-	public function offsetSet($offset, $value) {
76
-		$this->set($offset, $value);
77
-	}
78
-
79
-	public function offsetUnset($offset) {
80
-		$this->remove($offset);
81
-	}
82
-
83
-	public function getData() {
84
-		return $this->cache;
85
-	}
86
-
87
-
88
-	private function garbageCollect() {
89
-		while (count($this->cache) > $this->capacity) {
90
-			reset($this->cache);
91
-			$key = key($this->cache);
92
-			$this->remove($key);
93
-		}
94
-	}
33
+    private $capacity;
34
+    private $cache = [];
35
+
36
+    public function __construct($capacity = 512) {
37
+        $this->capacity = $capacity;
38
+    }
39
+
40
+    public function hasKey($key) {
41
+        return isset($this->cache[$key]);
42
+    }
43
+
44
+    public function get($key) {
45
+        return isset($this->cache[$key]) ? $this->cache[$key] : null;
46
+    }
47
+
48
+    public function set($key, $value, $ttl = 0) {
49
+        if (is_null($key)) {
50
+            $this->cache[] = $value;
51
+        } else {
52
+            $this->cache[$key] = $value;
53
+        }
54
+        $this->garbageCollect();
55
+    }
56
+
57
+    public function remove($key) {
58
+        unset($this->cache[$key]);
59
+        return true;
60
+    }
61
+
62
+    public function clear($prefix = '') {
63
+        $this->cache = [];
64
+        return true;
65
+    }
66
+
67
+    public function offsetExists($offset) {
68
+        return $this->hasKey($offset);
69
+    }
70
+
71
+    public function &offsetGet($offset) {
72
+        return $this->cache[$offset];
73
+    }
74
+
75
+    public function offsetSet($offset, $value) {
76
+        $this->set($offset, $value);
77
+    }
78
+
79
+    public function offsetUnset($offset) {
80
+        $this->remove($offset);
81
+    }
82
+
83
+    public function getData() {
84
+        return $this->cache;
85
+    }
86
+
87
+
88
+    private function garbageCollect() {
89
+        while (count($this->cache) > $this->capacity) {
90
+            reset($this->cache);
91
+            $key = key($this->cache);
92
+            $this->remove($key);
93
+        }
94
+    }
95 95
 }
Please login to merge, or discard this patch.
lib/private/Search.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		$results = [];
62 62
 		foreach ($this->providers as $provider) {
63 63
 			/** @var $provider Provider */
64
-			if (! $provider->providesResultsFor($inApps)) {
64
+			if (!$provider->providesResultsFor($inApps)) {
65 65
 				continue;
66 66
 			}
67 67
 			if ($provider instanceof PagedProvider) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	public function removeProvider($provider) {
97 97
 		$this->registeredProviders = array_filter(
98 98
 			$this->registeredProviders,
99
-			function ($element) use ($provider) {
99
+			function($element) use ($provider) {
100 100
 				return ($element['class'] != $provider);
101 101
 			}
102 102
 		);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * Create instances of all the registered search providers
118 118
 	 */
119 119
 	private function initProviders() {
120
-		if (! empty($this->providers)) {
120
+		if (!empty($this->providers)) {
121 121
 			return;
122 122
 		}
123 123
 		foreach ($this->registeredProviders as $provider) {
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -36,85 +36,85 @@
 block discarded – undo
36 36
  * Provide an interface to all search providers
37 37
  */
38 38
 class Search implements ISearch {
39
-	private $providers = [];
40
-	private $registeredProviders = [];
39
+    private $providers = [];
40
+    private $registeredProviders = [];
41 41
 
42
-	/**
43
-	 * Search all providers for $query
44
-	 * @param string $query
45
-	 * @param string[] $inApps optionally limit results to the given apps
46
-	 * @param int $page pages start at page 1
47
-	 * @param int $size, 0 = all
48
-	 * @return array An array of OC\Search\Result's
49
-	 */
50
-	public function searchPaged($query, array $inApps = [], $page = 1, $size = 30) {
51
-		$this->initProviders();
52
-		$results = [];
53
-		foreach ($this->providers as $provider) {
54
-			/** @var $provider Provider */
55
-			if (! $provider->providesResultsFor($inApps)) {
56
-				continue;
57
-			}
58
-			if ($provider instanceof PagedProvider) {
59
-				$results = array_merge($results, $provider->searchPaged($query, $page, $size));
60
-			} elseif ($provider instanceof Provider) {
61
-				$providerResults = $provider->search($query);
62
-				if ($size > 0) {
63
-					$slicedResults = array_slice($providerResults, ($page - 1) * $size, $size);
64
-					$results = array_merge($results, $slicedResults);
65
-				} else {
66
-					$results = array_merge($results, $providerResults);
67
-				}
68
-			} else {
69
-				\OC::$server->getLogger()->warning('Ignoring Unknown search provider', ['provider' => $provider]);
70
-			}
71
-		}
72
-		return $results;
73
-	}
42
+    /**
43
+     * Search all providers for $query
44
+     * @param string $query
45
+     * @param string[] $inApps optionally limit results to the given apps
46
+     * @param int $page pages start at page 1
47
+     * @param int $size, 0 = all
48
+     * @return array An array of OC\Search\Result's
49
+     */
50
+    public function searchPaged($query, array $inApps = [], $page = 1, $size = 30) {
51
+        $this->initProviders();
52
+        $results = [];
53
+        foreach ($this->providers as $provider) {
54
+            /** @var $provider Provider */
55
+            if (! $provider->providesResultsFor($inApps)) {
56
+                continue;
57
+            }
58
+            if ($provider instanceof PagedProvider) {
59
+                $results = array_merge($results, $provider->searchPaged($query, $page, $size));
60
+            } elseif ($provider instanceof Provider) {
61
+                $providerResults = $provider->search($query);
62
+                if ($size > 0) {
63
+                    $slicedResults = array_slice($providerResults, ($page - 1) * $size, $size);
64
+                    $results = array_merge($results, $slicedResults);
65
+                } else {
66
+                    $results = array_merge($results, $providerResults);
67
+                }
68
+            } else {
69
+                \OC::$server->getLogger()->warning('Ignoring Unknown search provider', ['provider' => $provider]);
70
+            }
71
+        }
72
+        return $results;
73
+    }
74 74
 
75
-	/**
76
-	 * Remove all registered search providers
77
-	 */
78
-	public function clearProviders() {
79
-		$this->providers = [];
80
-		$this->registeredProviders = [];
81
-	}
75
+    /**
76
+     * Remove all registered search providers
77
+     */
78
+    public function clearProviders() {
79
+        $this->providers = [];
80
+        $this->registeredProviders = [];
81
+    }
82 82
 
83
-	/**
84
-	 * Remove one existing search provider
85
-	 * @param string $provider class name of a OC\Search\Provider
86
-	 */
87
-	public function removeProvider($provider) {
88
-		$this->registeredProviders = array_filter(
89
-			$this->registeredProviders,
90
-			function ($element) use ($provider) {
91
-				return ($element['class'] != $provider);
92
-			}
93
-		);
94
-		// force regeneration of providers on next search
95
-		$this->providers = [];
96
-	}
83
+    /**
84
+     * Remove one existing search provider
85
+     * @param string $provider class name of a OC\Search\Provider
86
+     */
87
+    public function removeProvider($provider) {
88
+        $this->registeredProviders = array_filter(
89
+            $this->registeredProviders,
90
+            function ($element) use ($provider) {
91
+                return ($element['class'] != $provider);
92
+            }
93
+        );
94
+        // force regeneration of providers on next search
95
+        $this->providers = [];
96
+    }
97 97
 
98
-	/**
99
-	 * Register a new search provider to search with
100
-	 * @param string $class class name of a OC\Search\Provider
101
-	 * @param array $options optional
102
-	 */
103
-	public function registerProvider($class, array $options = []) {
104
-		$this->registeredProviders[] = ['class' => $class, 'options' => $options];
105
-	}
98
+    /**
99
+     * Register a new search provider to search with
100
+     * @param string $class class name of a OC\Search\Provider
101
+     * @param array $options optional
102
+     */
103
+    public function registerProvider($class, array $options = []) {
104
+        $this->registeredProviders[] = ['class' => $class, 'options' => $options];
105
+    }
106 106
 
107
-	/**
108
-	 * Create instances of all the registered search providers
109
-	 */
110
-	private function initProviders() {
111
-		if (! empty($this->providers)) {
112
-			return;
113
-		}
114
-		foreach ($this->registeredProviders as $provider) {
115
-			$class = $provider['class'];
116
-			$options = $provider['options'];
117
-			$this->providers[] = new $class($options);
118
-		}
119
-	}
107
+    /**
108
+     * Create instances of all the registered search providers
109
+     */
110
+    private function initProviders() {
111
+        if (! empty($this->providers)) {
112
+            return;
113
+        }
114
+        foreach ($this->registeredProviders as $provider) {
115
+            $class = $provider['class'];
116
+            $options = $provider['options'];
117
+            $this->providers[] = new $class($options);
118
+        }
119
+    }
120 120
 }
Please login to merge, or discard this patch.
lib/private/Search/Result/Audio.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@
 block discarded – undo
29 29
  */
30 30
 class Audio extends File {
31 31
 
32
-	/**
33
-	 * Type name; translated in templates
34
-	 * @var string
35
-	 */
36
-	public $type = 'audio';
32
+    /**
33
+     * Type name; translated in templates
34
+     * @var string
35
+     */
36
+    public $type = 'audio';
37 37
 	
38
-	/**
39
-	 * @TODO add ID3 information
40
-	 */
38
+    /**
39
+     * @TODO add ID3 information
40
+     */
41 41
 }
Please login to merge, or discard this patch.
lib/private/Search/Result/Image.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@
 block discarded – undo
29 29
  */
30 30
 class Image extends File {
31 31
 
32
-	/**
33
-	 * Type name; translated in templates
34
-	 * @var string
35
-	 */
36
-	public $type = 'image';
32
+    /**
33
+     * Type name; translated in templates
34
+     * @var string
35
+     */
36
+    public $type = 'image';
37 37
 	
38
-	/**
39
-	 * @TODO add EXIF information
40
-	 */
38
+    /**
39
+     * @TODO add EXIF information
40
+     */
41 41
 }
Please login to merge, or discard this patch.
lib/private/Search/Result/Folder.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@
 block discarded – undo
29 29
  */
30 30
 class Folder extends File {
31 31
 
32
-	/**
33
-	 * Type name; translated in templates
34
-	 * @var string
35
-	 */
36
-	public $type = 'folder';
32
+    /**
33
+     * Type name; translated in templates
34
+     * @var string
35
+     */
36
+    public $type = 'folder';
37 37
 }
Please login to merge, or discard this patch.
lib/private/Search/Provider/File.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,44 +33,44 @@
 block discarded – undo
33 33
  */
34 34
 class File extends \OCP\Search\Provider {
35 35
 
36
-	/**
37
-	 * Search for files and folders matching the given query
38
-	 * @param string $query
39
-	 * @return \OCP\Search\Result
40
-	 */
41
-	public function search($query) {
42
-		$files = Filesystem::search($query);
43
-		$results = [];
44
-		// edit results
45
-		foreach ($files as $fileData) {
46
-			// skip versions
47
-			if (strpos($fileData['path'], '_versions') === 0) {
48
-				continue;
49
-			}
50
-			// skip top-level folder
51
-			if ($fileData['name'] === 'files' && $fileData['parent'] === -1) {
52
-				continue;
53
-			}
54
-			// create audio result
55
-			if ($fileData['mimepart'] === 'audio') {
56
-				$result = new \OC\Search\Result\Audio($fileData);
57
-			}
58
-			// create image result
59
-			elseif ($fileData['mimepart'] === 'image') {
60
-				$result = new \OC\Search\Result\Image($fileData);
61
-			}
62
-			// create folder result
63
-			elseif ($fileData['mimetype'] === 'httpd/unix-directory') {
64
-				$result = new \OC\Search\Result\Folder($fileData);
65
-			}
66
-			// or create file result
67
-			else {
68
-				$result = new \OC\Search\Result\File($fileData);
69
-			}
70
-			// add to results
71
-			$results[] = $result;
72
-		}
73
-		// return
74
-		return $results;
75
-	}
36
+    /**
37
+     * Search for files and folders matching the given query
38
+     * @param string $query
39
+     * @return \OCP\Search\Result
40
+     */
41
+    public function search($query) {
42
+        $files = Filesystem::search($query);
43
+        $results = [];
44
+        // edit results
45
+        foreach ($files as $fileData) {
46
+            // skip versions
47
+            if (strpos($fileData['path'], '_versions') === 0) {
48
+                continue;
49
+            }
50
+            // skip top-level folder
51
+            if ($fileData['name'] === 'files' && $fileData['parent'] === -1) {
52
+                continue;
53
+            }
54
+            // create audio result
55
+            if ($fileData['mimepart'] === 'audio') {
56
+                $result = new \OC\Search\Result\Audio($fileData);
57
+            }
58
+            // create image result
59
+            elseif ($fileData['mimepart'] === 'image') {
60
+                $result = new \OC\Search\Result\Image($fileData);
61
+            }
62
+            // create folder result
63
+            elseif ($fileData['mimetype'] === 'httpd/unix-directory') {
64
+                $result = new \OC\Search\Result\Folder($fileData);
65
+            }
66
+            // or create file result
67
+            else {
68
+                $result = new \OC\Search\Result\File($fileData);
69
+            }
70
+            // add to results
71
+            $results[] = $result;
72
+        }
73
+        // return
74
+        return $results;
75
+    }
76 76
 }
Please login to merge, or discard this patch.
lib/private/Security/Certificate.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -27,104 +27,104 @@
 block discarded – undo
27 27
 use OCP\ICertificate;
28 28
 
29 29
 class Certificate implements ICertificate {
30
-	protected $name;
31
-
32
-	protected $commonName;
33
-
34
-	protected $organization;
35
-
36
-	protected $serial;
37
-
38
-	protected $issueDate;
39
-
40
-	protected $expireDate;
41
-
42
-	protected $issuerName;
43
-
44
-	protected $issuerOrganization;
45
-
46
-	/**
47
-	 * @param string $data base64 encoded certificate
48
-	 * @param string $name
49
-	 * @throws \Exception If the certificate could not get parsed
50
-	 */
51
-	public function __construct($data, $name) {
52
-		$this->name = $name;
53
-		$gmt = new \DateTimeZone('GMT');
54
-
55
-		// If string starts with "file://" ignore the certificate
56
-		$query = 'file://';
57
-		if (strtolower(substr($data, 0, strlen($query))) === $query) {
58
-			throw new \Exception('Certificate could not get parsed.');
59
-		}
60
-
61
-		$info = openssl_x509_parse($data);
62
-		if (!is_array($info)) {
63
-			throw new \Exception('Certificate could not get parsed.');
64
-		}
65
-
66
-		$this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null;
67
-		$this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null;
68
-		$this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt);
69
-		$this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt);
70
-		$this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null;
71
-		$this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null;
72
-	}
73
-
74
-	/**
75
-	 * @return string
76
-	 */
77
-	public function getName() {
78
-		return $this->name;
79
-	}
80
-
81
-	/**
82
-	 * @return string|null
83
-	 */
84
-	public function getCommonName() {
85
-		return $this->commonName;
86
-	}
87
-
88
-	/**
89
-	 * @return string
90
-	 */
91
-	public function getOrganization() {
92
-		return $this->organization;
93
-	}
94
-
95
-	/**
96
-	 * @return \DateTime
97
-	 */
98
-	public function getIssueDate() {
99
-		return $this->issueDate;
100
-	}
101
-
102
-	/**
103
-	 * @return \DateTime
104
-	 */
105
-	public function getExpireDate() {
106
-		return $this->expireDate;
107
-	}
108
-
109
-	/**
110
-	 * @return bool
111
-	 */
112
-	public function isExpired() {
113
-		$now = new \DateTime();
114
-		return $this->issueDate > $now or $now > $this->expireDate;
115
-	}
116
-
117
-	/**
118
-	 * @return string|null
119
-	 */
120
-	public function getIssuerName() {
121
-		return $this->issuerName;
122
-	}
123
-
124
-	/**
125
-	 * @return string|null
126
-	 */
127
-	public function getIssuerOrganization() {
128
-		return $this->issuerOrganization;
129
-	}
30
+    protected $name;
31
+
32
+    protected $commonName;
33
+
34
+    protected $organization;
35
+
36
+    protected $serial;
37
+
38
+    protected $issueDate;
39
+
40
+    protected $expireDate;
41
+
42
+    protected $issuerName;
43
+
44
+    protected $issuerOrganization;
45
+
46
+    /**
47
+     * @param string $data base64 encoded certificate
48
+     * @param string $name
49
+     * @throws \Exception If the certificate could not get parsed
50
+     */
51
+    public function __construct($data, $name) {
52
+        $this->name = $name;
53
+        $gmt = new \DateTimeZone('GMT');
54
+
55
+        // If string starts with "file://" ignore the certificate
56
+        $query = 'file://';
57
+        if (strtolower(substr($data, 0, strlen($query))) === $query) {
58
+            throw new \Exception('Certificate could not get parsed.');
59
+        }
60
+
61
+        $info = openssl_x509_parse($data);
62
+        if (!is_array($info)) {
63
+            throw new \Exception('Certificate could not get parsed.');
64
+        }
65
+
66
+        $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null;
67
+        $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null;
68
+        $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt);
69
+        $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt);
70
+        $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null;
71
+        $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null;
72
+    }
73
+
74
+    /**
75
+     * @return string
76
+     */
77
+    public function getName() {
78
+        return $this->name;
79
+    }
80
+
81
+    /**
82
+     * @return string|null
83
+     */
84
+    public function getCommonName() {
85
+        return $this->commonName;
86
+    }
87
+
88
+    /**
89
+     * @return string
90
+     */
91
+    public function getOrganization() {
92
+        return $this->organization;
93
+    }
94
+
95
+    /**
96
+     * @return \DateTime
97
+     */
98
+    public function getIssueDate() {
99
+        return $this->issueDate;
100
+    }
101
+
102
+    /**
103
+     * @return \DateTime
104
+     */
105
+    public function getExpireDate() {
106
+        return $this->expireDate;
107
+    }
108
+
109
+    /**
110
+     * @return bool
111
+     */
112
+    public function isExpired() {
113
+        $now = new \DateTime();
114
+        return $this->issueDate > $now or $now > $this->expireDate;
115
+    }
116
+
117
+    /**
118
+     * @return string|null
119
+     */
120
+    public function getIssuerName() {
121
+        return $this->issuerName;
122
+    }
123
+
124
+    /**
125
+     * @return string|null
126
+     */
127
+    public function getIssuerOrganization() {
128
+        return $this->issuerOrganization;
129
+    }
130 130
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@
 block discarded – undo
65 65
 
66 66
 		$this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null;
67 67
 		$this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null;
68
-		$this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt);
69
-		$this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt);
68
+		$this->issueDate = new \DateTime('@'.$info['validFrom_time_t'], $gmt);
69
+		$this->expireDate = new \DateTime('@'.$info['validTo_time_t'], $gmt);
70 70
 		$this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null;
71 71
 		$this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null;
72 72
 	}
Please login to merge, or discard this patch.
lib/private/Security/IdentityProof/Signer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
 			$user = $this->userManager->get($userId);
90 90
 			if ($user !== null) {
91 91
 				$key = $this->keyManager->getKey($user);
92
-				return (bool)openssl_verify(
92
+				return (bool) openssl_verify(
93 93
 					json_encode($data['message']),
94 94
 					base64_decode($data['signature']),
95 95
 					$key->getPublic(),
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -32,76 +32,76 @@
 block discarded – undo
32 32
 use OCP\IUserManager;
33 33
 
34 34
 class Signer {
35
-	/** @var Manager */
36
-	private $keyManager;
37
-	/** @var ITimeFactory */
38
-	private $timeFactory;
39
-	/** @var IUserManager */
40
-	private $userManager;
35
+    /** @var Manager */
36
+    private $keyManager;
37
+    /** @var ITimeFactory */
38
+    private $timeFactory;
39
+    /** @var IUserManager */
40
+    private $userManager;
41 41
 
42
-	/**
43
-	 * @param Manager $keyManager
44
-	 * @param ITimeFactory $timeFactory
45
-	 * @param IUserManager $userManager
46
-	 */
47
-	public function __construct(Manager $keyManager,
48
-								ITimeFactory $timeFactory,
49
-								IUserManager $userManager) {
50
-		$this->keyManager = $keyManager;
51
-		$this->timeFactory = $timeFactory;
52
-		$this->userManager = $userManager;
53
-	}
42
+    /**
43
+     * @param Manager $keyManager
44
+     * @param ITimeFactory $timeFactory
45
+     * @param IUserManager $userManager
46
+     */
47
+    public function __construct(Manager $keyManager,
48
+                                ITimeFactory $timeFactory,
49
+                                IUserManager $userManager) {
50
+        $this->keyManager = $keyManager;
51
+        $this->timeFactory = $timeFactory;
52
+        $this->userManager = $userManager;
53
+    }
54 54
 
55
-	/**
56
-	 * Returns a signed blob for $data
57
-	 *
58
-	 * @param string $type
59
-	 * @param array $data
60
-	 * @param IUser $user
61
-	 * @return array ['message', 'signature']
62
-	 */
63
-	public function sign(string $type, array $data, IUser $user): array {
64
-		$privateKey = $this->keyManager->getKey($user)->getPrivate();
65
-		$data = [
66
-			'data' => $data,
67
-			'type' => $type,
68
-			'signer' => $user->getCloudId(),
69
-			'timestamp' => $this->timeFactory->getTime(),
70
-		];
71
-		openssl_sign(json_encode($data), $signature, $privateKey, OPENSSL_ALGO_SHA512);
55
+    /**
56
+     * Returns a signed blob for $data
57
+     *
58
+     * @param string $type
59
+     * @param array $data
60
+     * @param IUser $user
61
+     * @return array ['message', 'signature']
62
+     */
63
+    public function sign(string $type, array $data, IUser $user): array {
64
+        $privateKey = $this->keyManager->getKey($user)->getPrivate();
65
+        $data = [
66
+            'data' => $data,
67
+            'type' => $type,
68
+            'signer' => $user->getCloudId(),
69
+            'timestamp' => $this->timeFactory->getTime(),
70
+        ];
71
+        openssl_sign(json_encode($data), $signature, $privateKey, OPENSSL_ALGO_SHA512);
72 72
 
73
-		return [
74
-			'message' => $data,
75
-			'signature' => base64_encode($signature),
76
-		];
77
-	}
73
+        return [
74
+            'message' => $data,
75
+            'signature' => base64_encode($signature),
76
+        ];
77
+    }
78 78
 
79
-	/**
80
-	 * Whether the data is signed properly
81
-	 *
82
-	 * @param array $data
83
-	 * @return bool
84
-	 */
85
-	public function verify(array $data): bool {
86
-		if (isset($data['message'])
87
-			&& isset($data['signature'])
88
-			&& isset($data['message']['signer'])
89
-		) {
90
-			$location = strrpos($data['message']['signer'], '@');
91
-			$userId = substr($data['message']['signer'], 0, $location);
79
+    /**
80
+     * Whether the data is signed properly
81
+     *
82
+     * @param array $data
83
+     * @return bool
84
+     */
85
+    public function verify(array $data): bool {
86
+        if (isset($data['message'])
87
+            && isset($data['signature'])
88
+            && isset($data['message']['signer'])
89
+        ) {
90
+            $location = strrpos($data['message']['signer'], '@');
91
+            $userId = substr($data['message']['signer'], 0, $location);
92 92
 
93
-			$user = $this->userManager->get($userId);
94
-			if ($user !== null) {
95
-				$key = $this->keyManager->getKey($user);
96
-				return (bool)openssl_verify(
97
-					json_encode($data['message']),
98
-					base64_decode($data['signature']),
99
-					$key->getPublic(),
100
-					OPENSSL_ALGO_SHA512
101
-				);
102
-			}
103
-		}
93
+            $user = $this->userManager->get($userId);
94
+            if ($user !== null) {
95
+                $key = $this->keyManager->getKey($user);
96
+                return (bool)openssl_verify(
97
+                    json_encode($data['message']),
98
+                    base64_decode($data['signature']),
99
+                    $key->getPublic(),
100
+                    OPENSSL_ALGO_SHA512
101
+                );
102
+            }
103
+        }
104 104
 
105
-		return false;
106
-	}
105
+        return false;
106
+    }
107 107
 }
Please login to merge, or discard this patch.
lib/private/Encryption/Exceptions/EncryptionHeaderToLargeException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 use OCP\Encryption\Exceptions\GenericEncryptionException;
28 28
 
29 29
 class EncryptionHeaderToLargeException extends GenericEncryptionException {
30
-	public function __construct() {
31
-		parent::__construct('max header size exceeded');
32
-	}
30
+    public function __construct() {
31
+        parent::__construct('max header size exceeded');
32
+    }
33 33
 }
Please login to merge, or discard this patch.