Passed
Push — master ( 873501...d2df81 )
by Maxence
14:59 queued 12s
created
apps/files_external/lib/Lib/Auth/AmazonS3/AccessKey.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,17 +32,17 @@
 block discarded – undo
32 32
  * Amazon S3 access key authentication
33 33
  */
34 34
 class AccessKey extends AuthMechanism {
35
-	public const SCHEME_AMAZONS3_ACCESSKEY = 'amazons3_accesskey';
35
+    public const SCHEME_AMAZONS3_ACCESSKEY = 'amazons3_accesskey';
36 36
 
37
-	public function __construct(IL10N $l) {
38
-		$this
39
-			->setIdentifier('amazons3::accesskey')
40
-			->setScheme(self::SCHEME_AMAZONS3_ACCESSKEY)
41
-			->setText($l->t('Access key'))
42
-			->addParameters([
43
-				new DefinitionParameter('key', $l->t('Access key')),
44
-				(new DefinitionParameter('secret', $l->t('Secret key')))
45
-					->setType(DefinitionParameter::VALUE_PASSWORD),
46
-			]);
47
-	}
37
+    public function __construct(IL10N $l) {
38
+        $this
39
+            ->setIdentifier('amazons3::accesskey')
40
+            ->setScheme(self::SCHEME_AMAZONS3_ACCESSKEY)
41
+            ->setText($l->t('Access key'))
42
+            ->addParameters([
43
+                new DefinitionParameter('key', $l->t('Access key')),
44
+                (new DefinitionParameter('secret', $l->t('Secret key')))
45
+                    ->setType(DefinitionParameter::VALUE_PASSWORD),
46
+            ]);
47
+    }
48 48
 }
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Sabre/AbstractTrashFile.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@
 block discarded – undo
30 30
 use Sabre\DAV\IFile;
31 31
 
32 32
 abstract class AbstractTrashFile extends AbstractTrash implements IFile, ITrash {
33
-	public function put($data) {
34
-		throw new Forbidden();
35
-	}
33
+    public function put($data) {
34
+        throw new Forbidden();
35
+    }
36 36
 
37
-	public function setName($name) {
38
-		throw new Forbidden();
39
-	}
37
+    public function setName($name) {
38
+        throw new Forbidden();
39
+    }
40 40
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/OpenStack/OpenStackV3.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -36,19 +36,19 @@
 block discarded – undo
36 36
  * OpenStack Keystone authentication
37 37
  */
38 38
 class OpenStackV3 extends AuthMechanism {
39
-	public function __construct(IL10N $l) {
40
-		$this
41
-			->setIdentifier('openstack::openstackv3')
42
-			->setScheme(self::SCHEME_OPENSTACK)
43
-			->setText($l->t('OpenStack v3'))
44
-			->addParameters([
45
-				new DefinitionParameter('user', $l->t('Username')),
46
-				new DefinitionParameter('domain', $l->t('Domain')),
47
-				(new DefinitionParameter('password', $l->t('Password')))
48
-					->setType(DefinitionParameter::VALUE_PASSWORD),
49
-				new DefinitionParameter('tenant', $l->t('Tenant name')),
50
-				new DefinitionParameter('url', $l->t('Identity endpoint URL'))
51
-			])
52
-		;
53
-	}
39
+    public function __construct(IL10N $l) {
40
+        $this
41
+            ->setIdentifier('openstack::openstackv3')
42
+            ->setScheme(self::SCHEME_OPENSTACK)
43
+            ->setText($l->t('OpenStack v3'))
44
+            ->addParameters([
45
+                new DefinitionParameter('user', $l->t('Username')),
46
+                new DefinitionParameter('domain', $l->t('Domain')),
47
+                (new DefinitionParameter('password', $l->t('Password')))
48
+                    ->setType(DefinitionParameter::VALUE_PASSWORD),
49
+                new DefinitionParameter('tenant', $l->t('Tenant name')),
50
+                new DefinitionParameter('url', $l->t('Identity endpoint URL'))
51
+            ])
52
+        ;
53
+    }
54 54
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/HasPhotoPlugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 		$ns = '{http://nextcloud.com/ns}';
61 61
 
62 62
 		if ($node instanceof Card) {
63
-			$propFind->handle($ns . 'has-photo', function () use ($node) {
63
+			$propFind->handle($ns.'has-photo', function() use ($node) {
64 64
 				$vcard = Reader::read($node->get());
65 65
 				return $vcard instanceof VCard
66 66
 					&& $vcard->PHOTO
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -38,69 +38,69 @@
 block discarded – undo
38 38
 
39 39
 class HasPhotoPlugin extends ServerPlugin {
40 40
 
41
-	/** @var Server */
42
-	protected $server;
41
+    /** @var Server */
42
+    protected $server;
43 43
 
44
-	/**
45
-	 * Initializes the plugin and registers event handlers
46
-	 *
47
-	 * @param Server $server
48
-	 * @return void
49
-	 */
50
-	public function initialize(Server $server) {
51
-		$server->on('propFind', [$this, 'propFind']);
52
-	}
44
+    /**
45
+     * Initializes the plugin and registers event handlers
46
+     *
47
+     * @param Server $server
48
+     * @return void
49
+     */
50
+    public function initialize(Server $server) {
51
+        $server->on('propFind', [$this, 'propFind']);
52
+    }
53 53
 
54
-	/**
55
-	 * Adds all CardDAV-specific properties
56
-	 *
57
-	 * @param PropFind $propFind
58
-	 * @param INode $node
59
-	 * @return void
60
-	 */
61
-	public function propFind(PropFind $propFind, INode $node) {
62
-		$ns = '{http://nextcloud.com/ns}';
54
+    /**
55
+     * Adds all CardDAV-specific properties
56
+     *
57
+     * @param PropFind $propFind
58
+     * @param INode $node
59
+     * @return void
60
+     */
61
+    public function propFind(PropFind $propFind, INode $node) {
62
+        $ns = '{http://nextcloud.com/ns}';
63 63
 
64
-		if ($node instanceof Card) {
65
-			$propFind->handle($ns . 'has-photo', function () use ($node) {
66
-				$vcard = Reader::read($node->get());
67
-				return $vcard instanceof VCard
68
-					&& $vcard->PHOTO
69
-					// Either the PHOTO is a url (doesn't start with data:) or the mimetype has to start with image/
70
-					&& (strpos($vcard->PHOTO->getValue(), 'data:') !== 0
71
-						|| strpos($vcard->PHOTO->getValue(), 'data:image/') === 0)
72
-				;
73
-			});
74
-		}
75
-	}
64
+        if ($node instanceof Card) {
65
+            $propFind->handle($ns . 'has-photo', function () use ($node) {
66
+                $vcard = Reader::read($node->get());
67
+                return $vcard instanceof VCard
68
+                    && $vcard->PHOTO
69
+                    // Either the PHOTO is a url (doesn't start with data:) or the mimetype has to start with image/
70
+                    && (strpos($vcard->PHOTO->getValue(), 'data:') !== 0
71
+                        || strpos($vcard->PHOTO->getValue(), 'data:image/') === 0)
72
+                ;
73
+            });
74
+        }
75
+    }
76 76
 
77
-	/**
78
-	 * Returns a plugin name.
79
-	 *
80
-	 * Using this name other plugins will be able to access other plugins
81
-	 * using \Sabre\DAV\Server::getPlugin
82
-	 *
83
-	 * @return string
84
-	 */
85
-	public function getPluginName() {
86
-		return 'vcard-has-photo';
87
-	}
77
+    /**
78
+     * Returns a plugin name.
79
+     *
80
+     * Using this name other plugins will be able to access other plugins
81
+     * using \Sabre\DAV\Server::getPlugin
82
+     *
83
+     * @return string
84
+     */
85
+    public function getPluginName() {
86
+        return 'vcard-has-photo';
87
+    }
88 88
 
89
-	/**
90
-	 * Returns a bunch of meta-data about the plugin.
91
-	 *
92
-	 * Providing this information is optional, and is mainly displayed by the
93
-	 * Browser plugin.
94
-	 *
95
-	 * The description key in the returned array may contain html and will not
96
-	 * be sanitized.
97
-	 *
98
-	 * @return array
99
-	 */
100
-	public function getPluginInfo() {
101
-		return [
102
-			'name' => $this->getPluginName(),
103
-			'description' => 'Return a boolean stating if the vcard have a photo property set or not.'
104
-		];
105
-	}
89
+    /**
90
+     * Returns a bunch of meta-data about the plugin.
91
+     *
92
+     * Providing this information is optional, and is mainly displayed by the
93
+     * Browser plugin.
94
+     *
95
+     * The description key in the returned array may contain html and will not
96
+     * be sanitized.
97
+     *
98
+     * @return array
99
+     */
100
+    public function getPluginInfo() {
101
+        return [
102
+            'name' => $this->getPluginName(),
103
+            'description' => 'Return a boolean stating if the vcard have a photo property set or not.'
104
+        ];
105
+    }
106 106
 }
Please login to merge, or discard this patch.
apps/files_versions/appinfo/routes.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,19 +30,19 @@
 block discarded – undo
30 30
 /** @var Application $application */
31 31
 $application = \OC::$server->query(Application::class);
32 32
 $application->registerRoutes($this, [
33
-	'routes' => [
34
-		[
35
-			'name' => 'Preview#getPreview',
36
-			'url' => '/preview',
37
-			'verb' => 'GET',
38
-		],
39
-	],
33
+    'routes' => [
34
+        [
35
+            'name' => 'Preview#getPreview',
36
+            'url' => '/preview',
37
+            'verb' => 'GET',
38
+        ],
39
+    ],
40 40
 ]);
41 41
 
42 42
 /** @var $this \OCP\Route\IRouter */
43 43
 $this->create('files_versions_download', 'apps/files_versions/download.php')
44
-	->actionInclude('files_versions/download.php');
44
+    ->actionInclude('files_versions/download.php');
45 45
 $this->create('files_versions_ajax_getVersions', 'apps/files_versions/ajax/getVersions.php')
46
-	->actionInclude('files_versions/ajax/getVersions.php');
46
+    ->actionInclude('files_versions/ajax/getVersions.php');
47 47
 $this->create('files_versions_ajax_rollbackVersion', 'apps/files_versions/ajax/rollbackVersion.php')
48
-	->actionInclude('files_versions/ajax/rollbackVersion.php');
48
+    ->actionInclude('files_versions/ajax/rollbackVersion.php');
Please login to merge, or discard this patch.
lib/public/AppFramework/AuthPublicShareController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@
 block discarded – undo
168 168
 		if (substr($class, -10) === 'Controller') {
169 169
 			$class = substr($class, 0, -10);
170 170
 		}
171
-		return $app .'.'. $class .'.'. $function;
171
+		return $app.'.'.$class.'.'.$function;
172 172
 	}
173 173
 
174 174
 	/**
Please login to merge, or discard this patch.
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -46,208 +46,208 @@
 block discarded – undo
46 46
  * @since 14.0.0
47 47
  */
48 48
 abstract class AuthPublicShareController extends PublicShareController {
49
-	/** @var IURLGenerator */
50
-	protected $urlGenerator;
51
-
52
-	/**
53
-	 * @since 14.0.0
54
-	 */
55
-	public function __construct(string $appName,
56
-								IRequest $request,
57
-								ISession $session,
58
-								IURLGenerator $urlGenerator) {
59
-		parent::__construct($appName, $request, $session);
60
-
61
-		$this->urlGenerator = $urlGenerator;
62
-	}
63
-
64
-	/**
65
-	 * @PublicPage
66
-	 * @NoCSRFRequired
67
-	 *
68
-	 * Show the authentication page
69
-	 * The form has to submit to the authenticate method route
70
-	 *
71
-	 * @since 14.0.0
72
-	 */
73
-	public function showAuthenticate(): TemplateResponse {
74
-		return new TemplateResponse('core', 'publicshareauth', [], 'guest');
75
-	}
76
-
77
-	/**
78
-	 * The template to show when authentication failed
79
-	 *
80
-	 * @since 14.0.0
81
-	 */
82
-	protected function showAuthFailed(): TemplateResponse {
83
-		return new TemplateResponse('core', 'publicshareauth', ['wrongpw' => true], 'guest');
84
-	}
85
-
86
-	/**
87
-	 * The template to show after user identification
88
-	 *
89
-	 * @since 24.0.0
90
-	 */
91
-	protected function showIdentificationResult(bool $success): TemplateResponse {
92
-		return new TemplateResponse('core', 'publicshareauth', ['identityOk' => $success], 'guest');
93
-	}
94
-
95
-	/**
96
-	 * Validates that the provided identity is allowed to receive a temporary password
97
-	 *
98
-	 * @since 24.0.0
99
-	 */
100
-	protected function validateIdentity(?string $identityToken = null): bool {
101
-		return false;
102
-	}
103
-
104
-	/**
105
-	 * Generates a password
106
-	 *
107
-	 * @since 24.0.0
108
-	 */
109
-	protected function generatePassword(): void {
110
-	}
111
-
112
-	/**
113
-	 * Verify the password
114
-	 *
115
-	 * @since 24.0.0
116
-	 */
117
-	protected function verifyPassword(string $password): bool {
118
-		return false;
119
-	}
120
-
121
-	/**
122
-	 * Function called after failed authentication
123
-	 *
124
-	 * You can use this to do some logging for example
125
-	 *
126
-	 * @since 14.0.0
127
-	 */
128
-	protected function authFailed() {
129
-	}
130
-
131
-	/**
132
-	 * Function called after successfull authentication
133
-	 *
134
-	 * You can use this to do some logging for example
135
-	 *
136
-	 * @since 14.0.0
137
-	 */
138
-	protected function authSucceeded() {
139
-	}
140
-
141
-	/**
142
-	 * @UseSession
143
-	 * @PublicPage
144
-	 * @BruteForceProtection(action=publicLinkAuth)
145
-	 *
146
-	 * Authenticate the share
147
-	 *
148
-	 * @since 14.0.0
149
-	 */
150
-	final public function authenticate(string $password = '', string $passwordRequest = 'no', string $identityToken = '') {
151
-		// Already authenticated
152
-		if ($this->isAuthenticated()) {
153
-			return $this->getRedirect();
154
-		}
155
-
156
-		// Is user requesting a temporary password?
157
-		if ($passwordRequest == '') {
158
-			if ($this->validateIdentity($identityToken)) {
159
-				$this->generatePassword();
160
-				$response = $this->showIdentificationResult(true);
161
-				return $response;
162
-			} else {
163
-				$response = $this->showIdentificationResult(false);
164
-				$response->throttle();
165
-				return $response;
166
-			}
167
-		}
168
-
169
-		if (!$this->verifyPassword($password)) {
170
-			$this->authFailed();
171
-			$response = $this->showAuthFailed();
172
-			$response->throttle();
173
-			return $response;
174
-		}
175
-
176
-		$this->session->regenerateId(true, true);
177
-		$response = $this->getRedirect();
178
-
179
-		$this->session->set('public_link_authenticated_token', $this->getToken());
180
-		$this->session->set('public_link_authenticated_password_hash', $this->getPasswordHash());
181
-
182
-		$this->authSucceeded();
183
-
184
-		return $response;
185
-	}
186
-
187
-	/**
188
-	 * Default landing page
189
-	 *
190
-	 * @since 14.0.0
191
-	 */
192
-	abstract public function showShare(): TemplateResponse;
193
-
194
-	/**
195
-	 * @since 14.0.0
196
-	 */
197
-	final public function getAuthenticationRedirect(string $redirect): RedirectResponse {
198
-		return new RedirectResponse(
199
-			$this->urlGenerator->linkToRoute($this->getRoute('showAuthenticate'), ['token' => $this->getToken(), 'redirect' => $redirect])
200
-		);
201
-	}
202
-
203
-
204
-	/**
205
-	 * @since 14.0.0
206
-	 */
207
-	private function getRoute(string $function): string {
208
-		$app = strtolower($this->appName);
209
-		$class = (new \ReflectionClass($this))->getShortName();
210
-		if (substr($class, -10) === 'Controller') {
211
-			$class = substr($class, 0, -10);
212
-		}
213
-		return $app .'.'. $class .'.'. $function;
214
-	}
215
-
216
-	/**
217
-	 * @since 14.0.0
218
-	 */
219
-	private function getRedirect(): RedirectResponse {
220
-		//Get all the stored redirect parameters:
221
-		$params = $this->session->get('public_link_authenticate_redirect');
222
-
223
-		$route = $this->getRoute('showShare');
224
-
225
-		if ($params === null) {
226
-			$params = [
227
-				'token' => $this->getToken(),
228
-			];
229
-		} else {
230
-			$params = json_decode($params, true);
231
-			if (isset($params['_route'])) {
232
-				$route = $params['_route'];
233
-				unset($params['_route']);
234
-			}
235
-
236
-			// If the token doesn't match the rest of the arguments can't be trusted either
237
-			if (isset($params['token']) && $params['token'] !== $this->getToken()) {
238
-				$params = [
239
-					'token' => $this->getToken(),
240
-				];
241
-			}
242
-
243
-			// We need a token
244
-			if (!isset($params['token'])) {
245
-				$params = [
246
-					'token' => $this->getToken(),
247
-				];
248
-			}
249
-		}
250
-
251
-		return new RedirectResponse($this->urlGenerator->linkToRoute($route, $params));
252
-	}
49
+    /** @var IURLGenerator */
50
+    protected $urlGenerator;
51
+
52
+    /**
53
+     * @since 14.0.0
54
+     */
55
+    public function __construct(string $appName,
56
+                                IRequest $request,
57
+                                ISession $session,
58
+                                IURLGenerator $urlGenerator) {
59
+        parent::__construct($appName, $request, $session);
60
+
61
+        $this->urlGenerator = $urlGenerator;
62
+    }
63
+
64
+    /**
65
+     * @PublicPage
66
+     * @NoCSRFRequired
67
+     *
68
+     * Show the authentication page
69
+     * The form has to submit to the authenticate method route
70
+     *
71
+     * @since 14.0.0
72
+     */
73
+    public function showAuthenticate(): TemplateResponse {
74
+        return new TemplateResponse('core', 'publicshareauth', [], 'guest');
75
+    }
76
+
77
+    /**
78
+     * The template to show when authentication failed
79
+     *
80
+     * @since 14.0.0
81
+     */
82
+    protected function showAuthFailed(): TemplateResponse {
83
+        return new TemplateResponse('core', 'publicshareauth', ['wrongpw' => true], 'guest');
84
+    }
85
+
86
+    /**
87
+     * The template to show after user identification
88
+     *
89
+     * @since 24.0.0
90
+     */
91
+    protected function showIdentificationResult(bool $success): TemplateResponse {
92
+        return new TemplateResponse('core', 'publicshareauth', ['identityOk' => $success], 'guest');
93
+    }
94
+
95
+    /**
96
+     * Validates that the provided identity is allowed to receive a temporary password
97
+     *
98
+     * @since 24.0.0
99
+     */
100
+    protected function validateIdentity(?string $identityToken = null): bool {
101
+        return false;
102
+    }
103
+
104
+    /**
105
+     * Generates a password
106
+     *
107
+     * @since 24.0.0
108
+     */
109
+    protected function generatePassword(): void {
110
+    }
111
+
112
+    /**
113
+     * Verify the password
114
+     *
115
+     * @since 24.0.0
116
+     */
117
+    protected function verifyPassword(string $password): bool {
118
+        return false;
119
+    }
120
+
121
+    /**
122
+     * Function called after failed authentication
123
+     *
124
+     * You can use this to do some logging for example
125
+     *
126
+     * @since 14.0.0
127
+     */
128
+    protected function authFailed() {
129
+    }
130
+
131
+    /**
132
+     * Function called after successfull authentication
133
+     *
134
+     * You can use this to do some logging for example
135
+     *
136
+     * @since 14.0.0
137
+     */
138
+    protected function authSucceeded() {
139
+    }
140
+
141
+    /**
142
+     * @UseSession
143
+     * @PublicPage
144
+     * @BruteForceProtection(action=publicLinkAuth)
145
+     *
146
+     * Authenticate the share
147
+     *
148
+     * @since 14.0.0
149
+     */
150
+    final public function authenticate(string $password = '', string $passwordRequest = 'no', string $identityToken = '') {
151
+        // Already authenticated
152
+        if ($this->isAuthenticated()) {
153
+            return $this->getRedirect();
154
+        }
155
+
156
+        // Is user requesting a temporary password?
157
+        if ($passwordRequest == '') {
158
+            if ($this->validateIdentity($identityToken)) {
159
+                $this->generatePassword();
160
+                $response = $this->showIdentificationResult(true);
161
+                return $response;
162
+            } else {
163
+                $response = $this->showIdentificationResult(false);
164
+                $response->throttle();
165
+                return $response;
166
+            }
167
+        }
168
+
169
+        if (!$this->verifyPassword($password)) {
170
+            $this->authFailed();
171
+            $response = $this->showAuthFailed();
172
+            $response->throttle();
173
+            return $response;
174
+        }
175
+
176
+        $this->session->regenerateId(true, true);
177
+        $response = $this->getRedirect();
178
+
179
+        $this->session->set('public_link_authenticated_token', $this->getToken());
180
+        $this->session->set('public_link_authenticated_password_hash', $this->getPasswordHash());
181
+
182
+        $this->authSucceeded();
183
+
184
+        return $response;
185
+    }
186
+
187
+    /**
188
+     * Default landing page
189
+     *
190
+     * @since 14.0.0
191
+     */
192
+    abstract public function showShare(): TemplateResponse;
193
+
194
+    /**
195
+     * @since 14.0.0
196
+     */
197
+    final public function getAuthenticationRedirect(string $redirect): RedirectResponse {
198
+        return new RedirectResponse(
199
+            $this->urlGenerator->linkToRoute($this->getRoute('showAuthenticate'), ['token' => $this->getToken(), 'redirect' => $redirect])
200
+        );
201
+    }
202
+
203
+
204
+    /**
205
+     * @since 14.0.0
206
+     */
207
+    private function getRoute(string $function): string {
208
+        $app = strtolower($this->appName);
209
+        $class = (new \ReflectionClass($this))->getShortName();
210
+        if (substr($class, -10) === 'Controller') {
211
+            $class = substr($class, 0, -10);
212
+        }
213
+        return $app .'.'. $class .'.'. $function;
214
+    }
215
+
216
+    /**
217
+     * @since 14.0.0
218
+     */
219
+    private function getRedirect(): RedirectResponse {
220
+        //Get all the stored redirect parameters:
221
+        $params = $this->session->get('public_link_authenticate_redirect');
222
+
223
+        $route = $this->getRoute('showShare');
224
+
225
+        if ($params === null) {
226
+            $params = [
227
+                'token' => $this->getToken(),
228
+            ];
229
+        } else {
230
+            $params = json_decode($params, true);
231
+            if (isset($params['_route'])) {
232
+                $route = $params['_route'];
233
+                unset($params['_route']);
234
+            }
235
+
236
+            // If the token doesn't match the rest of the arguments can't be trusted either
237
+            if (isset($params['token']) && $params['token'] !== $this->getToken()) {
238
+                $params = [
239
+                    'token' => $this->getToken(),
240
+                ];
241
+            }
242
+
243
+            // We need a token
244
+            if (!isset($params['token'])) {
245
+                $params = [
246
+                    'token' => $this->getToken(),
247
+                ];
248
+            }
249
+        }
250
+
251
+        return new RedirectResponse($this->urlGenerator->linkToRoute($route, $params));
252
+    }
253 253
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Mapping/UserMapping.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,6 +35,6 @@
 block discarded – undo
35 35
 	 */
36 36
 	protected function getTableName(bool $includePrefix = true) {
37 37
 		$p = $includePrefix ? '*PREFIX*' : '';
38
-		return $p . 'ldap_user_mapping';
38
+		return $p.'ldap_user_mapping';
39 39
 	}
40 40
 }
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -35,44 +35,44 @@
 block discarded – undo
35 35
  */
36 36
 class UserMapping extends AbstractMapping {
37 37
 
38
-	private IAssertion $assertion;
39
-	protected const PROV_API_REGEX = '/\/ocs\/v[1-9].php\/cloud\/(groups|users)/';
38
+    private IAssertion $assertion;
39
+    protected const PROV_API_REGEX = '/\/ocs\/v[1-9].php\/cloud\/(groups|users)/';
40 40
 
41
-	public function __construct(IDBConnection $dbc, IAssertion $assertion) {
42
-		$this->assertion = $assertion;
43
-		parent::__construct($dbc);
44
-	}
41
+    public function __construct(IDBConnection $dbc, IAssertion $assertion) {
42
+        $this->assertion = $assertion;
43
+        parent::__construct($dbc);
44
+    }
45 45
 
46
-	/**
47
-	 * @throws HintException
48
-	 */
49
-	public function map($fdn, $name, $uuid): bool {
50
-		try {
51
-			$this->assertion->createUserIsLegit();
52
-		} catch (HintException $e) {
53
-			static $isProvisioningApi = null;
46
+    /**
47
+     * @throws HintException
48
+     */
49
+    public function map($fdn, $name, $uuid): bool {
50
+        try {
51
+            $this->assertion->createUserIsLegit();
52
+        } catch (HintException $e) {
53
+            static $isProvisioningApi = null;
54 54
 
55
-			if ($isProvisioningApi === null) {
56
-				$request = Server::get(IRequest::class);
57
-				$isProvisioningApi = \preg_match(self::PROV_API_REGEX, $request->getRequestUri()) === 1;
58
-			}
59
-			if ($isProvisioningApi) {
60
-				// only throw when prov API is being used, since functionality
61
-				// should not break for end users (e.g. when sharing).
62
-				// On direct API usage, e.g. on users page, this is desired.
63
-				throw $e;
64
-			}
65
-			return false;
66
-		}
67
-		return parent::map($fdn, $name, $uuid);
68
-	}
55
+            if ($isProvisioningApi === null) {
56
+                $request = Server::get(IRequest::class);
57
+                $isProvisioningApi = \preg_match(self::PROV_API_REGEX, $request->getRequestUri()) === 1;
58
+            }
59
+            if ($isProvisioningApi) {
60
+                // only throw when prov API is being used, since functionality
61
+                // should not break for end users (e.g. when sharing).
62
+                // On direct API usage, e.g. on users page, this is desired.
63
+                throw $e;
64
+            }
65
+            return false;
66
+        }
67
+        return parent::map($fdn, $name, $uuid);
68
+    }
69 69
 
70
-	/**
71
-	 * returns the DB table name which holds the mappings
72
-	 * @return string
73
-	 */
74
-	protected function getTableName(bool $includePrefix = true) {
75
-		$p = $includePrefix ? '*PREFIX*' : '';
76
-		return $p . 'ldap_user_mapping';
77
-	}
70
+    /**
71
+     * returns the DB table name which holds the mappings
72
+     * @return string
73
+     */
74
+    protected function getTableName(bool $includePrefix = true) {
75
+        $p = $includePrefix ? '*PREFIX*' : '';
76
+        return $p . 'ldap_user_mapping';
77
+    }
78 78
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Mapping/GroupMapping.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
  */
30 30
 class GroupMapping extends AbstractMapping {
31 31
 
32
-	/**
33
-	 * returns the DB table name which holds the mappings
34
-	 * @return string
35
-	 */
36
-	protected function getTableName(bool $includePrefix = true) {
37
-		$p = $includePrefix ? '*PREFIX*' : '';
38
-		return $p . 'ldap_group_mapping';
39
-	}
32
+    /**
33
+     * returns the DB table name which holds the mappings
34
+     * @return string
35
+     */
36
+    protected function getTableName(bool $includePrefix = true) {
37
+        $p = $includePrefix ? '*PREFIX*' : '';
38
+        return $p . 'ldap_group_mapping';
39
+    }
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,6 +35,6 @@
 block discarded – undo
35 35
 	 */
36 36
 	protected function getTableName(bool $includePrefix = true) {
37 37
 		$p = $includePrefix ? '*PREFIX*' : '';
38
-		return $p . 'ldap_group_mapping';
38
+		return $p.'ldap_group_mapping';
39 39
 	}
40 40
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Proxy.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @return string
108 108
 	 */
109 109
 	protected function getUserCacheKey($uid) {
110
-		return 'user-' . $uid . '-lastSeenOn';
110
+		return 'user-'.$uid.'-lastSeenOn';
111 111
 	}
112 112
 
113 113
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @return string
116 116
 	 */
117 117
 	protected function getGroupCacheKey($gid) {
118
-		return 'group-' . $gid . '-lastSeenOn';
118
+		return 'group-'.$gid.'-lastSeenOn';
119 119
 	}
120 120
 
121 121
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		if ($key === null) {
179 179
 			return $prefix;
180 180
 		}
181
-		return $prefix . hash('sha256', $key);
181
+		return $prefix.hash('sha256', $key);
182 182
 	}
183 183
 
184 184
 	/**
Please login to merge, or discard this patch.
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -38,157 +38,157 @@
 block discarded – undo
38 38
 use OCP\Server;
39 39
 
40 40
 abstract class Proxy {
41
-	/** @var array<string,Access> */
42
-	private static array $accesses = [];
43
-	private ILDAPWrapper $ldap;
44
-	private ?bool $isSingleBackend = null;
45
-	private ?ICache $cache = null;
46
-	private AccessFactory $accessFactory;
47
-
48
-	public function __construct(
49
-		ILDAPWrapper $ldap,
50
-		AccessFactory $accessFactory
51
-	) {
52
-		$this->ldap = $ldap;
53
-		$this->accessFactory = $accessFactory;
54
-		$memcache = \OC::$server->getMemCacheFactory();
55
-		if ($memcache->isAvailable()) {
56
-			$this->cache = $memcache->createDistributed();
57
-		}
58
-	}
59
-
60
-	private function addAccess(string $configPrefix): void {
61
-		$userMap = Server::get(UserMapping::class);
62
-		$groupMap = Server::get(GroupMapping::class);
63
-
64
-		$connector = new Connection($this->ldap, $configPrefix);
65
-		$access = $this->accessFactory->get($connector);
66
-		$access->setUserMapper($userMap);
67
-		$access->setGroupMapper($groupMap);
68
-		self::$accesses[$configPrefix] = $access;
69
-	}
70
-
71
-	protected function getAccess(string $configPrefix): Access {
72
-		if (!isset(self::$accesses[$configPrefix])) {
73
-			$this->addAccess($configPrefix);
74
-		}
75
-		return self::$accesses[$configPrefix];
76
-	}
77
-
78
-	/**
79
-	 * @param string $uid
80
-	 * @return string
81
-	 */
82
-	protected function getUserCacheKey($uid) {
83
-		return 'user-' . $uid . '-lastSeenOn';
84
-	}
85
-
86
-	/**
87
-	 * @param string $gid
88
-	 * @return string
89
-	 */
90
-	protected function getGroupCacheKey($gid) {
91
-		return 'group-' . $gid . '-lastSeenOn';
92
-	}
93
-
94
-	/**
95
-	 * @param string $id
96
-	 * @param string $method
97
-	 * @param array $parameters
98
-	 * @param bool $passOnWhen
99
-	 * @return mixed
100
-	 */
101
-	abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
102
-
103
-	/**
104
-	 * @param string $id
105
-	 * @param string $method
106
-	 * @param array $parameters
107
-	 * @return mixed
108
-	 */
109
-	abstract protected function walkBackends($id, $method, $parameters);
110
-
111
-	/**
112
-	 * @param string $id
113
-	 * @return Access
114
-	 */
115
-	abstract public function getLDAPAccess($id);
116
-
117
-	abstract protected function activeBackends(): int;
118
-
119
-	protected function isSingleBackend(): bool {
120
-		if ($this->isSingleBackend === null) {
121
-			$this->isSingleBackend = $this->activeBackends() === 1;
122
-		}
123
-		return $this->isSingleBackend;
124
-	}
125
-
126
-	/**
127
-	 * Takes care of the request to the User backend
128
-	 *
129
-	 * @param string $id
130
-	 * @param string $method string, the method of the user backend that shall be called
131
-	 * @param array $parameters an array of parameters to be passed
132
-	 * @param bool $passOnWhen
133
-	 * @return mixed, the result of the specified method
134
-	 */
135
-	protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
136
-		if (!$this->isSingleBackend()) {
137
-			$result = $this->callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
138
-		}
139
-		if (!isset($result) || $result === $passOnWhen) {
140
-			$result = $this->walkBackends($id, $method, $parameters);
141
-		}
142
-		return $result;
143
-	}
144
-
145
-	/**
146
-	 * @param string|null $key
147
-	 * @return string
148
-	 */
149
-	private function getCacheKey($key) {
150
-		$prefix = 'LDAP-Proxy-';
151
-		if ($key === null) {
152
-			return $prefix;
153
-		}
154
-		return $prefix . hash('sha256', $key);
155
-	}
156
-
157
-	/**
158
-	 * @param string $key
159
-	 * @return mixed|null
160
-	 */
161
-	public function getFromCache($key) {
162
-		if ($this->cache === null) {
163
-			return null;
164
-		}
165
-
166
-		$key = $this->getCacheKey($key);
167
-		$value = $this->cache->get($key);
168
-		if ($value === null) {
169
-			return null;
170
-		}
171
-
172
-		return json_decode(base64_decode($value));
173
-	}
174
-
175
-	/**
176
-	 * @param string $key
177
-	 * @param mixed $value
178
-	 */
179
-	public function writeToCache($key, $value) {
180
-		if ($this->cache === null) {
181
-			return;
182
-		}
183
-		$key = $this->getCacheKey($key);
184
-		$value = base64_encode(json_encode($value));
185
-		$this->cache->set($key, $value, 2592000);
186
-	}
187
-
188
-	public function clearCache() {
189
-		if ($this->cache === null) {
190
-			return;
191
-		}
192
-		$this->cache->clear($this->getCacheKey(null));
193
-	}
41
+    /** @var array<string,Access> */
42
+    private static array $accesses = [];
43
+    private ILDAPWrapper $ldap;
44
+    private ?bool $isSingleBackend = null;
45
+    private ?ICache $cache = null;
46
+    private AccessFactory $accessFactory;
47
+
48
+    public function __construct(
49
+        ILDAPWrapper $ldap,
50
+        AccessFactory $accessFactory
51
+    ) {
52
+        $this->ldap = $ldap;
53
+        $this->accessFactory = $accessFactory;
54
+        $memcache = \OC::$server->getMemCacheFactory();
55
+        if ($memcache->isAvailable()) {
56
+            $this->cache = $memcache->createDistributed();
57
+        }
58
+    }
59
+
60
+    private function addAccess(string $configPrefix): void {
61
+        $userMap = Server::get(UserMapping::class);
62
+        $groupMap = Server::get(GroupMapping::class);
63
+
64
+        $connector = new Connection($this->ldap, $configPrefix);
65
+        $access = $this->accessFactory->get($connector);
66
+        $access->setUserMapper($userMap);
67
+        $access->setGroupMapper($groupMap);
68
+        self::$accesses[$configPrefix] = $access;
69
+    }
70
+
71
+    protected function getAccess(string $configPrefix): Access {
72
+        if (!isset(self::$accesses[$configPrefix])) {
73
+            $this->addAccess($configPrefix);
74
+        }
75
+        return self::$accesses[$configPrefix];
76
+    }
77
+
78
+    /**
79
+     * @param string $uid
80
+     * @return string
81
+     */
82
+    protected function getUserCacheKey($uid) {
83
+        return 'user-' . $uid . '-lastSeenOn';
84
+    }
85
+
86
+    /**
87
+     * @param string $gid
88
+     * @return string
89
+     */
90
+    protected function getGroupCacheKey($gid) {
91
+        return 'group-' . $gid . '-lastSeenOn';
92
+    }
93
+
94
+    /**
95
+     * @param string $id
96
+     * @param string $method
97
+     * @param array $parameters
98
+     * @param bool $passOnWhen
99
+     * @return mixed
100
+     */
101
+    abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
102
+
103
+    /**
104
+     * @param string $id
105
+     * @param string $method
106
+     * @param array $parameters
107
+     * @return mixed
108
+     */
109
+    abstract protected function walkBackends($id, $method, $parameters);
110
+
111
+    /**
112
+     * @param string $id
113
+     * @return Access
114
+     */
115
+    abstract public function getLDAPAccess($id);
116
+
117
+    abstract protected function activeBackends(): int;
118
+
119
+    protected function isSingleBackend(): bool {
120
+        if ($this->isSingleBackend === null) {
121
+            $this->isSingleBackend = $this->activeBackends() === 1;
122
+        }
123
+        return $this->isSingleBackend;
124
+    }
125
+
126
+    /**
127
+     * Takes care of the request to the User backend
128
+     *
129
+     * @param string $id
130
+     * @param string $method string, the method of the user backend that shall be called
131
+     * @param array $parameters an array of parameters to be passed
132
+     * @param bool $passOnWhen
133
+     * @return mixed, the result of the specified method
134
+     */
135
+    protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
136
+        if (!$this->isSingleBackend()) {
137
+            $result = $this->callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
138
+        }
139
+        if (!isset($result) || $result === $passOnWhen) {
140
+            $result = $this->walkBackends($id, $method, $parameters);
141
+        }
142
+        return $result;
143
+    }
144
+
145
+    /**
146
+     * @param string|null $key
147
+     * @return string
148
+     */
149
+    private function getCacheKey($key) {
150
+        $prefix = 'LDAP-Proxy-';
151
+        if ($key === null) {
152
+            return $prefix;
153
+        }
154
+        return $prefix . hash('sha256', $key);
155
+    }
156
+
157
+    /**
158
+     * @param string $key
159
+     * @return mixed|null
160
+     */
161
+    public function getFromCache($key) {
162
+        if ($this->cache === null) {
163
+            return null;
164
+        }
165
+
166
+        $key = $this->getCacheKey($key);
167
+        $value = $this->cache->get($key);
168
+        if ($value === null) {
169
+            return null;
170
+        }
171
+
172
+        return json_decode(base64_decode($value));
173
+    }
174
+
175
+    /**
176
+     * @param string $key
177
+     * @param mixed $value
178
+     */
179
+    public function writeToCache($key, $value) {
180
+        if ($this->cache === null) {
181
+            return;
182
+        }
183
+        $key = $this->getCacheKey($key);
184
+        $value = base64_encode(json_encode($value));
185
+        $this->cache->set($key, $value, 2592000);
186
+    }
187
+
188
+    public function clearCache() {
189
+        if ($this->cache === null) {
190
+            return;
191
+        }
192
+        $this->cache->clear($this->getCacheKey(null));
193
+    }
194 194
 }
Please login to merge, or discard this patch.