Passed
Push — master ( 24e25a...d3efd4 )
by Joas
29:31 queued 13:57
created
apps/cloud_federation_api/lib/Capabilities.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -28,38 +28,38 @@
 block discarded – undo
28 28
 
29 29
 class Capabilities implements ICapability {
30 30
 
31
-	/** @var IURLGenerator */
32
-	private $urlGenerator;
31
+    /** @var IURLGenerator */
32
+    private $urlGenerator;
33 33
 
34
-	public function __construct(IURLGenerator $urlGenerator) {
35
-		$this->urlGenerator = $urlGenerator;
36
-	}
34
+    public function __construct(IURLGenerator $urlGenerator) {
35
+        $this->urlGenerator = $urlGenerator;
36
+    }
37 37
 
38
-	/**
39
-	 * Function an app uses to return the capabilities
40
-	 *
41
-	 * @return array Array containing the apps capabilities
42
-	 * @since 8.2.0
43
-	 */
44
-	public function getCapabilities() {
45
-		$url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare');
46
-		$capabilities = ['ocm' =>
47
-			[
48
-				'enabled' => true,
49
-				'apiVersion' => '1.0-proposal1',
50
-				'endPoint' => substr($url, 0, strrpos($url, '/')),
51
-				'resourceTypes' => [
52
-					[
53
-						'name' => 'file',
54
-						'shareTypes' => ['user', 'group'],
55
-						'protocols' => [
56
-							'webdav' => '/public.php/webdav/',
57
-						]
58
-					],
59
-				]
60
-			]
61
-		];
38
+    /**
39
+     * Function an app uses to return the capabilities
40
+     *
41
+     * @return array Array containing the apps capabilities
42
+     * @since 8.2.0
43
+     */
44
+    public function getCapabilities() {
45
+        $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare');
46
+        $capabilities = ['ocm' =>
47
+            [
48
+                'enabled' => true,
49
+                'apiVersion' => '1.0-proposal1',
50
+                'endPoint' => substr($url, 0, strrpos($url, '/')),
51
+                'resourceTypes' => [
52
+                    [
53
+                        'name' => 'file',
54
+                        'shareTypes' => ['user', 'group'],
55
+                        'protocols' => [
56
+                            'webdav' => '/public.php/webdav/',
57
+                        ]
58
+                    ],
59
+                ]
60
+            ]
61
+        ];
62 62
 
63
-		return $capabilities;
64
-	}
63
+        return $capabilities;
64
+    }
65 65
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@
 block discarded – undo
31 31
 
32 32
 class AddClenupLoginFlowV2BackgroundJob implements IRepairStep {
33 33
 
34
-	/** @var IJobList */
35
-	private $jobList;
34
+    /** @var IJobList */
35
+    private $jobList;
36 36
 
37
-	public function __construct(IJobList $jobList) {
38
-		$this->jobList = $jobList;
39
-	}
37
+    public function __construct(IJobList $jobList) {
38
+        $this->jobList = $jobList;
39
+    }
40 40
 
41
-	public function getName(): string {
42
-		return 'Add background job to cleanup login flow v2 tokens';
43
-	}
41
+    public function getName(): string {
42
+        return 'Add background job to cleanup login flow v2 tokens';
43
+    }
44 44
 
45
-	public function run(IOutput $output) {
46
-		$this->jobList->add(CleanupLoginFlowV2::class);
47
-	}
45
+    public function run(IOutput $output) {
46
+        $this->jobList->add(CleanupLoginFlowV2::class);
47
+    }
48 48
 
49 49
 }
Please login to merge, or discard this patch.
core/Data/LoginFlowV2Credentials.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,47 +25,47 @@
 block discarded – undo
25 25
 namespace OC\Core\Data;
26 26
 
27 27
 class LoginFlowV2Credentials implements \JsonSerializable {
28
-	/** @var string */
29
-	private $server;
30
-	/** @var string */
31
-	private $loginName;
32
-	/** @var string */
33
-	private $appPassword;
28
+    /** @var string */
29
+    private $server;
30
+    /** @var string */
31
+    private $loginName;
32
+    /** @var string */
33
+    private $appPassword;
34 34
 
35
-	public function __construct(string $server, string $loginName, string $appPassword) {
36
-		$this->server = $server;
37
-		$this->loginName = $loginName;
38
-		$this->appPassword = $appPassword;
39
-	}
35
+    public function __construct(string $server, string $loginName, string $appPassword) {
36
+        $this->server = $server;
37
+        $this->loginName = $loginName;
38
+        $this->appPassword = $appPassword;
39
+    }
40 40
 
41
-	/**
42
-	 * @return string
43
-	 */
44
-	public function getServer(): string {
45
-		return $this->server;
46
-	}
41
+    /**
42
+     * @return string
43
+     */
44
+    public function getServer(): string {
45
+        return $this->server;
46
+    }
47 47
 
48
-	/**
49
-	 * @return string
50
-	 */
51
-	public function getLoginName(): string {
52
-		return $this->loginName;
53
-	}
48
+    /**
49
+     * @return string
50
+     */
51
+    public function getLoginName(): string {
52
+        return $this->loginName;
53
+    }
54 54
 
55
-	/**
56
-	 * @return string
57
-	 */
58
-	public function getAppPassword(): string {
59
-		return $this->appPassword;
60
-	}
55
+    /**
56
+     * @return string
57
+     */
58
+    public function getAppPassword(): string {
59
+        return $this->appPassword;
60
+    }
61 61
 
62
-	public function jsonSerialize(): array {
63
-		return [
64
-			'server' => $this->server,
65
-			'loginName' => $this->loginName,
66
-			'appPassword' => $this->appPassword,
67
-		];
68
-	}
62
+    public function jsonSerialize(): array {
63
+        return [
64
+            'server' => $this->server,
65
+            'loginName' => $this->loginName,
66
+            'appPassword' => $this->appPassword,
67
+        ];
68
+    }
69 69
 
70 70
 
71 71
 }
Please login to merge, or discard this patch.
core/Service/LoginFlowV2Service.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
 	private function hashToken(string $token): string {
213 213
 		$secret = $this->config->getSystemValue('secret');
214
-		return hash('sha512', $token . $secret);
214
+		return hash('sha512', $token.$secret);
215 215
 	}
216 216
 
217 217
 	private function getKeyPair(): array {
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		while ($error = openssl_error_string()) {
242 242
 			$errors[] = $error;
243 243
 		}
244
-		$this->logger->critical('Something is wrong with your openssl setup: ' . implode(', ', $errors));
244
+		$this->logger->critical('Something is wrong with your openssl setup: '.implode(', ', $errors));
245 245
 	}
246 246
 
247 247
 	private function encryptPassword(string $password, string $publicKey): string {
Please login to merge, or discard this patch.
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -44,235 +44,235 @@
 block discarded – undo
44 44
 
45 45
 class LoginFlowV2Service {
46 46
 
47
-	/** @var LoginFlowV2Mapper */
48
-	private $mapper;
49
-	/** @var ISecureRandom */
50
-	private $random;
51
-	/** @var ITimeFactory */
52
-	private $time;
53
-	/** @var IConfig */
54
-	private $config;
55
-	/** @var ICrypto */
56
-	private $crypto;
57
-	/** @var ILogger */
58
-	private $logger;
59
-	/** @var IProvider */
60
-	private $tokenProvider;
61
-
62
-	public function __construct(LoginFlowV2Mapper $mapper,
63
-								ISecureRandom $random,
64
-								ITimeFactory $time,
65
-								IConfig $config,
66
-								ICrypto $crypto,
67
-								ILogger $logger,
68
-								IProvider $tokenProvider) {
69
-		$this->mapper = $mapper;
70
-		$this->random = $random;
71
-		$this->time = $time;
72
-		$this->config = $config;
73
-		$this->crypto = $crypto;
74
-		$this->logger = $logger;
75
-		$this->tokenProvider = $tokenProvider;
76
-	}
77
-
78
-	/**
79
-	 * @param string $pollToken
80
-	 * @return LoginFlowV2Credentials
81
-	 * @throws LoginFlowV2NotFoundException
82
-	 */
83
-	public function poll(string $pollToken): LoginFlowV2Credentials {
84
-		try {
85
-			$data = $this->mapper->getByPollToken($this->hashToken($pollToken));
86
-		} catch (DoesNotExistException $e) {
87
-			throw new LoginFlowV2NotFoundException('Invalid token');
88
-		}
89
-
90
-		$loginName = $data->getLoginName();
91
-		$server = $data->getServer();
92
-		$appPassword = $data->getAppPassword();
93
-
94
-		if ($loginName === null || $server === null || $appPassword === null) {
95
-			throw new LoginFlowV2NotFoundException('Token not yet ready');
96
-		}
97
-
98
-		// Remove the data from the DB
99
-		$this->mapper->delete($data);
100
-
101
-		try {
102
-			// Decrypt the apptoken
103
-			$privateKey = $this->crypto->decrypt($data->getPrivateKey(), $pollToken);
104
-			$appPassword = $this->decryptPassword($data->getAppPassword(), $privateKey);
105
-		} catch (\Exception $e) {
106
-			throw new LoginFlowV2NotFoundException('Apptoken could not be decrypted');
107
-		}
108
-
109
-		return new LoginFlowV2Credentials($server, $loginName, $appPassword);
110
-	}
111
-
112
-	/**
113
-	 * @param string $loginToken
114
-	 * @return LoginFlowV2
115
-	 * @throws LoginFlowV2NotFoundException
116
-	 */
117
-	public function getByLoginToken(string $loginToken): LoginFlowV2 {
118
-		try {
119
-			return $this->mapper->getByLoginToken($loginToken);
120
-		} catch (DoesNotExistException $e) {
121
-			throw new LoginFlowV2NotFoundException('Login token invalid');
122
-		}
123
-	}
124
-
125
-	/**
126
-	 * @param string $loginToken
127
-	 * @return bool returns true if the start was successfull. False if not.
128
-	 */
129
-	public function startLoginFlow(string $loginToken): bool {
130
-		try {
131
-			$data = $this->mapper->getByLoginToken($loginToken);
132
-		} catch (DoesNotExistException $e) {
133
-			return false;
134
-		}
135
-
136
-		$data->setStarted(1);
137
-		$this->mapper->update($data);
138
-
139
-		return true;
140
-	}
141
-
142
-	/**
143
-	 * @param string $loginToken
144
-	 * @param string $sessionId
145
-	 * @param string $server
146
-	 * @param string $userId
147
-	 * @return bool true if the flow was successfully completed false otherwise
148
-	 */
149
-	public function flowDone(string $loginToken, string $sessionId, string $server, string $userId): bool {
150
-		try {
151
-			$data = $this->mapper->getByLoginToken($loginToken);
152
-		} catch (DoesNotExistException $e) {
153
-			return false;
154
-		}
155
-
156
-		try {
157
-			$sessionToken = $this->tokenProvider->getToken($sessionId);
158
-			$loginName = $sessionToken->getLoginName();
159
-			try {
160
-				$password = $this->tokenProvider->getPassword($sessionToken, $sessionId);
161
-			} catch (PasswordlessTokenException $ex) {
162
-				$password = null;
163
-			}
164
-		} catch (InvalidTokenException $ex) {
165
-			return false;
166
-		}
167
-
168
-		$appPassword = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
169
-		$this->tokenProvider->generateToken(
170
-			$appPassword,
171
-			$userId,
172
-			$loginName,
173
-			$password,
174
-			$data->getClientName(),
175
-			IToken::PERMANENT_TOKEN,
176
-			IToken::DO_NOT_REMEMBER
177
-		);
178
-
179
-		$data->setLoginName($loginName);
180
-		$data->setServer($server);
181
-
182
-		// Properly encrypt
183
-		$data->setAppPassword($this->encryptPassword($appPassword, $data->getPublicKey()));
184
-
185
-		$this->mapper->update($data);
186
-		return true;
187
-	}
188
-
189
-	public function flowDoneWithAppPassword(string $loginToken, string $server, string $loginName, string $appPassword): bool {
190
-		try {
191
-			$data = $this->mapper->getByLoginToken($loginToken);
192
-		} catch (DoesNotExistException $e) {
193
-			return false;
194
-		}
195
-
196
-		$data->setLoginName($loginName);
197
-		$data->setServer($server);
198
-
199
-		// Properly encrypt
200
-		$data->setAppPassword($this->encryptPassword($appPassword, $data->getPublicKey()));
201
-
202
-		$this->mapper->update($data);
203
-		return true;
204
-	}
205
-
206
-	public function createTokens(string $userAgent): LoginFlowV2Tokens {
207
-		$flow = new LoginFlowV2();
208
-		$pollToken = $this->random->generate(128, ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER);
209
-		$loginToken = $this->random->generate(128, ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER);
210
-		$flow->setPollToken($this->hashToken($pollToken));
211
-		$flow->setLoginToken($loginToken);
212
-		$flow->setStarted(0);
213
-		$flow->setTimestamp($this->time->getTime());
214
-		$flow->setClientName($userAgent);
215
-
216
-		[$publicKey, $privateKey] = $this->getKeyPair();
217
-		$privateKey = $this->crypto->encrypt($privateKey, $pollToken);
218
-
219
-		$flow->setPublicKey($publicKey);
220
-		$flow->setPrivateKey($privateKey);
221
-
222
-		$this->mapper->insert($flow);
223
-
224
-		return new LoginFlowV2Tokens($loginToken, $pollToken);
225
-	}
226
-
227
-	private function hashToken(string $token): string {
228
-		$secret = $this->config->getSystemValue('secret');
229
-		return hash('sha512', $token . $secret);
230
-	}
231
-
232
-	private function getKeyPair(): array {
233
-		$config = array_merge([
234
-			'digest_alg' => 'sha512',
235
-			'private_key_bits' => 2048,
236
-		], $this->config->getSystemValue('openssl', []));
237
-
238
-		// Generate new key
239
-		$res = openssl_pkey_new($config);
240
-		if ($res === false) {
241
-			$this->logOpensslError();
242
-			throw new \RuntimeException('Could not initialize keys');
243
-		}
244
-
245
-		if (openssl_pkey_export($res, $privateKey, null, $config) === false) {
246
-			$this->logOpensslError();
247
-			throw new \RuntimeException('OpenSSL reported a problem');
248
-		}
249
-
250
-		// Extract the public key from $res to $pubKey
251
-		$publicKey = openssl_pkey_get_details($res);
252
-		$publicKey = $publicKey['key'];
253
-
254
-		return [$publicKey, $privateKey];
255
-	}
256
-
257
-	private function logOpensslError(): void {
258
-		$errors = [];
259
-		while ($error = openssl_error_string()) {
260
-			$errors[] = $error;
261
-		}
262
-		$this->logger->critical('Something is wrong with your openssl setup: ' . implode(', ', $errors));
263
-	}
264
-
265
-	private function encryptPassword(string $password, string $publicKey): string {
266
-		openssl_public_encrypt($password, $encryptedPassword, $publicKey, OPENSSL_PKCS1_OAEP_PADDING);
267
-		$encryptedPassword = base64_encode($encryptedPassword);
268
-
269
-		return $encryptedPassword;
270
-	}
271
-
272
-	private function decryptPassword(string $encryptedPassword, string $privateKey): string {
273
-		$encryptedPassword = base64_decode($encryptedPassword);
274
-		openssl_private_decrypt($encryptedPassword, $password, $privateKey, OPENSSL_PKCS1_OAEP_PADDING);
275
-
276
-		return $password;
277
-	}
47
+    /** @var LoginFlowV2Mapper */
48
+    private $mapper;
49
+    /** @var ISecureRandom */
50
+    private $random;
51
+    /** @var ITimeFactory */
52
+    private $time;
53
+    /** @var IConfig */
54
+    private $config;
55
+    /** @var ICrypto */
56
+    private $crypto;
57
+    /** @var ILogger */
58
+    private $logger;
59
+    /** @var IProvider */
60
+    private $tokenProvider;
61
+
62
+    public function __construct(LoginFlowV2Mapper $mapper,
63
+                                ISecureRandom $random,
64
+                                ITimeFactory $time,
65
+                                IConfig $config,
66
+                                ICrypto $crypto,
67
+                                ILogger $logger,
68
+                                IProvider $tokenProvider) {
69
+        $this->mapper = $mapper;
70
+        $this->random = $random;
71
+        $this->time = $time;
72
+        $this->config = $config;
73
+        $this->crypto = $crypto;
74
+        $this->logger = $logger;
75
+        $this->tokenProvider = $tokenProvider;
76
+    }
77
+
78
+    /**
79
+     * @param string $pollToken
80
+     * @return LoginFlowV2Credentials
81
+     * @throws LoginFlowV2NotFoundException
82
+     */
83
+    public function poll(string $pollToken): LoginFlowV2Credentials {
84
+        try {
85
+            $data = $this->mapper->getByPollToken($this->hashToken($pollToken));
86
+        } catch (DoesNotExistException $e) {
87
+            throw new LoginFlowV2NotFoundException('Invalid token');
88
+        }
89
+
90
+        $loginName = $data->getLoginName();
91
+        $server = $data->getServer();
92
+        $appPassword = $data->getAppPassword();
93
+
94
+        if ($loginName === null || $server === null || $appPassword === null) {
95
+            throw new LoginFlowV2NotFoundException('Token not yet ready');
96
+        }
97
+
98
+        // Remove the data from the DB
99
+        $this->mapper->delete($data);
100
+
101
+        try {
102
+            // Decrypt the apptoken
103
+            $privateKey = $this->crypto->decrypt($data->getPrivateKey(), $pollToken);
104
+            $appPassword = $this->decryptPassword($data->getAppPassword(), $privateKey);
105
+        } catch (\Exception $e) {
106
+            throw new LoginFlowV2NotFoundException('Apptoken could not be decrypted');
107
+        }
108
+
109
+        return new LoginFlowV2Credentials($server, $loginName, $appPassword);
110
+    }
111
+
112
+    /**
113
+     * @param string $loginToken
114
+     * @return LoginFlowV2
115
+     * @throws LoginFlowV2NotFoundException
116
+     */
117
+    public function getByLoginToken(string $loginToken): LoginFlowV2 {
118
+        try {
119
+            return $this->mapper->getByLoginToken($loginToken);
120
+        } catch (DoesNotExistException $e) {
121
+            throw new LoginFlowV2NotFoundException('Login token invalid');
122
+        }
123
+    }
124
+
125
+    /**
126
+     * @param string $loginToken
127
+     * @return bool returns true if the start was successfull. False if not.
128
+     */
129
+    public function startLoginFlow(string $loginToken): bool {
130
+        try {
131
+            $data = $this->mapper->getByLoginToken($loginToken);
132
+        } catch (DoesNotExistException $e) {
133
+            return false;
134
+        }
135
+
136
+        $data->setStarted(1);
137
+        $this->mapper->update($data);
138
+
139
+        return true;
140
+    }
141
+
142
+    /**
143
+     * @param string $loginToken
144
+     * @param string $sessionId
145
+     * @param string $server
146
+     * @param string $userId
147
+     * @return bool true if the flow was successfully completed false otherwise
148
+     */
149
+    public function flowDone(string $loginToken, string $sessionId, string $server, string $userId): bool {
150
+        try {
151
+            $data = $this->mapper->getByLoginToken($loginToken);
152
+        } catch (DoesNotExistException $e) {
153
+            return false;
154
+        }
155
+
156
+        try {
157
+            $sessionToken = $this->tokenProvider->getToken($sessionId);
158
+            $loginName = $sessionToken->getLoginName();
159
+            try {
160
+                $password = $this->tokenProvider->getPassword($sessionToken, $sessionId);
161
+            } catch (PasswordlessTokenException $ex) {
162
+                $password = null;
163
+            }
164
+        } catch (InvalidTokenException $ex) {
165
+            return false;
166
+        }
167
+
168
+        $appPassword = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
169
+        $this->tokenProvider->generateToken(
170
+            $appPassword,
171
+            $userId,
172
+            $loginName,
173
+            $password,
174
+            $data->getClientName(),
175
+            IToken::PERMANENT_TOKEN,
176
+            IToken::DO_NOT_REMEMBER
177
+        );
178
+
179
+        $data->setLoginName($loginName);
180
+        $data->setServer($server);
181
+
182
+        // Properly encrypt
183
+        $data->setAppPassword($this->encryptPassword($appPassword, $data->getPublicKey()));
184
+
185
+        $this->mapper->update($data);
186
+        return true;
187
+    }
188
+
189
+    public function flowDoneWithAppPassword(string $loginToken, string $server, string $loginName, string $appPassword): bool {
190
+        try {
191
+            $data = $this->mapper->getByLoginToken($loginToken);
192
+        } catch (DoesNotExistException $e) {
193
+            return false;
194
+        }
195
+
196
+        $data->setLoginName($loginName);
197
+        $data->setServer($server);
198
+
199
+        // Properly encrypt
200
+        $data->setAppPassword($this->encryptPassword($appPassword, $data->getPublicKey()));
201
+
202
+        $this->mapper->update($data);
203
+        return true;
204
+    }
205
+
206
+    public function createTokens(string $userAgent): LoginFlowV2Tokens {
207
+        $flow = new LoginFlowV2();
208
+        $pollToken = $this->random->generate(128, ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER);
209
+        $loginToken = $this->random->generate(128, ISecureRandom::CHAR_DIGITS.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_UPPER);
210
+        $flow->setPollToken($this->hashToken($pollToken));
211
+        $flow->setLoginToken($loginToken);
212
+        $flow->setStarted(0);
213
+        $flow->setTimestamp($this->time->getTime());
214
+        $flow->setClientName($userAgent);
215
+
216
+        [$publicKey, $privateKey] = $this->getKeyPair();
217
+        $privateKey = $this->crypto->encrypt($privateKey, $pollToken);
218
+
219
+        $flow->setPublicKey($publicKey);
220
+        $flow->setPrivateKey($privateKey);
221
+
222
+        $this->mapper->insert($flow);
223
+
224
+        return new LoginFlowV2Tokens($loginToken, $pollToken);
225
+    }
226
+
227
+    private function hashToken(string $token): string {
228
+        $secret = $this->config->getSystemValue('secret');
229
+        return hash('sha512', $token . $secret);
230
+    }
231
+
232
+    private function getKeyPair(): array {
233
+        $config = array_merge([
234
+            'digest_alg' => 'sha512',
235
+            'private_key_bits' => 2048,
236
+        ], $this->config->getSystemValue('openssl', []));
237
+
238
+        // Generate new key
239
+        $res = openssl_pkey_new($config);
240
+        if ($res === false) {
241
+            $this->logOpensslError();
242
+            throw new \RuntimeException('Could not initialize keys');
243
+        }
244
+
245
+        if (openssl_pkey_export($res, $privateKey, null, $config) === false) {
246
+            $this->logOpensslError();
247
+            throw new \RuntimeException('OpenSSL reported a problem');
248
+        }
249
+
250
+        // Extract the public key from $res to $pubKey
251
+        $publicKey = openssl_pkey_get_details($res);
252
+        $publicKey = $publicKey['key'];
253
+
254
+        return [$publicKey, $privateKey];
255
+    }
256
+
257
+    private function logOpensslError(): void {
258
+        $errors = [];
259
+        while ($error = openssl_error_string()) {
260
+            $errors[] = $error;
261
+        }
262
+        $this->logger->critical('Something is wrong with your openssl setup: ' . implode(', ', $errors));
263
+    }
264
+
265
+    private function encryptPassword(string $password, string $publicKey): string {
266
+        openssl_public_encrypt($password, $encryptedPassword, $publicKey, OPENSSL_PKCS1_OAEP_PADDING);
267
+        $encryptedPassword = base64_encode($encryptedPassword);
268
+
269
+        return $encryptedPassword;
270
+    }
271
+
272
+    private function decryptPassword(string $encryptedPassword, string $privateKey): string {
273
+        $encryptedPassword = base64_decode($encryptedPassword);
274
+        openssl_private_decrypt($encryptedPassword, $password, $privateKey, OPENSSL_PKCS1_OAEP_PADDING);
275
+
276
+        return $password;
277
+    }
278 278
 }
Please login to merge, or discard this patch.
core/Db/LoginFlowV2.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -49,37 +49,37 @@
 block discarded – undo
49 49
  * @method void setAppPassword(string $appPassword)
50 50
  */
51 51
 class LoginFlowV2 extends Entity {
52
-	/** @var int */
53
-	protected $timestamp;
54
-	/** @var int */
55
-	protected $started;
56
-	/** @var string */
57
-	protected $pollToken;
58
-	/** @var string */
59
-	protected $loginToken;
60
-	/** @var string */
61
-	protected $publicKey;
62
-	/** @var string */
63
-	protected $privateKey;
64
-	/** @var string */
65
-	protected $clientName;
66
-	/** @var string */
67
-	protected $loginName;
68
-	/** @var string */
69
-	protected $server;
70
-	/** @var string */
71
-	protected $appPassword;
52
+    /** @var int */
53
+    protected $timestamp;
54
+    /** @var int */
55
+    protected $started;
56
+    /** @var string */
57
+    protected $pollToken;
58
+    /** @var string */
59
+    protected $loginToken;
60
+    /** @var string */
61
+    protected $publicKey;
62
+    /** @var string */
63
+    protected $privateKey;
64
+    /** @var string */
65
+    protected $clientName;
66
+    /** @var string */
67
+    protected $loginName;
68
+    /** @var string */
69
+    protected $server;
70
+    /** @var string */
71
+    protected $appPassword;
72 72
 
73
-	public function __construct() {
74
-		$this->addType('timestamp', 'int');
75
-		$this->addType('started', 'int');
76
-		$this->addType('pollToken', 'string');
77
-		$this->addType('loginToken', 'string');
78
-		$this->addType('publicKey', 'string');
79
-		$this->addType('privateKey', 'string');
80
-		$this->addType('clientName', 'string');
81
-		$this->addType('loginName', 'string');
82
-		$this->addType('server', 'string');
83
-		$this->addType('appPassword', 'string');
84
-	}
73
+    public function __construct() {
74
+        $this->addType('timestamp', 'int');
75
+        $this->addType('started', 'int');
76
+        $this->addType('pollToken', 'string');
77
+        $this->addType('loginToken', 'string');
78
+        $this->addType('publicKey', 'string');
79
+        $this->addType('privateKey', 'string');
80
+        $this->addType('clientName', 'string');
81
+        $this->addType('loginName', 'string');
82
+        $this->addType('server', 'string');
83
+        $this->addType('appPassword', 'string');
84
+    }
85 85
 }
Please login to merge, or discard this patch.
core/Db/LoginFlowV2Mapper.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,71 +30,71 @@
 block discarded – undo
30 30
 use OCP\IDBConnection;
31 31
 
32 32
 class LoginFlowV2Mapper extends QBMapper {
33
-	private const lifetime = 1200;
33
+    private const lifetime = 1200;
34 34
 
35
-	/** @var ITimeFactory */
36
-	private $timeFactory;
35
+    /** @var ITimeFactory */
36
+    private $timeFactory;
37 37
 
38
-	public function __construct(IDBConnection $db, ITimeFactory $timeFactory) {
39
-		parent::__construct($db, 'login_flow_v2', LoginFlowV2::class);
40
-		$this->timeFactory = $timeFactory;
41
-	}
38
+    public function __construct(IDBConnection $db, ITimeFactory $timeFactory) {
39
+        parent::__construct($db, 'login_flow_v2', LoginFlowV2::class);
40
+        $this->timeFactory = $timeFactory;
41
+    }
42 42
 
43
-	/**
44
-	 * @param string $pollToken
45
-	 * @return LoginFlowV2
46
-	 * @throws DoesNotExistException
47
-	 */
48
-	public function getByPollToken(string $pollToken): LoginFlowV2 {
49
-		$qb = $this->db->getQueryBuilder();
50
-		$qb->select('*')
51
-			->from($this->getTableName())
52
-			->where(
53
-				$qb->expr()->eq('poll_token', $qb->createNamedParameter($pollToken))
54
-			);
43
+    /**
44
+     * @param string $pollToken
45
+     * @return LoginFlowV2
46
+     * @throws DoesNotExistException
47
+     */
48
+    public function getByPollToken(string $pollToken): LoginFlowV2 {
49
+        $qb = $this->db->getQueryBuilder();
50
+        $qb->select('*')
51
+            ->from($this->getTableName())
52
+            ->where(
53
+                $qb->expr()->eq('poll_token', $qb->createNamedParameter($pollToken))
54
+            );
55 55
 
56
-		$entity = $this->findEntity($qb);
57
-		return $this->validateTimestamp($entity);
58
-	}
56
+        $entity = $this->findEntity($qb);
57
+        return $this->validateTimestamp($entity);
58
+    }
59 59
 
60
-	/**
61
-	 * @param string $loginToken
62
-	 * @return LoginFlowV2
63
-	 * @throws DoesNotExistException
64
-	 */
65
-	public function getByLoginToken(string $loginToken): LoginFlowV2 {
66
-		$qb = $this->db->getQueryBuilder();
67
-		$qb->select('*')
68
-			->from($this->getTableName())
69
-			->where(
70
-				$qb->expr()->eq('login_token', $qb->createNamedParameter($loginToken))
71
-			);
60
+    /**
61
+     * @param string $loginToken
62
+     * @return LoginFlowV2
63
+     * @throws DoesNotExistException
64
+     */
65
+    public function getByLoginToken(string $loginToken): LoginFlowV2 {
66
+        $qb = $this->db->getQueryBuilder();
67
+        $qb->select('*')
68
+            ->from($this->getTableName())
69
+            ->where(
70
+                $qb->expr()->eq('login_token', $qb->createNamedParameter($loginToken))
71
+            );
72 72
 
73
-		$entity = $this->findEntity($qb);
74
-		return $this->validateTimestamp($entity);
75
-	}
73
+        $entity = $this->findEntity($qb);
74
+        return $this->validateTimestamp($entity);
75
+    }
76 76
 
77
-	public function cleanup(): void {
78
-		$qb = $this->db->getQueryBuilder();
79
-		$qb->delete($this->getTableName())
80
-			->where(
81
-				$qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime))
82
-			);
77
+    public function cleanup(): void {
78
+        $qb = $this->db->getQueryBuilder();
79
+        $qb->delete($this->getTableName())
80
+            ->where(
81
+                $qb->expr()->lt('timestamp', $qb->createNamedParameter($this->timeFactory->getTime() - self::lifetime))
82
+            );
83 83
 
84
-		$qb->execute();
85
-	}
84
+        $qb->execute();
85
+    }
86 86
 
87
-	/**
88
-	 * @param LoginFlowV2 $flowV2
89
-	 * @return LoginFlowV2
90
-	 * @throws DoesNotExistException
91
-	 */
92
-	private function validateTimestamp(LoginFlowV2 $flowV2): LoginFlowV2 {
93
-		if ($flowV2->getTimestamp() < ($this->timeFactory->getTime() - self::lifetime)) {
94
-			$this->delete($flowV2);
95
-			throw new DoesNotExistException('Token expired');
96
-		}
87
+    /**
88
+     * @param LoginFlowV2 $flowV2
89
+     * @return LoginFlowV2
90
+     * @throws DoesNotExistException
91
+     */
92
+    private function validateTimestamp(LoginFlowV2 $flowV2): LoginFlowV2 {
93
+        if ($flowV2->getTimestamp() < ($this->timeFactory->getTime() - self::lifetime)) {
94
+            $this->delete($flowV2);
95
+            throw new DoesNotExistException('Token expired');
96
+        }
97 97
 
98
-		return $flowV2;
99
-	}
98
+        return $flowV2;
99
+    }
100 100
 }
Please login to merge, or discard this patch.
lib/public/Group/Backend/IHideFromCollaborationBackend.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@
 block discarded – undo
27 27
  * Allow the backend to mark groups to be excluded from being shown in search dialogs
28 28
  */
29 29
 interface IHideFromCollaborationBackend {
30
-	/**
31
-	 * Check if a group should be hidden from search dialogs
32
-	 *
33
-	 * @param string $groupId
34
-	 * @return bool
35
-	 * @since 16.0.0
36
-	 */
37
-	public function hideGroup(string $groupId): bool;
30
+    /**
31
+     * Check if a group should be hidden from search dialogs
32
+     *
33
+     * @param string $groupId
34
+     * @return bool
35
+     * @since 16.0.0
36
+     */
37
+    public function hideGroup(string $groupId): bool;
38 38
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/AutoComplete/AutoCompleteEvent.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,70 +30,70 @@
 block discarded – undo
30 30
  */
31 31
 class AutoCompleteEvent extends GenericEvent {
32 32
 
33
-	/**
34
-	 * @param array $arguments
35
-	 * @since 16.0.0
36
-	 */
37
-	public function __construct(array $arguments) {
38
-		parent::__construct(null, $arguments);
39
-	}
33
+    /**
34
+     * @param array $arguments
35
+     * @since 16.0.0
36
+     */
37
+    public function __construct(array $arguments) {
38
+        parent::__construct(null, $arguments);
39
+    }
40 40
 
41
-	/**
42
-	 * @since 16.0.0
43
-	 */
44
-	public function getResults(): array {
45
-		return $this->getArgument('results');
46
-	}
41
+    /**
42
+     * @since 16.0.0
43
+     */
44
+    public function getResults(): array {
45
+        return $this->getArgument('results');
46
+    }
47 47
 
48
-	/**
49
-	 * @param array $results
50
-	 * @since 16.0.0
51
-	 */
52
-	public function setResults(array $results): void {
53
-		$this->setArgument('results', $results);
54
-	}
48
+    /**
49
+     * @param array $results
50
+     * @since 16.0.0
51
+     */
52
+    public function setResults(array $results): void {
53
+        $this->setArgument('results', $results);
54
+    }
55 55
 
56
-	/**
57
-	 * @since 16.0.0
58
-	 */
59
-	public function getSearchTerm(): string {
60
-		return $this->getArgument('search');
61
-	}
56
+    /**
57
+     * @since 16.0.0
58
+     */
59
+    public function getSearchTerm(): string {
60
+        return $this->getArgument('search');
61
+    }
62 62
 
63
-	/**
64
-	 * @return int[]
65
-	 * @since 16.0.0
66
-	 */
67
-	public function getShareTypes(): array {
68
-		return $this->getArgument('shareTypes');
69
-	}
63
+    /**
64
+     * @return int[]
65
+     * @since 16.0.0
66
+     */
67
+    public function getShareTypes(): array {
68
+        return $this->getArgument('shareTypes');
69
+    }
70 70
 
71
-	/**
72
-	 * @since 16.0.0
73
-	 */
74
-	public function getItemType(): string {
75
-		return $this->getArgument('itemType');
76
-	}
71
+    /**
72
+     * @since 16.0.0
73
+     */
74
+    public function getItemType(): string {
75
+        return $this->getArgument('itemType');
76
+    }
77 77
 
78
-	/**
79
-	 * @since 16.0.0
80
-	 */
81
-	public function getItemId(): string {
82
-		return $this->getArgument('itemId');
83
-	}
78
+    /**
79
+     * @since 16.0.0
80
+     */
81
+    public function getItemId(): string {
82
+        return $this->getArgument('itemId');
83
+    }
84 84
 
85
-	/**
86
-	 * @since 16.0.0
87
-	 */
88
-	public function getSorter(): string {
89
-		return $this->getArgument('sorter');
90
-	}
85
+    /**
86
+     * @since 16.0.0
87
+     */
88
+    public function getSorter(): string {
89
+        return $this->getArgument('sorter');
90
+    }
91 91
 
92
-	/**
93
-	 * @since 16.0.0
94
-	 */
95
-	public function getLimit(): int {
96
-		return $this->getArgument('limit');
97
-	}
92
+    /**
93
+     * @since 16.0.0
94
+     */
95
+    public function getLimit(): int {
96
+        return $this->getArgument('limit');
97
+    }
98 98
 
99 99
 }
Please login to merge, or discard this patch.
lib/private/Files/Node/NonExistingFile.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -26,119 +26,119 @@
 block discarded – undo
26 26
 use OCP\Files\NotFoundException;
27 27
 
28 28
 class NonExistingFile extends File {
29
-	/**
30
-	 * @param string $newPath
31
-	 * @throws \OCP\Files\NotFoundException
32
-	 */
33
-	public function rename($newPath) {
34
-		throw new NotFoundException();
35
-	}
36
-
37
-	public function delete() {
38
-		throw new NotFoundException();
39
-	}
40
-
41
-	public function copy($newPath) {
42
-		throw new NotFoundException();
43
-	}
44
-
45
-	public function touch($mtime = null) {
46
-		throw new NotFoundException();
47
-	}
48
-
49
-	public function getId() {
50
-		if ($this->fileInfo) {
51
-			return parent::getId();
52
-		} else {
53
-			throw new NotFoundException();
54
-		}
55
-	}
56
-
57
-	public function stat() {
58
-		throw new NotFoundException();
59
-	}
60
-
61
-	public function getMTime() {
62
-		if ($this->fileInfo) {
63
-			return parent::getMTime();
64
-		} else {
65
-			throw new NotFoundException();
66
-		}
67
-	}
68
-
69
-	public function getSize($includeMounts = true) {
70
-		if ($this->fileInfo) {
71
-			return parent::getSize($includeMounts);
72
-		} else {
73
-			throw new NotFoundException();
74
-		}
75
-	}
76
-
77
-	public function getEtag() {
78
-		if ($this->fileInfo) {
79
-			return parent::getEtag();
80
-		} else {
81
-			throw new NotFoundException();
82
-		}
83
-	}
84
-
85
-	public function getPermissions() {
86
-		if ($this->fileInfo) {
87
-			return parent::getPermissions();
88
-		} else {
89
-			throw new NotFoundException();
90
-		}
91
-	}
92
-
93
-	public function isReadable() {
94
-		if ($this->fileInfo) {
95
-			return parent::isReadable();
96
-		} else {
97
-			throw new NotFoundException();
98
-		}
99
-	}
100
-
101
-	public function isUpdateable() {
102
-		if ($this->fileInfo) {
103
-			return parent::isUpdateable();
104
-		} else {
105
-			throw new NotFoundException();
106
-		}
107
-	}
108
-
109
-	public function isDeletable() {
110
-		if ($this->fileInfo) {
111
-			return parent::isDeletable();
112
-		} else {
113
-			throw new NotFoundException();
114
-		}
115
-	}
116
-
117
-	public function isShareable() {
118
-		if ($this->fileInfo) {
119
-			return parent::isShareable();
120
-		} else {
121
-			throw new NotFoundException();
122
-		}
123
-	}
124
-
125
-	public function getContent() {
126
-		throw new NotFoundException();
127
-	}
128
-
129
-	public function putContent($data) {
130
-		throw new NotFoundException();
131
-	}
132
-
133
-	public function getMimeType() {
134
-		if ($this->fileInfo) {
135
-			return parent::getMimeType();
136
-		} else {
137
-			throw new NotFoundException();
138
-		}
139
-	}
140
-
141
-	public function fopen($mode) {
142
-		throw new NotFoundException();
143
-	}
29
+    /**
30
+     * @param string $newPath
31
+     * @throws \OCP\Files\NotFoundException
32
+     */
33
+    public function rename($newPath) {
34
+        throw new NotFoundException();
35
+    }
36
+
37
+    public function delete() {
38
+        throw new NotFoundException();
39
+    }
40
+
41
+    public function copy($newPath) {
42
+        throw new NotFoundException();
43
+    }
44
+
45
+    public function touch($mtime = null) {
46
+        throw new NotFoundException();
47
+    }
48
+
49
+    public function getId() {
50
+        if ($this->fileInfo) {
51
+            return parent::getId();
52
+        } else {
53
+            throw new NotFoundException();
54
+        }
55
+    }
56
+
57
+    public function stat() {
58
+        throw new NotFoundException();
59
+    }
60
+
61
+    public function getMTime() {
62
+        if ($this->fileInfo) {
63
+            return parent::getMTime();
64
+        } else {
65
+            throw new NotFoundException();
66
+        }
67
+    }
68
+
69
+    public function getSize($includeMounts = true) {
70
+        if ($this->fileInfo) {
71
+            return parent::getSize($includeMounts);
72
+        } else {
73
+            throw new NotFoundException();
74
+        }
75
+    }
76
+
77
+    public function getEtag() {
78
+        if ($this->fileInfo) {
79
+            return parent::getEtag();
80
+        } else {
81
+            throw new NotFoundException();
82
+        }
83
+    }
84
+
85
+    public function getPermissions() {
86
+        if ($this->fileInfo) {
87
+            return parent::getPermissions();
88
+        } else {
89
+            throw new NotFoundException();
90
+        }
91
+    }
92
+
93
+    public function isReadable() {
94
+        if ($this->fileInfo) {
95
+            return parent::isReadable();
96
+        } else {
97
+            throw new NotFoundException();
98
+        }
99
+    }
100
+
101
+    public function isUpdateable() {
102
+        if ($this->fileInfo) {
103
+            return parent::isUpdateable();
104
+        } else {
105
+            throw new NotFoundException();
106
+        }
107
+    }
108
+
109
+    public function isDeletable() {
110
+        if ($this->fileInfo) {
111
+            return parent::isDeletable();
112
+        } else {
113
+            throw new NotFoundException();
114
+        }
115
+    }
116
+
117
+    public function isShareable() {
118
+        if ($this->fileInfo) {
119
+            return parent::isShareable();
120
+        } else {
121
+            throw new NotFoundException();
122
+        }
123
+    }
124
+
125
+    public function getContent() {
126
+        throw new NotFoundException();
127
+    }
128
+
129
+    public function putContent($data) {
130
+        throw new NotFoundException();
131
+    }
132
+
133
+    public function getMimeType() {
134
+        if ($this->fileInfo) {
135
+            return parent::getMimeType();
136
+        } else {
137
+            throw new NotFoundException();
138
+        }
139
+    }
140
+
141
+    public function fopen($mode) {
142
+        throw new NotFoundException();
143
+    }
144 144
 }
Please login to merge, or discard this patch.