Completed
Pull Request — master (#9550)
by Georg
18:24
created
lib/public/Encryption/IManager.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -34,67 +34,67 @@
 block discarded – undo
34 34
  */
35 35
 interface IManager {
36 36
 
37
-	/**
38
-	 * Check if encryption is available (at least one encryption module needs to be enabled)
39
-	 *
40
-	 * @return bool true if enabled, false if not
41
-	 * @since 8.1.0
42
-	 */
43
-	public function isEnabled();
37
+    /**
38
+     * Check if encryption is available (at least one encryption module needs to be enabled)
39
+     *
40
+     * @return bool true if enabled, false if not
41
+     * @since 8.1.0
42
+     */
43
+    public function isEnabled();
44 44
 
45
-	/**
46
-	 * Registers an callback function which must return an encryption module instance
47
-	 *
48
-	 * @param string $id
49
-	 * @param string $displayName
50
-	 * @param callable $callback
51
-	 * @throws ModuleAlreadyExistsException
52
-	 * @since 8.1.0
53
-	 */
54
-	public function registerEncryptionModule($id, $displayName, callable $callback);
45
+    /**
46
+     * Registers an callback function which must return an encryption module instance
47
+     *
48
+     * @param string $id
49
+     * @param string $displayName
50
+     * @param callable $callback
51
+     * @throws ModuleAlreadyExistsException
52
+     * @since 8.1.0
53
+     */
54
+    public function registerEncryptionModule($id, $displayName, callable $callback);
55 55
 
56
-	/**
57
-	 * Unregisters an encryption module
58
-	 *
59
-	 * @param string $moduleId
60
-	 * @since 8.1.0
61
-	 */
62
-	public function unregisterEncryptionModule($moduleId);
56
+    /**
57
+     * Unregisters an encryption module
58
+     *
59
+     * @param string $moduleId
60
+     * @since 8.1.0
61
+     */
62
+    public function unregisterEncryptionModule($moduleId);
63 63
 
64
-	/**
65
-	 * get a list of all encryption modules
66
-	 *
67
-	 * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
68
-	 * @since 8.1.0
69
-	 */
70
-	public function getEncryptionModules();
64
+    /**
65
+     * get a list of all encryption modules
66
+     *
67
+     * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]]
68
+     * @since 8.1.0
69
+     */
70
+    public function getEncryptionModules();
71 71
 
72 72
 
73
-	/**
74
-	 * get a specific encryption module
75
-	 *
76
-	 * @param string $moduleId Empty to get the default module
77
-	 * @return IEncryptionModule
78
-	 * @throws ModuleDoesNotExistsException
79
-	 * @since 8.1.0
80
-	 */
81
-	public function getEncryptionModule($moduleId = '');
73
+    /**
74
+     * get a specific encryption module
75
+     *
76
+     * @param string $moduleId Empty to get the default module
77
+     * @return IEncryptionModule
78
+     * @throws ModuleDoesNotExistsException
79
+     * @since 8.1.0
80
+     */
81
+    public function getEncryptionModule($moduleId = '');
82 82
 
83
-	/**
84
-	 * get default encryption module Id
85
-	 *
86
-	 * @return string
87
-	 * @since 8.1.0
88
-	 */
89
-	public function getDefaultEncryptionModuleId();
83
+    /**
84
+     * get default encryption module Id
85
+     *
86
+     * @return string
87
+     * @since 8.1.0
88
+     */
89
+    public function getDefaultEncryptionModuleId();
90 90
 
91
-	/**
92
-	 * set default encryption module Id
93
-	 *
94
-	 * @param string $moduleId
95
-	 * @return string
96
-	 * @since 8.1.0
97
-	 */
98
-	public function setDefaultEncryptionModule($moduleId);
91
+    /**
92
+     * set default encryption module Id
93
+     *
94
+     * @param string $moduleId
95
+     * @return string
96
+     * @since 8.1.0
97
+     */
98
+    public function setDefaultEncryptionModule($moduleId);
99 99
 
100 100
 }
Please login to merge, or discard this patch.
lib/public/Encryption/Keys/IStorage.php 1 patch
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -33,151 +33,151 @@
 block discarded – undo
33 33
  */
34 34
 interface IStorage {
35 35
 
36
-	/**
37
-	 * get user specific key
38
-	 *
39
-	 * @param string $uid ID if the user for whom we want the key
40
-	 * @param string $keyId id of the key
41
-	 * @param string $encryptionModuleId
42
-	 *
43
-	 * @return mixed key
44
-	 * @since 8.1.0
45
-	 */
46
-	public function getUserKey($uid, $keyId, $encryptionModuleId);
36
+    /**
37
+     * get user specific key
38
+     *
39
+     * @param string $uid ID if the user for whom we want the key
40
+     * @param string $keyId id of the key
41
+     * @param string $encryptionModuleId
42
+     *
43
+     * @return mixed key
44
+     * @since 8.1.0
45
+     */
46
+    public function getUserKey($uid, $keyId, $encryptionModuleId);
47 47
 
48
-	/**
49
-	 * get file specific key
50
-	 *
51
-	 * @param string $path path to file
52
-	 * @param string $keyId id of the key
53
-	 * @param string $encryptionModuleId
54
-	 *
55
-	 * @return mixed key
56
-	 * @since 8.1.0
57
-	 */
58
-	public function getFileKey($path, $keyId, $encryptionModuleId);
48
+    /**
49
+     * get file specific key
50
+     *
51
+     * @param string $path path to file
52
+     * @param string $keyId id of the key
53
+     * @param string $encryptionModuleId
54
+     *
55
+     * @return mixed key
56
+     * @since 8.1.0
57
+     */
58
+    public function getFileKey($path, $keyId, $encryptionModuleId);
59 59
 
60
-	/**
61
-	 * get system-wide encryption keys not related to a specific user,
62
-	 * e.g something like a key for public link shares
63
-	 *
64
-	 * @param string $keyId id of the key
65
-	 * @param string $encryptionModuleId
66
-	 *
67
-	 * @return mixed key
68
-	 * @since 8.1.0
69
-	 */
70
-	public function getSystemUserKey($keyId, $encryptionModuleId);
60
+    /**
61
+     * get system-wide encryption keys not related to a specific user,
62
+     * e.g something like a key for public link shares
63
+     *
64
+     * @param string $keyId id of the key
65
+     * @param string $encryptionModuleId
66
+     *
67
+     * @return mixed key
68
+     * @since 8.1.0
69
+     */
70
+    public function getSystemUserKey($keyId, $encryptionModuleId);
71 71
 
72
-	/**
73
-	 * set user specific key
74
-	 *
75
-	 * @param string $uid ID if the user for whom we want the key
76
-	 * @param string $keyId id of the key
77
-	 * @param mixed $key
78
-	 * @param string $encryptionModuleId
79
-	 * @since 8.1.0
80
-	 */
81
-	public function setUserKey($uid, $keyId, $key, $encryptionModuleId);
72
+    /**
73
+     * set user specific key
74
+     *
75
+     * @param string $uid ID if the user for whom we want the key
76
+     * @param string $keyId id of the key
77
+     * @param mixed $key
78
+     * @param string $encryptionModuleId
79
+     * @since 8.1.0
80
+     */
81
+    public function setUserKey($uid, $keyId, $key, $encryptionModuleId);
82 82
 
83
-	/**
84
-	 * set file specific key
85
-	 *
86
-	 * @param string $path path to file
87
-	 * @param string $keyId id of the key
88
-	 * @param mixed $key
89
-	 * @param string $encryptionModuleId
90
-	 * @since 8.1.0
91
-	 */
92
-	public function setFileKey($path, $keyId, $key, $encryptionModuleId);
83
+    /**
84
+     * set file specific key
85
+     *
86
+     * @param string $path path to file
87
+     * @param string $keyId id of the key
88
+     * @param mixed $key
89
+     * @param string $encryptionModuleId
90
+     * @since 8.1.0
91
+     */
92
+    public function setFileKey($path, $keyId, $key, $encryptionModuleId);
93 93
 
94
-	/**
95
-	 * set system-wide encryption keys not related to a specific user,
96
-	 * e.g something like a key for public link shares
97
-	 *
98
-	 * @param string $keyId id of the key
99
-	 * @param mixed $key
100
-	 * @param string $encryptionModuleId
101
-	 *
102
-	 * @return mixed key
103
-	 * @since 8.1.0
104
-	 */
105
-	public function setSystemUserKey($keyId, $key, $encryptionModuleId);
94
+    /**
95
+     * set system-wide encryption keys not related to a specific user,
96
+     * e.g something like a key for public link shares
97
+     *
98
+     * @param string $keyId id of the key
99
+     * @param mixed $key
100
+     * @param string $encryptionModuleId
101
+     *
102
+     * @return mixed key
103
+     * @since 8.1.0
104
+     */
105
+    public function setSystemUserKey($keyId, $key, $encryptionModuleId);
106 106
 
107
-	/**
108
-	 * delete user specific key
109
-	 *
110
-	 * @param string $uid ID if the user for whom we want to delete the key
111
-	 * @param string $keyId id of the key
112
-	 * @param string $encryptionModuleId
113
-	 *
114
-	 * @return boolean False when the key could not be deleted
115
-	 * @since 8.1.0
116
-	 */
117
-	public function deleteUserKey($uid, $keyId, $encryptionModuleId);
107
+    /**
108
+     * delete user specific key
109
+     *
110
+     * @param string $uid ID if the user for whom we want to delete the key
111
+     * @param string $keyId id of the key
112
+     * @param string $encryptionModuleId
113
+     *
114
+     * @return boolean False when the key could not be deleted
115
+     * @since 8.1.0
116
+     */
117
+    public function deleteUserKey($uid, $keyId, $encryptionModuleId);
118 118
 
119
-	/**
120
-	 * delete file specific key
121
-	 *
122
-	 * @param string $path path to file
123
-	 * @param string $keyId id of the key
124
-	 * @param string $encryptionModuleId
125
-	 *
126
-	 * @return boolean False when the key could not be deleted
127
-	 * @since 8.1.0
128
-	 */
129
-	public function deleteFileKey($path, $keyId, $encryptionModuleId);
119
+    /**
120
+     * delete file specific key
121
+     *
122
+     * @param string $path path to file
123
+     * @param string $keyId id of the key
124
+     * @param string $encryptionModuleId
125
+     *
126
+     * @return boolean False when the key could not be deleted
127
+     * @since 8.1.0
128
+     */
129
+    public function deleteFileKey($path, $keyId, $encryptionModuleId);
130 130
 
131
-	/**
132
-	 * delete all file keys for a given file
133
-	 *
134
-	 * @param string $path to the file
135
-	 *
136
-	 * @return boolean False when the keys could not be deleted
137
-	 * @since 8.1.0
138
-	 */
139
-	public function deleteAllFileKeys($path);
131
+    /**
132
+     * delete all file keys for a given file
133
+     *
134
+     * @param string $path to the file
135
+     *
136
+     * @return boolean False when the keys could not be deleted
137
+     * @since 8.1.0
138
+     */
139
+    public function deleteAllFileKeys($path);
140 140
 
141
-	/**
142
-	 * delete system-wide encryption keys not related to a specific user,
143
-	 * e.g something like a key for public link shares
144
-	 *
145
-	 * @param string $keyId id of the key
146
-	 * @param string $encryptionModuleId
147
-	 *
148
-	 * @return boolean False when the key could not be deleted
149
-	 * @since 8.1.0
150
-	 */
151
-	public function deleteSystemUserKey($keyId, $encryptionModuleId);
141
+    /**
142
+     * delete system-wide encryption keys not related to a specific user,
143
+     * e.g something like a key for public link shares
144
+     *
145
+     * @param string $keyId id of the key
146
+     * @param string $encryptionModuleId
147
+     *
148
+     * @return boolean False when the key could not be deleted
149
+     * @since 8.1.0
150
+     */
151
+    public function deleteSystemUserKey($keyId, $encryptionModuleId);
152 152
 
153
-	/**
154
-	 * copy keys if a file was renamed
155
-	 *
156
-	 * @param string $source
157
-	 * @param string $target
158
-	 * @return boolean
159
-	 * @since 8.1.0
160
-	 */
161
-	public function renameKeys($source, $target);
153
+    /**
154
+     * copy keys if a file was renamed
155
+     *
156
+     * @param string $source
157
+     * @param string $target
158
+     * @return boolean
159
+     * @since 8.1.0
160
+     */
161
+    public function renameKeys($source, $target);
162 162
 
163
-	/**
164
-	 * move keys if a file was renamed
165
-	 *
166
-	 * @param string $source
167
-	 * @param string $target
168
-	 * @return boolean
169
-	 * @since 8.1.0
170
-	 */
171
-	public function copyKeys($source, $target);
163
+    /**
164
+     * move keys if a file was renamed
165
+     *
166
+     * @param string $source
167
+     * @param string $target
168
+     * @return boolean
169
+     * @since 8.1.0
170
+     */
171
+    public function copyKeys($source, $target);
172 172
 
173
-	/**
174
-	 * backup keys of a given encryption module
175
-	 *
176
-	 * @param string $encryptionModuleId
177
-	 * @param string $purpose
178
-	 * @param string $uid
179
-	 * @return bool
180
-	 * @since 12.0.0
181
-	 */
182
-	public function backupUserKeys($encryptionModuleId, $purpose, $uid);
173
+    /**
174
+     * backup keys of a given encryption module
175
+     *
176
+     * @param string $encryptionModuleId
177
+     * @param string $purpose
178
+     * @param string $uid
179
+     * @return bool
180
+     * @since 12.0.0
181
+     */
182
+    public function backupUserKeys($encryptionModuleId, $purpose, $uid);
183 183
 }
Please login to merge, or discard this patch.
lib/public/IPreview.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 	/**
47 47
 	 * @since 9.2.0
48 48
 	 */
49
-	const EVENT = self::class . ':' . 'PreviewRequested';
49
+	const EVENT = self::class.':'.'PreviewRequested';
50 50
 
51 51
 	const MODE_FILL = 'fill';
52 52
 	const MODE_COVER = 'cover';
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -43,86 +43,86 @@
 block discarded – undo
43 43
  */
44 44
 interface IPreview {
45 45
 
46
-	/**
47
-	 * @since 9.2.0
48
-	 */
49
-	const EVENT = self::class . ':' . 'PreviewRequested';
46
+    /**
47
+     * @since 9.2.0
48
+     */
49
+    const EVENT = self::class . ':' . 'PreviewRequested';
50 50
 
51
-	const MODE_FILL = 'fill';
52
-	const MODE_COVER = 'cover';
51
+    const MODE_FILL = 'fill';
52
+    const MODE_COVER = 'cover';
53 53
 
54
-	/**
55
-	 * In order to improve lazy loading a closure can be registered which will be
56
-	 * called in case preview providers are actually requested
57
-	 *
58
-	 * $callable has to return an instance of \OCP\Preview\IProvider
59
-	 *
60
-	 * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
61
-	 * @param \Closure $callable
62
-	 * @return void
63
-	 * @since 8.1.0
64
-	 */
65
-	public function registerProvider($mimeTypeRegex, \Closure $callable);
54
+    /**
55
+     * In order to improve lazy loading a closure can be registered which will be
56
+     * called in case preview providers are actually requested
57
+     *
58
+     * $callable has to return an instance of \OCP\Preview\IProvider
59
+     *
60
+     * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider
61
+     * @param \Closure $callable
62
+     * @return void
63
+     * @since 8.1.0
64
+     */
65
+    public function registerProvider($mimeTypeRegex, \Closure $callable);
66 66
 
67
-	/**
68
-	 * Get all providers
69
-	 * @return array
70
-	 * @since 8.1.0
71
-	 */
72
-	public function getProviders();
67
+    /**
68
+     * Get all providers
69
+     * @return array
70
+     * @since 8.1.0
71
+     */
72
+    public function getProviders();
73 73
 
74
-	/**
75
-	 * Does the manager have any providers
76
-	 * @return bool
77
-	 * @since 8.1.0
78
-	 */
79
-	public function hasProviders();
74
+    /**
75
+     * Does the manager have any providers
76
+     * @return bool
77
+     * @since 8.1.0
78
+     */
79
+    public function hasProviders();
80 80
 
81
-	/**
82
-	 * Return a preview of a file
83
-	 * @param string $file The path to the file where you want a thumbnail from
84
-	 * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
85
-	 * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
86
-	 * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
87
-	 * @return \OCP\IImage
88
-	 * @since 6.0.0
89
-	 * @deprecated 11 Use getPreview
90
-	 */
91
-	public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false);
81
+    /**
82
+     * Return a preview of a file
83
+     * @param string $file The path to the file where you want a thumbnail from
84
+     * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
85
+     * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
86
+     * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly
87
+     * @return \OCP\IImage
88
+     * @since 6.0.0
89
+     * @deprecated 11 Use getPreview
90
+     */
91
+    public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false);
92 92
 
93
-	/**
94
-	 * Returns a preview of a file
95
-	 *
96
-	 * The cache is searched first and if nothing usable was found then a preview is
97
-	 * generated by one of the providers
98
-	 *
99
-	 * @param File $file
100
-	 * @param int $width
101
-	 * @param int $height
102
-	 * @param bool $crop
103
-	 * @param string $mode
104
-	 * @param string $mimeType To force a given mimetype for the file (files_versions needs this)
105
-	 * @return ISimpleFile
106
-	 * @throws NotFoundException
107
-	 * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
108
-	 * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0
109
-	 */
110
-	public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null);
93
+    /**
94
+     * Returns a preview of a file
95
+     *
96
+     * The cache is searched first and if nothing usable was found then a preview is
97
+     * generated by one of the providers
98
+     *
99
+     * @param File $file
100
+     * @param int $width
101
+     * @param int $height
102
+     * @param bool $crop
103
+     * @param string $mode
104
+     * @param string $mimeType To force a given mimetype for the file (files_versions needs this)
105
+     * @return ISimpleFile
106
+     * @throws NotFoundException
107
+     * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid)
108
+     * @since 11.0.0 - \InvalidArgumentException was added in 12.0.0
109
+     */
110
+    public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null);
111 111
 
112
-	/**
113
-	 * Returns true if the passed mime type is supported
114
-	 * @param string $mimeType
115
-	 * @return boolean
116
-	 * @since 6.0.0
117
-	 */
118
-	public function isMimeSupported($mimeType = '*');
112
+    /**
113
+     * Returns true if the passed mime type is supported
114
+     * @param string $mimeType
115
+     * @return boolean
116
+     * @since 6.0.0
117
+     */
118
+    public function isMimeSupported($mimeType = '*');
119 119
 
120
-	/**
121
-	 * Check if a preview can be generated for a file
122
-	 *
123
-	 * @param \OCP\Files\FileInfo $file
124
-	 * @return bool
125
-	 * @since 8.0.0
126
-	 */
127
-	public function isAvailable(\OCP\Files\FileInfo $file);
120
+    /**
121
+     * Check if a preview can be generated for a file
122
+     *
123
+     * @param \OCP\Files\FileInfo $file
124
+     * @return bool
125
+     * @since 8.0.0
126
+     */
127
+    public function isAvailable(\OCP\Files\FileInfo $file);
128 128
 }
Please login to merge, or discard this patch.
lib/private/Authentication/LoginCredentials/Credentials.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -28,45 +28,45 @@
 block discarded – undo
28 28
 
29 29
 class Credentials implements ICredentials {
30 30
 
31
-	/** @var string */
32
-	private $uid;
31
+    /** @var string */
32
+    private $uid;
33 33
 
34
-	/** @var string */
35
-	private $loginName;
34
+    /** @var string */
35
+    private $loginName;
36 36
 
37
-	/** @var string */
38
-	private $password;
37
+    /** @var string */
38
+    private $password;
39 39
 
40
-	/**
41
-	 * @param string $uid
42
-	 * @param string $loginName
43
-	 * @param string $password
44
-	 */
45
-	public function __construct($uid, $loginName, $password) {
46
-		$this->uid = $uid;
47
-		$this->loginName = $loginName;
48
-		$this->password = $password;
49
-	}
40
+    /**
41
+     * @param string $uid
42
+     * @param string $loginName
43
+     * @param string $password
44
+     */
45
+    public function __construct($uid, $loginName, $password) {
46
+        $this->uid = $uid;
47
+        $this->loginName = $loginName;
48
+        $this->password = $password;
49
+    }
50 50
 
51
-	/**
52
-	 * @return string
53
-	 */
54
-	public function getUID() {
55
-		return $this->uid;
56
-	}
51
+    /**
52
+     * @return string
53
+     */
54
+    public function getUID() {
55
+        return $this->uid;
56
+    }
57 57
 
58
-	/**
59
-	 * @return string
60
-	 */
61
-	public function getLoginName() {
62
-		return $this->loginName;
63
-	}
58
+    /**
59
+     * @return string
60
+     */
61
+    public function getLoginName() {
62
+        return $this->loginName;
63
+    }
64 64
 
65
-	/**
66
-	 * @return string
67
-	 */
68
-	public function getPassword() {
69
-		return $this->password;
70
-	}
65
+    /**
66
+     * @return string
67
+     */
68
+    public function getPassword() {
69
+        return $this->password;
70
+    }
71 71
 
72 72
 }
Please login to merge, or discard this patch.
lib/private/Authentication/LoginCredentials/Store.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -37,84 +37,84 @@
 block discarded – undo
37 37
 
38 38
 class Store implements IStore {
39 39
 
40
-	/** @var ISession */
41
-	private $session;
42
-
43
-	/** @var ILogger */
44
-	private $logger;
45
-
46
-	/** @var IProvider|null */
47
-	private $tokenProvider;
48
-
49
-	/**
50
-	 * @param ISession $session
51
-	 * @param ILogger $logger
52
-	 * @param IProvider $tokenProvider
53
-	 */
54
-	public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) {
55
-		$this->session = $session;
56
-		$this->logger = $logger;
57
-		$this->tokenProvider = $tokenProvider;
58
-
59
-		Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
60
-	}
61
-
62
-	/**
63
-	 * Hook listener on post login
64
-	 *
65
-	 * @param array $params
66
-	 */
67
-	public function authenticate(array $params) {
68
-		$this->session->set('login_credentials', json_encode($params));
69
-	}
70
-
71
-	/**
72
-	 * Replace the session implementation
73
-	 *
74
-	 * @param ISession $session
75
-	 */
76
-	public function setSession(ISession $session) {
77
-		$this->session = $session;
78
-	}
79
-
80
-	/**
81
-	 * @since 12
82
-	 *
83
-	 * @return ICredentials the login credentials of the current user
84
-	 * @throws CredentialsUnavailableException
85
-	 */
86
-	public function getLoginCredentials() {
87
-		if (is_null($this->tokenProvider)) {
88
-			throw new CredentialsUnavailableException();
89
-		}
90
-
91
-		$trySession = false;
92
-		try {
93
-			$sessionId = $this->session->getId();
94
-			$token = $this->tokenProvider->getToken($sessionId);
95
-
96
-			$uid = $token->getUID();
97
-			$user = $token->getLoginName();
98
-			$password = $this->tokenProvider->getPassword($token, $sessionId);
99
-
100
-			return new Credentials($uid, $user, $password);
101
-		} catch (SessionNotAvailableException $ex) {
102
-			$this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core']);
103
-		} catch (InvalidTokenException $ex) {
104
-			$this->logger->debug('could not get login credentials because the token is invalid', ['app' => 'core']);
105
-			$trySession = true;
106
-		} catch (PasswordlessTokenException $ex) {
107
-			$this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core']);
108
-			$trySession = true;
109
-		}
110
-
111
-		if ($trySession && $this->session->exists('login_credentials')) {
112
-			$creds = json_decode($this->session->get('login_credentials'));
113
-			return new Credentials($creds->uid, $creds->uid, $creds->password);
114
-		}
115
-
116
-		// If we reach this line, an exception was thrown.
117
-		throw new CredentialsUnavailableException();
118
-	}
40
+    /** @var ISession */
41
+    private $session;
42
+
43
+    /** @var ILogger */
44
+    private $logger;
45
+
46
+    /** @var IProvider|null */
47
+    private $tokenProvider;
48
+
49
+    /**
50
+     * @param ISession $session
51
+     * @param ILogger $logger
52
+     * @param IProvider $tokenProvider
53
+     */
54
+    public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) {
55
+        $this->session = $session;
56
+        $this->logger = $logger;
57
+        $this->tokenProvider = $tokenProvider;
58
+
59
+        Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
60
+    }
61
+
62
+    /**
63
+     * Hook listener on post login
64
+     *
65
+     * @param array $params
66
+     */
67
+    public function authenticate(array $params) {
68
+        $this->session->set('login_credentials', json_encode($params));
69
+    }
70
+
71
+    /**
72
+     * Replace the session implementation
73
+     *
74
+     * @param ISession $session
75
+     */
76
+    public function setSession(ISession $session) {
77
+        $this->session = $session;
78
+    }
79
+
80
+    /**
81
+     * @since 12
82
+     *
83
+     * @return ICredentials the login credentials of the current user
84
+     * @throws CredentialsUnavailableException
85
+     */
86
+    public function getLoginCredentials() {
87
+        if (is_null($this->tokenProvider)) {
88
+            throw new CredentialsUnavailableException();
89
+        }
90
+
91
+        $trySession = false;
92
+        try {
93
+            $sessionId = $this->session->getId();
94
+            $token = $this->tokenProvider->getToken($sessionId);
95
+
96
+            $uid = $token->getUID();
97
+            $user = $token->getLoginName();
98
+            $password = $this->tokenProvider->getPassword($token, $sessionId);
99
+
100
+            return new Credentials($uid, $user, $password);
101
+        } catch (SessionNotAvailableException $ex) {
102
+            $this->logger->debug('could not get login credentials because session is unavailable', ['app' => 'core']);
103
+        } catch (InvalidTokenException $ex) {
104
+            $this->logger->debug('could not get login credentials because the token is invalid', ['app' => 'core']);
105
+            $trySession = true;
106
+        } catch (PasswordlessTokenException $ex) {
107
+            $this->logger->debug('could not get login credentials because the token has no password', ['app' => 'core']);
108
+            $trySession = true;
109
+        }
110
+
111
+        if ($trySession && $this->session->exists('login_credentials')) {
112
+            $creds = json_decode($this->session->get('login_credentials'));
113
+            return new Credentials($creds->uid, $creds->uid, $creds->password);
114
+        }
115
+
116
+        // If we reach this line, an exception was thrown.
117
+        throw new CredentialsUnavailableException();
118
+    }
119 119
 
120 120
 }
Please login to merge, or discard this patch.
lib/private/Authentication/TwoFactorAuth/Manager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@
 block discarded – undo
159 159
 			}
160 160
 		}
161 161
 
162
-		return array_filter($providers, function ($provider) use ($user) {
162
+		return array_filter($providers, function($provider) use ($user) {
163 163
 			/* @var $provider IProvider */
164 164
 			return $provider->isTwoFactorAuthEnabledForUser($user);
165 165
 		});
Please login to merge, or discard this patch.
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -46,310 +46,310 @@
 block discarded – undo
46 46
 
47 47
 class Manager {
48 48
 
49
-	const SESSION_UID_KEY = 'two_factor_auth_uid';
50
-	const SESSION_UID_DONE = 'two_factor_auth_passed';
51
-	const BACKUP_CODES_APP_ID = 'twofactor_backupcodes';
52
-	const BACKUP_CODES_PROVIDER_ID = 'backup_codes';
53
-	const REMEMBER_LOGIN = 'two_factor_remember_login';
54
-
55
-	/** @var AppManager */
56
-	private $appManager;
57
-
58
-	/** @var ISession */
59
-	private $session;
60
-
61
-	/** @var IConfig */
62
-	private $config;
63
-
64
-	/** @var IManager */
65
-	private $activityManager;
66
-
67
-	/** @var ILogger */
68
-	private $logger;
69
-
70
-	/** @var TokenProvider */
71
-	private $tokenProvider;
72
-
73
-	/** @var ITimeFactory */
74
-	private $timeFactory;
75
-
76
-	/** @var EventDispatcherInterface */
77
-	private $dispatcher;
78
-
79
-	/**
80
-	 * @param AppManager $appManager
81
-	 * @param ISession $session
82
-	 * @param IConfig $config
83
-	 * @param IManager $activityManager
84
-	 * @param ILogger $logger
85
-	 * @param TokenProvider $tokenProvider
86
-	 * @param ITimeFactory $timeFactory
87
-	 * @param EventDispatcherInterface $eventDispatcher
88
-	 */
89
-	public function __construct(AppManager $appManager,
90
-								ISession $session,
91
-								IConfig $config,
92
-								IManager $activityManager,
93
-								ILogger $logger,
94
-								TokenProvider $tokenProvider,
95
-								ITimeFactory $timeFactory,
96
-								EventDispatcherInterface $eventDispatcher) {
97
-		$this->appManager = $appManager;
98
-		$this->session = $session;
99
-		$this->config = $config;
100
-		$this->activityManager = $activityManager;
101
-		$this->logger = $logger;
102
-		$this->tokenProvider = $tokenProvider;
103
-		$this->timeFactory = $timeFactory;
104
-		$this->dispatcher = $eventDispatcher;
105
-	}
106
-
107
-	/**
108
-	 * Determine whether the user must provide a second factor challenge
109
-	 *
110
-	 * @param IUser $user
111
-	 * @return boolean
112
-	 */
113
-	public function isTwoFactorAuthenticated(IUser $user): bool {
114
-		$twoFactorEnabled = ((int) $this->config->getUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 0)) === 0;
115
-		return $twoFactorEnabled && \count($this->getProviders($user)) > 0;
116
-	}
117
-
118
-	/**
119
-	 * Disable 2FA checks for the given user
120
-	 *
121
-	 * @param IUser $user
122
-	 */
123
-	public function disableTwoFactorAuthentication(IUser $user) {
124
-		$this->config->setUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 1);
125
-	}
126
-
127
-	/**
128
-	 * Enable all 2FA checks for the given user
129
-	 *
130
-	 * @param IUser $user
131
-	 */
132
-	public function enableTwoFactorAuthentication(IUser $user) {
133
-		$this->config->deleteUserValue($user->getUID(), 'core', 'two_factor_auth_disabled');
134
-	}
135
-
136
-	/**
137
-	 * Get a 2FA provider by its ID
138
-	 *
139
-	 * @param IUser $user
140
-	 * @param string $challengeProviderId
141
-	 * @return IProvider|null
142
-	 */
143
-	public function getProvider(IUser $user, string $challengeProviderId) {
144
-		$providers = $this->getProviders($user, true);
145
-		return $providers[$challengeProviderId] ?? null;
146
-	}
147
-
148
-	/**
149
-	 * @param IUser $user
150
-	 * @return IProvider|null the backup provider, if enabled for the given user
151
-	 */
152
-	public function getBackupProvider(IUser $user) {
153
-		$providers = $this->getProviders($user, true);
154
-		if (!isset($providers[self::BACKUP_CODES_PROVIDER_ID])) {
155
-			return null;
156
-		}
157
-		return $providers[self::BACKUP_CODES_PROVIDER_ID];
158
-	}
159
-
160
-	/**
161
-	 * Get the list of 2FA providers for the given user
162
-	 *
163
-	 * @param IUser $user
164
-	 * @param bool $includeBackupApp
165
-	 * @return IProvider[]
166
-	 * @throws Exception
167
-	 */
168
-	public function getProviders(IUser $user, bool $includeBackupApp = false): array {
169
-		$allApps = $this->appManager->getEnabledAppsForUser($user);
170
-		$providers = [];
171
-
172
-		foreach ($allApps as $appId) {
173
-			if (!$includeBackupApp && $appId === self::BACKUP_CODES_APP_ID) {
174
-				continue;
175
-			}
176
-
177
-			$info = $this->appManager->getAppInfo($appId);
178
-			if (isset($info['two-factor-providers'])) {
179
-				/** @var string[] $providerClasses */
180
-				$providerClasses = $info['two-factor-providers'];
181
-				foreach ($providerClasses as $class) {
182
-					try {
183
-						$this->loadTwoFactorApp($appId);
184
-						$provider = OC::$server->query($class);
185
-						$providers[$provider->getId()] = $provider;
186
-					} catch (QueryException $exc) {
187
-						// Provider class can not be resolved
188
-						throw new Exception("Could not load two-factor auth provider $class");
189
-					}
190
-				}
191
-			}
192
-		}
193
-
194
-		return array_filter($providers, function ($provider) use ($user) {
195
-			/* @var $provider IProvider */
196
-			return $provider->isTwoFactorAuthEnabledForUser($user);
197
-		});
198
-	}
199
-
200
-	/**
201
-	 * Load an app by ID if it has not been loaded yet
202
-	 *
203
-	 * @param string $appId
204
-	 */
205
-	protected function loadTwoFactorApp(string $appId) {
206
-		if (!OC_App::isAppLoaded($appId)) {
207
-			OC_App::loadApp($appId);
208
-		}
209
-	}
210
-
211
-	/**
212
-	 * Verify the given challenge
213
-	 *
214
-	 * @param string $providerId
215
-	 * @param IUser $user
216
-	 * @param string $challenge
217
-	 * @return boolean
218
-	 */
219
-	public function verifyChallenge(string $providerId, IUser $user, string $challenge): bool {
220
-		$provider = $this->getProvider($user, $providerId);
221
-		if ($provider === null) {
222
-			return false;
223
-		}
224
-
225
-		$passed = $provider->verifyChallenge($user, $challenge);
226
-		if ($passed) {
227
-			if ($this->session->get(self::REMEMBER_LOGIN) === true) {
228
-				// TODO: resolve cyclic dependency and use DI
229
-				\OC::$server->getUserSession()->createRememberMeToken($user);
230
-			}
231
-			$this->session->remove(self::SESSION_UID_KEY);
232
-			$this->session->remove(self::REMEMBER_LOGIN);
233
-			$this->session->set(self::SESSION_UID_DONE, $user->getUID());
234
-
235
-			// Clear token from db
236
-			$sessionId = $this->session->getId();
237
-			$token = $this->tokenProvider->getToken($sessionId);
238
-			$tokenId = $token->getId();
239
-			$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId);
240
-
241
-			$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
242
-			$this->dispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
243
-
244
-			$this->publishEvent($user, 'twofactor_success', [
245
-				'provider' => $provider->getDisplayName(),
246
-			]);
247
-		} else {
248
-			$dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
249
-			$this->dispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent);
250
-
251
-			$this->publishEvent($user, 'twofactor_failed', [
252
-				'provider' => $provider->getDisplayName(),
253
-			]);
254
-		}
255
-		return $passed;
256
-	}
257
-
258
-	/**
259
-	 * Push a 2fa event the user's activity stream
260
-	 *
261
-	 * @param IUser $user
262
-	 * @param string $event
263
-	 * @param array $params
264
-	 */
265
-	private function publishEvent(IUser $user, string $event, array $params) {
266
-		$activity = $this->activityManager->generateEvent();
267
-		$activity->setApp('core')
268
-			->setType('security')
269
-			->setAuthor($user->getUID())
270
-			->setAffectedUser($user->getUID())
271
-			->setSubject($event, $params);
272
-		try {
273
-			$this->activityManager->publish($activity);
274
-		} catch (BadMethodCallException $e) {
275
-			$this->logger->warning('could not publish backup code creation activity', ['app' => 'core']);
276
-			$this->logger->logException($e, ['app' => 'core']);
277
-		}
278
-	}
279
-
280
-	/**
281
-	 * Check if the currently logged in user needs to pass 2FA
282
-	 *
283
-	 * @param IUser $user the currently logged in user
284
-	 * @return boolean
285
-	 */
286
-	public function needsSecondFactor(IUser $user = null): bool {
287
-		if ($user === null) {
288
-			return false;
289
-		}
290
-
291
-		// If we are authenticated using an app password skip all this
292
-		if ($this->session->exists('app_password')) {
293
-			return false;
294
-		}
295
-
296
-		// First check if the session tells us we should do 2FA (99% case)
297
-		if (!$this->session->exists(self::SESSION_UID_KEY)) {
298
-
299
-			// Check if the session tells us it is 2FA authenticated already
300
-			if ($this->session->exists(self::SESSION_UID_DONE) &&
301
-				$this->session->get(self::SESSION_UID_DONE) === $user->getUID()) {
302
-				return false;
303
-			}
304
-
305
-			/*
49
+    const SESSION_UID_KEY = 'two_factor_auth_uid';
50
+    const SESSION_UID_DONE = 'two_factor_auth_passed';
51
+    const BACKUP_CODES_APP_ID = 'twofactor_backupcodes';
52
+    const BACKUP_CODES_PROVIDER_ID = 'backup_codes';
53
+    const REMEMBER_LOGIN = 'two_factor_remember_login';
54
+
55
+    /** @var AppManager */
56
+    private $appManager;
57
+
58
+    /** @var ISession */
59
+    private $session;
60
+
61
+    /** @var IConfig */
62
+    private $config;
63
+
64
+    /** @var IManager */
65
+    private $activityManager;
66
+
67
+    /** @var ILogger */
68
+    private $logger;
69
+
70
+    /** @var TokenProvider */
71
+    private $tokenProvider;
72
+
73
+    /** @var ITimeFactory */
74
+    private $timeFactory;
75
+
76
+    /** @var EventDispatcherInterface */
77
+    private $dispatcher;
78
+
79
+    /**
80
+     * @param AppManager $appManager
81
+     * @param ISession $session
82
+     * @param IConfig $config
83
+     * @param IManager $activityManager
84
+     * @param ILogger $logger
85
+     * @param TokenProvider $tokenProvider
86
+     * @param ITimeFactory $timeFactory
87
+     * @param EventDispatcherInterface $eventDispatcher
88
+     */
89
+    public function __construct(AppManager $appManager,
90
+                                ISession $session,
91
+                                IConfig $config,
92
+                                IManager $activityManager,
93
+                                ILogger $logger,
94
+                                TokenProvider $tokenProvider,
95
+                                ITimeFactory $timeFactory,
96
+                                EventDispatcherInterface $eventDispatcher) {
97
+        $this->appManager = $appManager;
98
+        $this->session = $session;
99
+        $this->config = $config;
100
+        $this->activityManager = $activityManager;
101
+        $this->logger = $logger;
102
+        $this->tokenProvider = $tokenProvider;
103
+        $this->timeFactory = $timeFactory;
104
+        $this->dispatcher = $eventDispatcher;
105
+    }
106
+
107
+    /**
108
+     * Determine whether the user must provide a second factor challenge
109
+     *
110
+     * @param IUser $user
111
+     * @return boolean
112
+     */
113
+    public function isTwoFactorAuthenticated(IUser $user): bool {
114
+        $twoFactorEnabled = ((int) $this->config->getUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 0)) === 0;
115
+        return $twoFactorEnabled && \count($this->getProviders($user)) > 0;
116
+    }
117
+
118
+    /**
119
+     * Disable 2FA checks for the given user
120
+     *
121
+     * @param IUser $user
122
+     */
123
+    public function disableTwoFactorAuthentication(IUser $user) {
124
+        $this->config->setUserValue($user->getUID(), 'core', 'two_factor_auth_disabled', 1);
125
+    }
126
+
127
+    /**
128
+     * Enable all 2FA checks for the given user
129
+     *
130
+     * @param IUser $user
131
+     */
132
+    public function enableTwoFactorAuthentication(IUser $user) {
133
+        $this->config->deleteUserValue($user->getUID(), 'core', 'two_factor_auth_disabled');
134
+    }
135
+
136
+    /**
137
+     * Get a 2FA provider by its ID
138
+     *
139
+     * @param IUser $user
140
+     * @param string $challengeProviderId
141
+     * @return IProvider|null
142
+     */
143
+    public function getProvider(IUser $user, string $challengeProviderId) {
144
+        $providers = $this->getProviders($user, true);
145
+        return $providers[$challengeProviderId] ?? null;
146
+    }
147
+
148
+    /**
149
+     * @param IUser $user
150
+     * @return IProvider|null the backup provider, if enabled for the given user
151
+     */
152
+    public function getBackupProvider(IUser $user) {
153
+        $providers = $this->getProviders($user, true);
154
+        if (!isset($providers[self::BACKUP_CODES_PROVIDER_ID])) {
155
+            return null;
156
+        }
157
+        return $providers[self::BACKUP_CODES_PROVIDER_ID];
158
+    }
159
+
160
+    /**
161
+     * Get the list of 2FA providers for the given user
162
+     *
163
+     * @param IUser $user
164
+     * @param bool $includeBackupApp
165
+     * @return IProvider[]
166
+     * @throws Exception
167
+     */
168
+    public function getProviders(IUser $user, bool $includeBackupApp = false): array {
169
+        $allApps = $this->appManager->getEnabledAppsForUser($user);
170
+        $providers = [];
171
+
172
+        foreach ($allApps as $appId) {
173
+            if (!$includeBackupApp && $appId === self::BACKUP_CODES_APP_ID) {
174
+                continue;
175
+            }
176
+
177
+            $info = $this->appManager->getAppInfo($appId);
178
+            if (isset($info['two-factor-providers'])) {
179
+                /** @var string[] $providerClasses */
180
+                $providerClasses = $info['two-factor-providers'];
181
+                foreach ($providerClasses as $class) {
182
+                    try {
183
+                        $this->loadTwoFactorApp($appId);
184
+                        $provider = OC::$server->query($class);
185
+                        $providers[$provider->getId()] = $provider;
186
+                    } catch (QueryException $exc) {
187
+                        // Provider class can not be resolved
188
+                        throw new Exception("Could not load two-factor auth provider $class");
189
+                    }
190
+                }
191
+            }
192
+        }
193
+
194
+        return array_filter($providers, function ($provider) use ($user) {
195
+            /* @var $provider IProvider */
196
+            return $provider->isTwoFactorAuthEnabledForUser($user);
197
+        });
198
+    }
199
+
200
+    /**
201
+     * Load an app by ID if it has not been loaded yet
202
+     *
203
+     * @param string $appId
204
+     */
205
+    protected function loadTwoFactorApp(string $appId) {
206
+        if (!OC_App::isAppLoaded($appId)) {
207
+            OC_App::loadApp($appId);
208
+        }
209
+    }
210
+
211
+    /**
212
+     * Verify the given challenge
213
+     *
214
+     * @param string $providerId
215
+     * @param IUser $user
216
+     * @param string $challenge
217
+     * @return boolean
218
+     */
219
+    public function verifyChallenge(string $providerId, IUser $user, string $challenge): bool {
220
+        $provider = $this->getProvider($user, $providerId);
221
+        if ($provider === null) {
222
+            return false;
223
+        }
224
+
225
+        $passed = $provider->verifyChallenge($user, $challenge);
226
+        if ($passed) {
227
+            if ($this->session->get(self::REMEMBER_LOGIN) === true) {
228
+                // TODO: resolve cyclic dependency and use DI
229
+                \OC::$server->getUserSession()->createRememberMeToken($user);
230
+            }
231
+            $this->session->remove(self::SESSION_UID_KEY);
232
+            $this->session->remove(self::REMEMBER_LOGIN);
233
+            $this->session->set(self::SESSION_UID_DONE, $user->getUID());
234
+
235
+            // Clear token from db
236
+            $sessionId = $this->session->getId();
237
+            $token = $this->tokenProvider->getToken($sessionId);
238
+            $tokenId = $token->getId();
239
+            $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $tokenId);
240
+
241
+            $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
242
+            $this->dispatcher->dispatch(IProvider::EVENT_SUCCESS, $dispatchEvent);
243
+
244
+            $this->publishEvent($user, 'twofactor_success', [
245
+                'provider' => $provider->getDisplayName(),
246
+            ]);
247
+        } else {
248
+            $dispatchEvent = new GenericEvent($user, ['provider' => $provider->getDisplayName()]);
249
+            $this->dispatcher->dispatch(IProvider::EVENT_FAILED, $dispatchEvent);
250
+
251
+            $this->publishEvent($user, 'twofactor_failed', [
252
+                'provider' => $provider->getDisplayName(),
253
+            ]);
254
+        }
255
+        return $passed;
256
+    }
257
+
258
+    /**
259
+     * Push a 2fa event the user's activity stream
260
+     *
261
+     * @param IUser $user
262
+     * @param string $event
263
+     * @param array $params
264
+     */
265
+    private function publishEvent(IUser $user, string $event, array $params) {
266
+        $activity = $this->activityManager->generateEvent();
267
+        $activity->setApp('core')
268
+            ->setType('security')
269
+            ->setAuthor($user->getUID())
270
+            ->setAffectedUser($user->getUID())
271
+            ->setSubject($event, $params);
272
+        try {
273
+            $this->activityManager->publish($activity);
274
+        } catch (BadMethodCallException $e) {
275
+            $this->logger->warning('could not publish backup code creation activity', ['app' => 'core']);
276
+            $this->logger->logException($e, ['app' => 'core']);
277
+        }
278
+    }
279
+
280
+    /**
281
+     * Check if the currently logged in user needs to pass 2FA
282
+     *
283
+     * @param IUser $user the currently logged in user
284
+     * @return boolean
285
+     */
286
+    public function needsSecondFactor(IUser $user = null): bool {
287
+        if ($user === null) {
288
+            return false;
289
+        }
290
+
291
+        // If we are authenticated using an app password skip all this
292
+        if ($this->session->exists('app_password')) {
293
+            return false;
294
+        }
295
+
296
+        // First check if the session tells us we should do 2FA (99% case)
297
+        if (!$this->session->exists(self::SESSION_UID_KEY)) {
298
+
299
+            // Check if the session tells us it is 2FA authenticated already
300
+            if ($this->session->exists(self::SESSION_UID_DONE) &&
301
+                $this->session->get(self::SESSION_UID_DONE) === $user->getUID()) {
302
+                return false;
303
+            }
304
+
305
+            /*
306 306
 			 * If the session is expired check if we are not logged in by a token
307 307
 			 * that still needs 2FA auth
308 308
 			 */
309
-			try {
310
-				$sessionId = $this->session->getId();
311
-				$token = $this->tokenProvider->getToken($sessionId);
312
-				$tokenId = $token->getId();
313
-				$tokensNeeding2FA = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
314
-
315
-				if (!\in_array($tokenId, $tokensNeeding2FA, true)) {
316
-					$this->session->set(self::SESSION_UID_DONE, $user->getUID());
317
-					return false;
318
-				}
319
-			} catch (InvalidTokenException $e) {
320
-			}
321
-		}
322
-
323
-		if (!$this->isTwoFactorAuthenticated($user)) {
324
-			// There is no second factor any more -> let the user pass
325
-			//   This prevents infinite redirect loops when a user is about
326
-			//   to solve the 2FA challenge, and the provider app is
327
-			//   disabled the same time
328
-			$this->session->remove(self::SESSION_UID_KEY);
329
-
330
-			$keys = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
331
-			foreach ($keys as $key) {
332
-				$this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $key);
333
-			}
334
-			return false;
335
-		}
336
-
337
-		return true;
338
-	}
339
-
340
-	/**
341
-	 * Prepare the 2FA login
342
-	 *
343
-	 * @param IUser $user
344
-	 * @param boolean $rememberMe
345
-	 */
346
-	public function prepareTwoFactorLogin(IUser $user, bool $rememberMe) {
347
-		$this->session->set(self::SESSION_UID_KEY, $user->getUID());
348
-		$this->session->set(self::REMEMBER_LOGIN, $rememberMe);
349
-
350
-		$id = $this->session->getId();
351
-		$token = $this->tokenProvider->getToken($id);
352
-		$this->config->setUserValue($user->getUID(), 'login_token_2fa', $token->getId(), $this->timeFactory->getTime());
353
-	}
309
+            try {
310
+                $sessionId = $this->session->getId();
311
+                $token = $this->tokenProvider->getToken($sessionId);
312
+                $tokenId = $token->getId();
313
+                $tokensNeeding2FA = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
314
+
315
+                if (!\in_array($tokenId, $tokensNeeding2FA, true)) {
316
+                    $this->session->set(self::SESSION_UID_DONE, $user->getUID());
317
+                    return false;
318
+                }
319
+            } catch (InvalidTokenException $e) {
320
+            }
321
+        }
322
+
323
+        if (!$this->isTwoFactorAuthenticated($user)) {
324
+            // There is no second factor any more -> let the user pass
325
+            //   This prevents infinite redirect loops when a user is about
326
+            //   to solve the 2FA challenge, and the provider app is
327
+            //   disabled the same time
328
+            $this->session->remove(self::SESSION_UID_KEY);
329
+
330
+            $keys = $this->config->getUserKeys($user->getUID(), 'login_token_2fa');
331
+            foreach ($keys as $key) {
332
+                $this->config->deleteUserValue($user->getUID(), 'login_token_2fa', $key);
333
+            }
334
+            return false;
335
+        }
336
+
337
+        return true;
338
+    }
339
+
340
+    /**
341
+     * Prepare the 2FA login
342
+     *
343
+     * @param IUser $user
344
+     * @param boolean $rememberMe
345
+     */
346
+    public function prepareTwoFactorLogin(IUser $user, bool $rememberMe) {
347
+        $this->session->set(self::SESSION_UID_KEY, $user->getUID());
348
+        $this->session->set(self::REMEMBER_LOGIN, $rememberMe);
349
+
350
+        $id = $this->session->getId();
351
+        $token = $this->tokenProvider->getToken($id);
352
+        $this->config->setUserValue($user->getUID(), 'login_token_2fa', $token->getId(), $this->timeFactory->getTime());
353
+    }
354 354
 
355 355
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Token/DefaultTokenMapper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
 		$data = $result->fetchAll();
130 130
 		$result->closeCursor();
131 131
 
132
-		$entities = array_map(function ($row) {
132
+		$entities = array_map(function($row) {
133 133
 			return DefaultToken::fromRow($row);
134 134
 		}, $data);
135 135
 
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -37,134 +37,134 @@
 block discarded – undo
37 37
 
38 38
 class DefaultTokenMapper extends QBMapper {
39 39
 
40
-	public function __construct(IDBConnection $db) {
41
-		parent::__construct($db, 'authtoken');
42
-	}
43
-
44
-	/**
45
-	 * Invalidate (delete) a given token
46
-	 *
47
-	 * @param string $token
48
-	 */
49
-	public function invalidate(string $token) {
50
-		/* @var $qb IQueryBuilder */
51
-		$qb = $this->db->getQueryBuilder();
52
-		$qb->delete('authtoken')
53
-			->where($qb->expr()->eq('token', $qb->createParameter('token')))
54
-			->setParameter('token', $token)
55
-			->execute();
56
-	}
57
-
58
-	/**
59
-	 * @param int $olderThan
60
-	 * @param int $remember
61
-	 */
62
-	public function invalidateOld(int $olderThan, int $remember = IToken::DO_NOT_REMEMBER) {
63
-		/* @var $qb IQueryBuilder */
64
-		$qb = $this->db->getQueryBuilder();
65
-		$qb->delete('authtoken')
66
-			->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT)))
67
-			->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT)))
68
-			->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT)))
69
-			->execute();
70
-	}
71
-
72
-	/**
73
-	 * Get the user UID for the given token
74
-	 *
75
-	 * @param string $token
76
-	 * @throws DoesNotExistException
77
-	 * @return DefaultToken
78
-	 */
79
-	public function getToken(string $token): DefaultToken {
80
-		/* @var $qb IQueryBuilder */
81
-		$qb = $this->db->getQueryBuilder();
82
-		$result = $qb->select('*')
83
-			->from('authtoken')
84
-			->where($qb->expr()->eq('token', $qb->createNamedParameter($token)))
85
-			->execute();
86
-
87
-		$data = $result->fetch();
88
-		$result->closeCursor();
89
-		if ($data === false) {
90
-			throw new DoesNotExistException('token does not exist');
91
-		}
92
-		return DefaultToken::fromRow($data);
93
-	}
94
-
95
-	/**
96
-	 * Get the token for $id
97
-	 *
98
-	 * @param int $id
99
-	 * @throws DoesNotExistException
100
-	 * @return DefaultToken
101
-	 */
102
-	public function getTokenById(int $id): DefaultToken {
103
-		/* @var $qb IQueryBuilder */
104
-		$qb = $this->db->getQueryBuilder();
105
-		$result = $qb->select('*')
106
-			->from('authtoken')
107
-			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
108
-			->execute();
109
-
110
-		$data = $result->fetch();
111
-		$result->closeCursor();
112
-		if ($data === false) {
113
-			throw new DoesNotExistException('token does not exist');
114
-		}
115
-		return DefaultToken::fromRow($data);
116
-	}
117
-
118
-	/**
119
-	 * Get all tokens of a user
120
-	 *
121
-	 * The provider may limit the number of result rows in case of an abuse
122
-	 * where a high number of (session) tokens is generated
123
-	 *
124
-	 * @param IUser $user
125
-	 * @return DefaultToken[]
126
-	 */
127
-	public function getTokenByUser(IUser $user): array {
128
-		/* @var $qb IQueryBuilder */
129
-		$qb = $this->db->getQueryBuilder();
130
-		$qb->select('*')
131
-			->from('authtoken')
132
-			->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
133
-			->setMaxResults(1000);
134
-		$result = $qb->execute();
135
-		$data = $result->fetchAll();
136
-		$result->closeCursor();
137
-
138
-		$entities = array_map(function ($row) {
139
-			return DefaultToken::fromRow($row);
140
-		}, $data);
141
-
142
-		return $entities;
143
-	}
144
-
145
-	/**
146
-	 * @param IUser $user
147
-	 * @param int $id
148
-	 */
149
-	public function deleteById(IUser $user, int $id) {
150
-		/* @var $qb IQueryBuilder */
151
-		$qb = $this->db->getQueryBuilder();
152
-		$qb->delete('authtoken')
153
-			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
154
-			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())));
155
-		$qb->execute();
156
-	}
157
-
158
-	/**
159
-	 * delete all auth token which belong to a specific client if the client was deleted
160
-	 *
161
-	 * @param string $name
162
-	 */
163
-	public function deleteByName(string $name) {
164
-		$qb = $this->db->getQueryBuilder();
165
-		$qb->delete('authtoken')
166
-			->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR));
167
-		$qb->execute();
168
-	}
40
+    public function __construct(IDBConnection $db) {
41
+        parent::__construct($db, 'authtoken');
42
+    }
43
+
44
+    /**
45
+     * Invalidate (delete) a given token
46
+     *
47
+     * @param string $token
48
+     */
49
+    public function invalidate(string $token) {
50
+        /* @var $qb IQueryBuilder */
51
+        $qb = $this->db->getQueryBuilder();
52
+        $qb->delete('authtoken')
53
+            ->where($qb->expr()->eq('token', $qb->createParameter('token')))
54
+            ->setParameter('token', $token)
55
+            ->execute();
56
+    }
57
+
58
+    /**
59
+     * @param int $olderThan
60
+     * @param int $remember
61
+     */
62
+    public function invalidateOld(int $olderThan, int $remember = IToken::DO_NOT_REMEMBER) {
63
+        /* @var $qb IQueryBuilder */
64
+        $qb = $this->db->getQueryBuilder();
65
+        $qb->delete('authtoken')
66
+            ->where($qb->expr()->lt('last_activity', $qb->createNamedParameter($olderThan, IQueryBuilder::PARAM_INT)))
67
+            ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter(IToken::TEMPORARY_TOKEN, IQueryBuilder::PARAM_INT)))
68
+            ->andWhere($qb->expr()->eq('remember', $qb->createNamedParameter($remember, IQueryBuilder::PARAM_INT)))
69
+            ->execute();
70
+    }
71
+
72
+    /**
73
+     * Get the user UID for the given token
74
+     *
75
+     * @param string $token
76
+     * @throws DoesNotExistException
77
+     * @return DefaultToken
78
+     */
79
+    public function getToken(string $token): DefaultToken {
80
+        /* @var $qb IQueryBuilder */
81
+        $qb = $this->db->getQueryBuilder();
82
+        $result = $qb->select('*')
83
+            ->from('authtoken')
84
+            ->where($qb->expr()->eq('token', $qb->createNamedParameter($token)))
85
+            ->execute();
86
+
87
+        $data = $result->fetch();
88
+        $result->closeCursor();
89
+        if ($data === false) {
90
+            throw new DoesNotExistException('token does not exist');
91
+        }
92
+        return DefaultToken::fromRow($data);
93
+    }
94
+
95
+    /**
96
+     * Get the token for $id
97
+     *
98
+     * @param int $id
99
+     * @throws DoesNotExistException
100
+     * @return DefaultToken
101
+     */
102
+    public function getTokenById(int $id): DefaultToken {
103
+        /* @var $qb IQueryBuilder */
104
+        $qb = $this->db->getQueryBuilder();
105
+        $result = $qb->select('*')
106
+            ->from('authtoken')
107
+            ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
108
+            ->execute();
109
+
110
+        $data = $result->fetch();
111
+        $result->closeCursor();
112
+        if ($data === false) {
113
+            throw new DoesNotExistException('token does not exist');
114
+        }
115
+        return DefaultToken::fromRow($data);
116
+    }
117
+
118
+    /**
119
+     * Get all tokens of a user
120
+     *
121
+     * The provider may limit the number of result rows in case of an abuse
122
+     * where a high number of (session) tokens is generated
123
+     *
124
+     * @param IUser $user
125
+     * @return DefaultToken[]
126
+     */
127
+    public function getTokenByUser(IUser $user): array {
128
+        /* @var $qb IQueryBuilder */
129
+        $qb = $this->db->getQueryBuilder();
130
+        $qb->select('*')
131
+            ->from('authtoken')
132
+            ->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
133
+            ->setMaxResults(1000);
134
+        $result = $qb->execute();
135
+        $data = $result->fetchAll();
136
+        $result->closeCursor();
137
+
138
+        $entities = array_map(function ($row) {
139
+            return DefaultToken::fromRow($row);
140
+        }, $data);
141
+
142
+        return $entities;
143
+    }
144
+
145
+    /**
146
+     * @param IUser $user
147
+     * @param int $id
148
+     */
149
+    public function deleteById(IUser $user, int $id) {
150
+        /* @var $qb IQueryBuilder */
151
+        $qb = $this->db->getQueryBuilder();
152
+        $qb->delete('authtoken')
153
+            ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
154
+            ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())));
155
+        $qb->execute();
156
+    }
157
+
158
+    /**
159
+     * delete all auth token which belong to a specific client if the client was deleted
160
+     *
161
+     * @param string $name
162
+     */
163
+    public function deleteByName(string $name) {
164
+        $qb = $this->db->getQueryBuilder();
165
+        $qb->delete('authtoken')
166
+            ->where($qb->expr()->eq('name', $qb->createNamedParameter($name), IQueryBuilder::PARAM_STR));
167
+        $qb->execute();
168
+    }
169 169
 
170 170
 }
Please login to merge, or discard this patch.
lib/private/Console/TimestampFormatter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,6 +103,6 @@
 block discarded – undo
103 103
 		$time = new \DateTime('now', $timeZone);
104 104
 		$timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTime::ATOM));
105 105
 
106
-		return $timestampInfo . ' ' . $this->formatter->format($message);
106
+		return $timestampInfo.' '.$this->formatter->format($message);
107 107
 	}
108 108
 }
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -28,85 +28,85 @@
 block discarded – undo
28 28
 use Symfony\Component\Console\Formatter\OutputFormatterStyleInterface;
29 29
 
30 30
 class TimestampFormatter implements OutputFormatterInterface {
31
-	/** @var IConfig */
32
-	protected $config;
31
+    /** @var IConfig */
32
+    protected $config;
33 33
 
34
-	/** @var OutputFormatterInterface */
35
-	protected $formatter;
34
+    /** @var OutputFormatterInterface */
35
+    protected $formatter;
36 36
 
37
-	/**
38
-	 * @param IConfig $config
39
-	 * @param OutputFormatterInterface $formatter
40
-	 */
41
-	public function __construct(IConfig $config, OutputFormatterInterface $formatter) {
42
-		$this->config = $config;
43
-		$this->formatter = $formatter;
44
-	}
37
+    /**
38
+     * @param IConfig $config
39
+     * @param OutputFormatterInterface $formatter
40
+     */
41
+    public function __construct(IConfig $config, OutputFormatterInterface $formatter) {
42
+        $this->config = $config;
43
+        $this->formatter = $formatter;
44
+    }
45 45
 
46
-	/**
47
-	 * Sets the decorated flag.
48
-	 *
49
-	 * @param bool $decorated Whether to decorate the messages or not
50
-	 */
51
-	public function setDecorated($decorated) {
52
-		$this->formatter->setDecorated($decorated);
53
-	}
46
+    /**
47
+     * Sets the decorated flag.
48
+     *
49
+     * @param bool $decorated Whether to decorate the messages or not
50
+     */
51
+    public function setDecorated($decorated) {
52
+        $this->formatter->setDecorated($decorated);
53
+    }
54 54
 
55
-	/**
56
-	 * Gets the decorated flag.
57
-	 *
58
-	 * @return bool true if the output will decorate messages, false otherwise
59
-	 */
60
-	public function isDecorated() {
61
-		return $this->formatter->isDecorated();
62
-	}
55
+    /**
56
+     * Gets the decorated flag.
57
+     *
58
+     * @return bool true if the output will decorate messages, false otherwise
59
+     */
60
+    public function isDecorated() {
61
+        return $this->formatter->isDecorated();
62
+    }
63 63
 
64
-	/**
65
-	 * Sets a new style.
66
-	 *
67
-	 * @param string $name The style name
68
-	 * @param OutputFormatterStyleInterface $style The style instance
69
-	 */
70
-	public function setStyle($name, OutputFormatterStyleInterface $style) {
71
-		$this->formatter->setStyle($name, $style);
72
-	}
64
+    /**
65
+     * Sets a new style.
66
+     *
67
+     * @param string $name The style name
68
+     * @param OutputFormatterStyleInterface $style The style instance
69
+     */
70
+    public function setStyle($name, OutputFormatterStyleInterface $style) {
71
+        $this->formatter->setStyle($name, $style);
72
+    }
73 73
 
74
-	/**
75
-	 * Checks if output formatter has style with specified name.
76
-	 *
77
-	 * @param string $name
78
-	 * @return bool
79
-	 */
80
-	public function hasStyle($name) {
81
-		return $this->formatter->hasStyle($name);
82
-	}
74
+    /**
75
+     * Checks if output formatter has style with specified name.
76
+     *
77
+     * @param string $name
78
+     * @return bool
79
+     */
80
+    public function hasStyle($name) {
81
+        return $this->formatter->hasStyle($name);
82
+    }
83 83
 
84
-	/**
85
-	 * Gets style options from style with specified name.
86
-	 *
87
-	 * @param string $name
88
-	 * @return OutputFormatterStyleInterface
89
-	 * @throws \InvalidArgumentException When style isn't defined
90
-	 */
91
-	public function getStyle($name) {
92
-		return $this->formatter->getStyle($name);
93
-	}
84
+    /**
85
+     * Gets style options from style with specified name.
86
+     *
87
+     * @param string $name
88
+     * @return OutputFormatterStyleInterface
89
+     * @throws \InvalidArgumentException When style isn't defined
90
+     */
91
+    public function getStyle($name) {
92
+        return $this->formatter->getStyle($name);
93
+    }
94 94
 
95
-	/**
96
-	 * Formats a message according to the given styles.
97
-	 *
98
-	 * @param string $message The message to style
99
-	 * @return string The styled message, prepended with a timestamp using the
100
-	 * log timezone and dateformat, e.g. "2015-06-23T17:24:37+02:00"
101
-	 */
102
-	public function format($message) {
95
+    /**
96
+     * Formats a message according to the given styles.
97
+     *
98
+     * @param string $message The message to style
99
+     * @return string The styled message, prepended with a timestamp using the
100
+     * log timezone and dateformat, e.g. "2015-06-23T17:24:37+02:00"
101
+     */
102
+    public function format($message) {
103 103
 
104
-		$timeZone = $this->config->getSystemValue('logtimezone', 'UTC');
105
-		$timeZone = $timeZone !== null ? new \DateTimeZone($timeZone) : null;
104
+        $timeZone = $this->config->getSystemValue('logtimezone', 'UTC');
105
+        $timeZone = $timeZone !== null ? new \DateTimeZone($timeZone) : null;
106 106
 
107
-		$time = new \DateTime('now', $timeZone);
108
-		$timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTime::ATOM));
107
+        $time = new \DateTime('now', $timeZone);
108
+        $timestampInfo = $time->format($this->config->getSystemValue('logdateformat', \DateTime::ATOM));
109 109
 
110
-		return $timestampInfo . ' ' . $this->formatter->format($message);
111
-	}
110
+        return $timestampInfo . ' ' . $this->formatter->format($message);
111
+    }
112 112
 }
Please login to merge, or discard this patch.
lib/private/Activity/Event.php 2 patches
Indentation   +515 added lines, -515 removed lines patch added patch discarded remove patch
@@ -30,523 +30,523 @@
 block discarded – undo
30 30
 
31 31
 class Event implements IEvent {
32 32
 
33
-	/** @var string */
34
-	protected $app = '';
35
-	/** @var string */
36
-	protected $type = '';
37
-	/** @var string */
38
-	protected $affectedUser = '';
39
-	/** @var string */
40
-	protected $author = '';
41
-	/** @var int */
42
-	protected $timestamp = 0;
43
-	/** @var string */
44
-	protected $subject = '';
45
-	/** @var array */
46
-	protected $subjectParameters = [];
47
-	/** @var string */
48
-	protected $subjectParsed;
49
-	/** @var string */
50
-	protected $subjectRich;
51
-	/** @var array */
52
-	protected $subjectRichParameters;
53
-	/** @var string */
54
-	protected $message = '';
55
-	/** @var array */
56
-	protected $messageParameters = [];
57
-	/** @var string */
58
-	protected $messageParsed;
59
-	/** @var string */
60
-	protected $messageRich;
61
-	/** @var array */
62
-	protected $messageRichParameters;
63
-	/** @var string */
64
-	protected $objectType = '';
65
-	/** @var int */
66
-	protected $objectId = 0;
67
-	/** @var string */
68
-	protected $objectName = '';
69
-	/** @var string */
70
-	protected $link = '';
71
-	/** @var string */
72
-	protected $icon = '';
73
-
74
-	/** @var IEvent */
75
-	protected $child = null;
76
-	/** @var IValidator */
77
-	protected $richValidator;
78
-
79
-	/**
80
-	 * @param IValidator $richValidator
81
-	 */
82
-	public function __construct(IValidator $richValidator) {
83
-		$this->richValidator = $richValidator;
84
-	}
85
-
86
-	/**
87
-	 * Set the app of the activity
88
-	 *
89
-	 * @param string $app
90
-	 * @return IEvent
91
-	 * @throws \InvalidArgumentException if the app id is invalid
92
-	 * @since 8.2.0
93
-	 */
94
-	public function setApp($app) {
95
-		if (!is_string($app) || $app === '' || isset($app[32])) {
96
-			throw new \InvalidArgumentException('The given app is invalid');
97
-		}
98
-		$this->app = (string) $app;
99
-		return $this;
100
-	}
101
-
102
-	/**
103
-	 * @return string
104
-	 */
105
-	public function getApp() {
106
-		return $this->app;
107
-	}
108
-
109
-	/**
110
-	 * Set the type of the activity
111
-	 *
112
-	 * @param string $type
113
-	 * @return IEvent
114
-	 * @throws \InvalidArgumentException if the type is invalid
115
-	 * @since 8.2.0
116
-	 */
117
-	public function setType($type) {
118
-		if (!is_string($type) || $type === '' || isset($type[255])) {
119
-			throw new \InvalidArgumentException('The given type is invalid');
120
-		}
121
-		$this->type = (string) $type;
122
-		return $this;
123
-	}
124
-
125
-	/**
126
-	 * @return string
127
-	 */
128
-	public function getType() {
129
-		return $this->type;
130
-	}
131
-
132
-	/**
133
-	 * Set the affected user of the activity
134
-	 *
135
-	 * @param string $affectedUser
136
-	 * @return IEvent
137
-	 * @throws \InvalidArgumentException if the affected user is invalid
138
-	 * @since 8.2.0
139
-	 */
140
-	public function setAffectedUser($affectedUser) {
141
-		if (!is_string($affectedUser) || $affectedUser === '' || isset($affectedUser[64])) {
142
-			throw new \InvalidArgumentException('The given affected user is invalid');
143
-		}
144
-		$this->affectedUser = (string) $affectedUser;
145
-		return $this;
146
-	}
147
-
148
-	/**
149
-	 * @return string
150
-	 */
151
-	public function getAffectedUser() {
152
-		return $this->affectedUser;
153
-	}
154
-
155
-	/**
156
-	 * Set the author of the activity
157
-	 *
158
-	 * @param string $author
159
-	 * @return IEvent
160
-	 * @throws \InvalidArgumentException if the author is invalid
161
-	 * @since 8.2.0
162
-	 */
163
-	public function setAuthor($author) {
164
-		if (!is_string($author) || isset($author[64])) {
165
-			throw new \InvalidArgumentException('The given author user is invalid'. serialize($author));
166
-		}
167
-		$this->author = (string) $author;
168
-		return $this;
169
-	}
170
-
171
-	/**
172
-	 * @return string
173
-	 */
174
-	public function getAuthor() {
175
-		return $this->author;
176
-	}
177
-
178
-	/**
179
-	 * Set the timestamp of the activity
180
-	 *
181
-	 * @param int $timestamp
182
-	 * @return IEvent
183
-	 * @throws \InvalidArgumentException if the timestamp is invalid
184
-	 * @since 8.2.0
185
-	 */
186
-	public function setTimestamp($timestamp) {
187
-		if (!is_int($timestamp)) {
188
-			throw new \InvalidArgumentException('The given timestamp is invalid');
189
-		}
190
-		$this->timestamp = (int) $timestamp;
191
-		return $this;
192
-	}
193
-
194
-	/**
195
-	 * @return int
196
-	 */
197
-	public function getTimestamp() {
198
-		return $this->timestamp;
199
-	}
200
-
201
-	/**
202
-	 * Set the subject of the activity
203
-	 *
204
-	 * @param string $subject
205
-	 * @param array $parameters
206
-	 * @return IEvent
207
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
208
-	 * @since 8.2.0
209
-	 */
210
-	public function setSubject($subject, array $parameters = []) {
211
-		if (!is_string($subject) || isset($subject[255])) {
212
-			throw new \InvalidArgumentException('The given subject is invalid');
213
-		}
214
-		$this->subject = (string) $subject;
215
-		$this->subjectParameters = $parameters;
216
-		return $this;
217
-	}
218
-
219
-	/**
220
-	 * @return string
221
-	 */
222
-	public function getSubject() {
223
-		return $this->subject;
224
-	}
225
-
226
-	/**
227
-	 * @return array
228
-	 */
229
-	public function getSubjectParameters() {
230
-		return $this->subjectParameters;
231
-	}
232
-
233
-	/**
234
-	 * @param string $subject
235
-	 * @return $this
236
-	 * @throws \InvalidArgumentException if the subject is invalid
237
-	 * @since 11.0.0
238
-	 */
239
-	public function setParsedSubject($subject) {
240
-		if (!is_string($subject) || $subject === '') {
241
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
242
-		}
243
-		$this->subjectParsed = $subject;
244
-		return $this;
245
-	}
246
-
247
-	/**
248
-	 * @return string
249
-	 * @since 11.0.0
250
-	 */
251
-	public function getParsedSubject() {
252
-		return $this->subjectParsed;
253
-	}
254
-
255
-	/**
256
-	 * @param string $subject
257
-	 * @param array $parameters
258
-	 * @return $this
259
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
260
-	 * @since 11.0.0
261
-	 */
262
-	public function setRichSubject($subject, array $parameters = []) {
263
-		if (!is_string($subject) || $subject === '') {
264
-			throw new \InvalidArgumentException('The given parsed subject is invalid');
265
-		}
266
-		$this->subjectRich = $subject;
267
-
268
-		if (!is_array($parameters)) {
269
-			throw new \InvalidArgumentException('The given subject parameters are invalid');
270
-		}
271
-		$this->subjectRichParameters = $parameters;
272
-
273
-		return $this;
274
-	}
275
-
276
-	/**
277
-	 * @return string
278
-	 * @since 11.0.0
279
-	 */
280
-	public function getRichSubject() {
281
-		return $this->subjectRich;
282
-	}
283
-
284
-	/**
285
-	 * @return array[]
286
-	 * @since 11.0.0
287
-	 */
288
-	public function getRichSubjectParameters() {
289
-		return $this->subjectRichParameters;
290
-	}
291
-
292
-	/**
293
-	 * Set the message of the activity
294
-	 *
295
-	 * @param string $message
296
-	 * @param array $parameters
297
-	 * @return IEvent
298
-	 * @throws \InvalidArgumentException if the message or parameters are invalid
299
-	 * @since 8.2.0
300
-	 */
301
-	public function setMessage($message, array $parameters = []) {
302
-		if (!is_string($message) || isset($message[255])) {
303
-			throw new \InvalidArgumentException('The given message is invalid');
304
-		}
305
-		$this->message = (string) $message;
306
-		$this->messageParameters = $parameters;
307
-		return $this;
308
-	}
309
-
310
-	/**
311
-	 * @return string
312
-	 */
313
-	public function getMessage() {
314
-		return $this->message;
315
-	}
316
-
317
-	/**
318
-	 * @return array
319
-	 */
320
-	public function getMessageParameters() {
321
-		return $this->messageParameters;
322
-	}
323
-
324
-	/**
325
-	 * @param string $message
326
-	 * @return $this
327
-	 * @throws \InvalidArgumentException if the message is invalid
328
-	 * @since 11.0.0
329
-	 */
330
-	public function setParsedMessage($message) {
331
-		if (!is_string($message)) {
332
-			throw new \InvalidArgumentException('The given parsed message is invalid');
333
-		}
334
-		$this->messageParsed = $message;
335
-		return $this;
336
-	}
337
-
338
-	/**
339
-	 * @return string
340
-	 * @since 11.0.0
341
-	 */
342
-	public function getParsedMessage() {
343
-		return $this->messageParsed;
344
-	}
345
-
346
-	/**
347
-	 * @param string $message
348
-	 * @param array $parameters
349
-	 * @return $this
350
-	 * @throws \InvalidArgumentException if the subject or parameters are invalid
351
-	 * @since 11.0.0
352
-	 */
353
-	public function setRichMessage($message, array $parameters = []) {
354
-		if (!is_string($message)) {
355
-			throw new \InvalidArgumentException('The given parsed message is invalid');
356
-		}
357
-		$this->messageRich = $message;
358
-
359
-		if (!is_array($parameters)) {
360
-			throw new \InvalidArgumentException('The given message parameters are invalid');
361
-		}
362
-		$this->messageRichParameters = $parameters;
363
-
364
-		return $this;
365
-	}
366
-
367
-	/**
368
-	 * @return string
369
-	 * @since 11.0.0
370
-	 */
371
-	public function getRichMessage() {
372
-		return $this->messageRich;
373
-	}
374
-
375
-	/**
376
-	 * @return array[]
377
-	 * @since 11.0.0
378
-	 */
379
-	public function getRichMessageParameters() {
380
-		return $this->messageRichParameters;
381
-	}
382
-
383
-	/**
384
-	 * Set the object of the activity
385
-	 *
386
-	 * @param string $objectType
387
-	 * @param int $objectId
388
-	 * @param string $objectName
389
-	 * @return IEvent
390
-	 * @throws \InvalidArgumentException if the object is invalid
391
-	 * @since 8.2.0
392
-	 */
393
-	public function setObject($objectType, $objectId, $objectName = '') {
394
-		if (!is_string($objectType) || isset($objectType[255])) {
395
-			throw new \InvalidArgumentException('The given object type is invalid');
396
-		}
397
-		if (!is_int($objectId)) {
398
-			throw new \InvalidArgumentException('The given object id is invalid');
399
-		}
400
-		if (!is_string($objectName) || isset($objectName[4000])) {
401
-			throw new \InvalidArgumentException('The given object name is invalid');
402
-		}
403
-		$this->objectType = (string) $objectType;
404
-		$this->objectId = (int) $objectId;
405
-		$this->objectName = (string) $objectName;
406
-		return $this;
407
-	}
408
-
409
-	/**
410
-	 * @return string
411
-	 */
412
-	public function getObjectType() {
413
-		return $this->objectType;
414
-	}
415
-
416
-	/**
417
-	 * @return string
418
-	 */
419
-	public function getObjectId() {
420
-		return $this->objectId;
421
-	}
422
-
423
-	/**
424
-	 * @return string
425
-	 */
426
-	public function getObjectName() {
427
-		return $this->objectName;
428
-	}
429
-
430
-	/**
431
-	 * Set the link of the activity
432
-	 *
433
-	 * @param string $link
434
-	 * @return IEvent
435
-	 * @throws \InvalidArgumentException if the link is invalid
436
-	 * @since 8.2.0
437
-	 */
438
-	public function setLink($link) {
439
-		if (!is_string($link) || isset($link[4000])) {
440
-			throw new \InvalidArgumentException('The given link is invalid');
441
-		}
442
-		$this->link = (string) $link;
443
-		return $this;
444
-	}
445
-
446
-	/**
447
-	 * @return string
448
-	 */
449
-	public function getLink() {
450
-		return $this->link;
451
-	}
452
-
453
-	/**
454
-	 * @param string $icon
455
-	 * @return $this
456
-	 * @throws \InvalidArgumentException if the icon is invalid
457
-	 * @since 11.0.0
458
-	 */
459
-	public function setIcon($icon) {
460
-		if (!is_string($icon) || isset($icon[4000])) {
461
-			throw new \InvalidArgumentException('The given icon is invalid');
462
-		}
463
-		$this->icon = $icon;
464
-		return $this;
465
-	}
466
-
467
-	/**
468
-	 * @return string
469
-	 * @since 11.0.0
470
-	 */
471
-	public function getIcon() {
472
-		return $this->icon;
473
-	}
474
-
475
-	/**
476
-	 * @param IEvent $child
477
-	 * @since 11.0.0
478
-	 */
479
-	public function setChildEvent(IEvent $child) {
480
-		$this->child = $child;
481
-	}
482
-
483
-	/**
484
-	 * @return IEvent|null
485
-	 * @since 11.0.0
486
-	 */
487
-	public function getChildEvent() {
488
-		return $this->child;
489
-	}
490
-
491
-	/**
492
-	 * @return bool
493
-	 * @since 8.2.0
494
-	 */
495
-	public function isValid() {
496
-		return
497
-			$this->isValidCommon()
498
-			&&
499
-			$this->getSubject() !== ''
500
-		;
501
-	}
502
-
503
-	/**
504
-	 * @return bool
505
-	 * @since 8.2.0
506
-	 */
507
-	public function isValidParsed() {
508
-		if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
509
-			try {
510
-				$this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
511
-			} catch (InvalidObjectExeption $e) {
512
-				return false;
513
-			}
514
-		}
515
-
516
-		if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
517
-			try {
518
-				$this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
519
-			} catch (InvalidObjectExeption $e) {
520
-				return false;
521
-			}
522
-		}
523
-
524
-		return
525
-			$this->isValidCommon()
526
-			&&
527
-			$this->getParsedSubject() !== ''
528
-		;
529
-	}
530
-
531
-	/**
532
-	 * @return bool
533
-	 */
534
-	protected function isValidCommon() {
535
-		return
536
-			$this->getApp() !== ''
537
-			&&
538
-			$this->getType() !== ''
539
-			&&
540
-			$this->getAffectedUser() !== ''
541
-			&&
542
-			$this->getTimestamp() !== 0
543
-			/**
544
-			 * Disabled for BC with old activities
33
+    /** @var string */
34
+    protected $app = '';
35
+    /** @var string */
36
+    protected $type = '';
37
+    /** @var string */
38
+    protected $affectedUser = '';
39
+    /** @var string */
40
+    protected $author = '';
41
+    /** @var int */
42
+    protected $timestamp = 0;
43
+    /** @var string */
44
+    protected $subject = '';
45
+    /** @var array */
46
+    protected $subjectParameters = [];
47
+    /** @var string */
48
+    protected $subjectParsed;
49
+    /** @var string */
50
+    protected $subjectRich;
51
+    /** @var array */
52
+    protected $subjectRichParameters;
53
+    /** @var string */
54
+    protected $message = '';
55
+    /** @var array */
56
+    protected $messageParameters = [];
57
+    /** @var string */
58
+    protected $messageParsed;
59
+    /** @var string */
60
+    protected $messageRich;
61
+    /** @var array */
62
+    protected $messageRichParameters;
63
+    /** @var string */
64
+    protected $objectType = '';
65
+    /** @var int */
66
+    protected $objectId = 0;
67
+    /** @var string */
68
+    protected $objectName = '';
69
+    /** @var string */
70
+    protected $link = '';
71
+    /** @var string */
72
+    protected $icon = '';
73
+
74
+    /** @var IEvent */
75
+    protected $child = null;
76
+    /** @var IValidator */
77
+    protected $richValidator;
78
+
79
+    /**
80
+     * @param IValidator $richValidator
81
+     */
82
+    public function __construct(IValidator $richValidator) {
83
+        $this->richValidator = $richValidator;
84
+    }
85
+
86
+    /**
87
+     * Set the app of the activity
88
+     *
89
+     * @param string $app
90
+     * @return IEvent
91
+     * @throws \InvalidArgumentException if the app id is invalid
92
+     * @since 8.2.0
93
+     */
94
+    public function setApp($app) {
95
+        if (!is_string($app) || $app === '' || isset($app[32])) {
96
+            throw new \InvalidArgumentException('The given app is invalid');
97
+        }
98
+        $this->app = (string) $app;
99
+        return $this;
100
+    }
101
+
102
+    /**
103
+     * @return string
104
+     */
105
+    public function getApp() {
106
+        return $this->app;
107
+    }
108
+
109
+    /**
110
+     * Set the type of the activity
111
+     *
112
+     * @param string $type
113
+     * @return IEvent
114
+     * @throws \InvalidArgumentException if the type is invalid
115
+     * @since 8.2.0
116
+     */
117
+    public function setType($type) {
118
+        if (!is_string($type) || $type === '' || isset($type[255])) {
119
+            throw new \InvalidArgumentException('The given type is invalid');
120
+        }
121
+        $this->type = (string) $type;
122
+        return $this;
123
+    }
124
+
125
+    /**
126
+     * @return string
127
+     */
128
+    public function getType() {
129
+        return $this->type;
130
+    }
131
+
132
+    /**
133
+     * Set the affected user of the activity
134
+     *
135
+     * @param string $affectedUser
136
+     * @return IEvent
137
+     * @throws \InvalidArgumentException if the affected user is invalid
138
+     * @since 8.2.0
139
+     */
140
+    public function setAffectedUser($affectedUser) {
141
+        if (!is_string($affectedUser) || $affectedUser === '' || isset($affectedUser[64])) {
142
+            throw new \InvalidArgumentException('The given affected user is invalid');
143
+        }
144
+        $this->affectedUser = (string) $affectedUser;
145
+        return $this;
146
+    }
147
+
148
+    /**
149
+     * @return string
150
+     */
151
+    public function getAffectedUser() {
152
+        return $this->affectedUser;
153
+    }
154
+
155
+    /**
156
+     * Set the author of the activity
157
+     *
158
+     * @param string $author
159
+     * @return IEvent
160
+     * @throws \InvalidArgumentException if the author is invalid
161
+     * @since 8.2.0
162
+     */
163
+    public function setAuthor($author) {
164
+        if (!is_string($author) || isset($author[64])) {
165
+            throw new \InvalidArgumentException('The given author user is invalid'. serialize($author));
166
+        }
167
+        $this->author = (string) $author;
168
+        return $this;
169
+    }
170
+
171
+    /**
172
+     * @return string
173
+     */
174
+    public function getAuthor() {
175
+        return $this->author;
176
+    }
177
+
178
+    /**
179
+     * Set the timestamp of the activity
180
+     *
181
+     * @param int $timestamp
182
+     * @return IEvent
183
+     * @throws \InvalidArgumentException if the timestamp is invalid
184
+     * @since 8.2.0
185
+     */
186
+    public function setTimestamp($timestamp) {
187
+        if (!is_int($timestamp)) {
188
+            throw new \InvalidArgumentException('The given timestamp is invalid');
189
+        }
190
+        $this->timestamp = (int) $timestamp;
191
+        return $this;
192
+    }
193
+
194
+    /**
195
+     * @return int
196
+     */
197
+    public function getTimestamp() {
198
+        return $this->timestamp;
199
+    }
200
+
201
+    /**
202
+     * Set the subject of the activity
203
+     *
204
+     * @param string $subject
205
+     * @param array $parameters
206
+     * @return IEvent
207
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
208
+     * @since 8.2.0
209
+     */
210
+    public function setSubject($subject, array $parameters = []) {
211
+        if (!is_string($subject) || isset($subject[255])) {
212
+            throw new \InvalidArgumentException('The given subject is invalid');
213
+        }
214
+        $this->subject = (string) $subject;
215
+        $this->subjectParameters = $parameters;
216
+        return $this;
217
+    }
218
+
219
+    /**
220
+     * @return string
221
+     */
222
+    public function getSubject() {
223
+        return $this->subject;
224
+    }
225
+
226
+    /**
227
+     * @return array
228
+     */
229
+    public function getSubjectParameters() {
230
+        return $this->subjectParameters;
231
+    }
232
+
233
+    /**
234
+     * @param string $subject
235
+     * @return $this
236
+     * @throws \InvalidArgumentException if the subject is invalid
237
+     * @since 11.0.0
238
+     */
239
+    public function setParsedSubject($subject) {
240
+        if (!is_string($subject) || $subject === '') {
241
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
242
+        }
243
+        $this->subjectParsed = $subject;
244
+        return $this;
245
+    }
246
+
247
+    /**
248
+     * @return string
249
+     * @since 11.0.0
250
+     */
251
+    public function getParsedSubject() {
252
+        return $this->subjectParsed;
253
+    }
254
+
255
+    /**
256
+     * @param string $subject
257
+     * @param array $parameters
258
+     * @return $this
259
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
260
+     * @since 11.0.0
261
+     */
262
+    public function setRichSubject($subject, array $parameters = []) {
263
+        if (!is_string($subject) || $subject === '') {
264
+            throw new \InvalidArgumentException('The given parsed subject is invalid');
265
+        }
266
+        $this->subjectRich = $subject;
267
+
268
+        if (!is_array($parameters)) {
269
+            throw new \InvalidArgumentException('The given subject parameters are invalid');
270
+        }
271
+        $this->subjectRichParameters = $parameters;
272
+
273
+        return $this;
274
+    }
275
+
276
+    /**
277
+     * @return string
278
+     * @since 11.0.0
279
+     */
280
+    public function getRichSubject() {
281
+        return $this->subjectRich;
282
+    }
283
+
284
+    /**
285
+     * @return array[]
286
+     * @since 11.0.0
287
+     */
288
+    public function getRichSubjectParameters() {
289
+        return $this->subjectRichParameters;
290
+    }
291
+
292
+    /**
293
+     * Set the message of the activity
294
+     *
295
+     * @param string $message
296
+     * @param array $parameters
297
+     * @return IEvent
298
+     * @throws \InvalidArgumentException if the message or parameters are invalid
299
+     * @since 8.2.0
300
+     */
301
+    public function setMessage($message, array $parameters = []) {
302
+        if (!is_string($message) || isset($message[255])) {
303
+            throw new \InvalidArgumentException('The given message is invalid');
304
+        }
305
+        $this->message = (string) $message;
306
+        $this->messageParameters = $parameters;
307
+        return $this;
308
+    }
309
+
310
+    /**
311
+     * @return string
312
+     */
313
+    public function getMessage() {
314
+        return $this->message;
315
+    }
316
+
317
+    /**
318
+     * @return array
319
+     */
320
+    public function getMessageParameters() {
321
+        return $this->messageParameters;
322
+    }
323
+
324
+    /**
325
+     * @param string $message
326
+     * @return $this
327
+     * @throws \InvalidArgumentException if the message is invalid
328
+     * @since 11.0.0
329
+     */
330
+    public function setParsedMessage($message) {
331
+        if (!is_string($message)) {
332
+            throw new \InvalidArgumentException('The given parsed message is invalid');
333
+        }
334
+        $this->messageParsed = $message;
335
+        return $this;
336
+    }
337
+
338
+    /**
339
+     * @return string
340
+     * @since 11.0.0
341
+     */
342
+    public function getParsedMessage() {
343
+        return $this->messageParsed;
344
+    }
345
+
346
+    /**
347
+     * @param string $message
348
+     * @param array $parameters
349
+     * @return $this
350
+     * @throws \InvalidArgumentException if the subject or parameters are invalid
351
+     * @since 11.0.0
352
+     */
353
+    public function setRichMessage($message, array $parameters = []) {
354
+        if (!is_string($message)) {
355
+            throw new \InvalidArgumentException('The given parsed message is invalid');
356
+        }
357
+        $this->messageRich = $message;
358
+
359
+        if (!is_array($parameters)) {
360
+            throw new \InvalidArgumentException('The given message parameters are invalid');
361
+        }
362
+        $this->messageRichParameters = $parameters;
363
+
364
+        return $this;
365
+    }
366
+
367
+    /**
368
+     * @return string
369
+     * @since 11.0.0
370
+     */
371
+    public function getRichMessage() {
372
+        return $this->messageRich;
373
+    }
374
+
375
+    /**
376
+     * @return array[]
377
+     * @since 11.0.0
378
+     */
379
+    public function getRichMessageParameters() {
380
+        return $this->messageRichParameters;
381
+    }
382
+
383
+    /**
384
+     * Set the object of the activity
385
+     *
386
+     * @param string $objectType
387
+     * @param int $objectId
388
+     * @param string $objectName
389
+     * @return IEvent
390
+     * @throws \InvalidArgumentException if the object is invalid
391
+     * @since 8.2.0
392
+     */
393
+    public function setObject($objectType, $objectId, $objectName = '') {
394
+        if (!is_string($objectType) || isset($objectType[255])) {
395
+            throw new \InvalidArgumentException('The given object type is invalid');
396
+        }
397
+        if (!is_int($objectId)) {
398
+            throw new \InvalidArgumentException('The given object id is invalid');
399
+        }
400
+        if (!is_string($objectName) || isset($objectName[4000])) {
401
+            throw new \InvalidArgumentException('The given object name is invalid');
402
+        }
403
+        $this->objectType = (string) $objectType;
404
+        $this->objectId = (int) $objectId;
405
+        $this->objectName = (string) $objectName;
406
+        return $this;
407
+    }
408
+
409
+    /**
410
+     * @return string
411
+     */
412
+    public function getObjectType() {
413
+        return $this->objectType;
414
+    }
415
+
416
+    /**
417
+     * @return string
418
+     */
419
+    public function getObjectId() {
420
+        return $this->objectId;
421
+    }
422
+
423
+    /**
424
+     * @return string
425
+     */
426
+    public function getObjectName() {
427
+        return $this->objectName;
428
+    }
429
+
430
+    /**
431
+     * Set the link of the activity
432
+     *
433
+     * @param string $link
434
+     * @return IEvent
435
+     * @throws \InvalidArgumentException if the link is invalid
436
+     * @since 8.2.0
437
+     */
438
+    public function setLink($link) {
439
+        if (!is_string($link) || isset($link[4000])) {
440
+            throw new \InvalidArgumentException('The given link is invalid');
441
+        }
442
+        $this->link = (string) $link;
443
+        return $this;
444
+    }
445
+
446
+    /**
447
+     * @return string
448
+     */
449
+    public function getLink() {
450
+        return $this->link;
451
+    }
452
+
453
+    /**
454
+     * @param string $icon
455
+     * @return $this
456
+     * @throws \InvalidArgumentException if the icon is invalid
457
+     * @since 11.0.0
458
+     */
459
+    public function setIcon($icon) {
460
+        if (!is_string($icon) || isset($icon[4000])) {
461
+            throw new \InvalidArgumentException('The given icon is invalid');
462
+        }
463
+        $this->icon = $icon;
464
+        return $this;
465
+    }
466
+
467
+    /**
468
+     * @return string
469
+     * @since 11.0.0
470
+     */
471
+    public function getIcon() {
472
+        return $this->icon;
473
+    }
474
+
475
+    /**
476
+     * @param IEvent $child
477
+     * @since 11.0.0
478
+     */
479
+    public function setChildEvent(IEvent $child) {
480
+        $this->child = $child;
481
+    }
482
+
483
+    /**
484
+     * @return IEvent|null
485
+     * @since 11.0.0
486
+     */
487
+    public function getChildEvent() {
488
+        return $this->child;
489
+    }
490
+
491
+    /**
492
+     * @return bool
493
+     * @since 8.2.0
494
+     */
495
+    public function isValid() {
496
+        return
497
+            $this->isValidCommon()
498
+            &&
499
+            $this->getSubject() !== ''
500
+        ;
501
+    }
502
+
503
+    /**
504
+     * @return bool
505
+     * @since 8.2.0
506
+     */
507
+    public function isValidParsed() {
508
+        if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) {
509
+            try {
510
+                $this->richValidator->validate($this->getRichSubject(), $this->getRichSubjectParameters());
511
+            } catch (InvalidObjectExeption $e) {
512
+                return false;
513
+            }
514
+        }
515
+
516
+        if ($this->getRichMessage() !== '' || !empty($this->getRichMessageParameters())) {
517
+            try {
518
+                $this->richValidator->validate($this->getRichMessage(), $this->getRichMessageParameters());
519
+            } catch (InvalidObjectExeption $e) {
520
+                return false;
521
+            }
522
+        }
523
+
524
+        return
525
+            $this->isValidCommon()
526
+            &&
527
+            $this->getParsedSubject() !== ''
528
+        ;
529
+    }
530
+
531
+    /**
532
+     * @return bool
533
+     */
534
+    protected function isValidCommon() {
535
+        return
536
+            $this->getApp() !== ''
537
+            &&
538
+            $this->getType() !== ''
539
+            &&
540
+            $this->getAffectedUser() !== ''
541
+            &&
542
+            $this->getTimestamp() !== 0
543
+            /**
544
+             * Disabled for BC with old activities
545 545
 			&&
546 546
 			$this->getObjectType() !== ''
547 547
 			&&
548 548
 			$this->getObjectId() !== 0
549
-			 */
550
-		;
551
-	}
549
+             */
550
+        ;
551
+    }
552 552
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@
 block discarded – undo
162 162
 	 */
163 163
 	public function setAuthor($author) {
164 164
 		if (!is_string($author) || isset($author[64])) {
165
-			throw new \InvalidArgumentException('The given author user is invalid'. serialize($author));
165
+			throw new \InvalidArgumentException('The given author user is invalid'.serialize($author));
166 166
 		}
167 167
 		$this->author = (string) $author;
168 168
 		return $this;
Please login to merge, or discard this patch.