Passed
Push — master ( dd9428...b40603 )
by Roeland
18:23 queued 08:05
created
settings/Controller/AuthSettingsController.php 2 patches
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -47,234 +47,234 @@
 block discarded – undo
47 47
 
48 48
 class AuthSettingsController extends Controller {
49 49
 
50
-	/** @var IProvider */
51
-	private $tokenProvider;
50
+    /** @var IProvider */
51
+    private $tokenProvider;
52 52
 
53
-	/** @var ISession */
54
-	private $session;
53
+    /** @var ISession */
54
+    private $session;
55 55
 
56
-	/** @var string */
57
-	private $uid;
56
+    /** @var string */
57
+    private $uid;
58 58
 
59
-	/** @var ISecureRandom */
60
-	private $random;
59
+    /** @var ISecureRandom */
60
+    private $random;
61 61
 
62
-	/** @var IManager */
63
-	private $activityManager;
62
+    /** @var IManager */
63
+    private $activityManager;
64 64
 
65
-	/** @var ILogger */
66
-	private $logger;
65
+    /** @var ILogger */
66
+    private $logger;
67 67
 
68
-	/**
69
-	 * @param string $appName
70
-	 * @param IRequest $request
71
-	 * @param IProvider $tokenProvider
72
-	 * @param ISession $session
73
-	 * @param ISecureRandom $random
74
-	 * @param string|null $userId
75
-	 * @param IManager $activityManager
76
-	 * @param ILogger $logger
77
-	 */
78
-	public function __construct(string $appName,
79
-								IRequest $request,
80
-								IProvider $tokenProvider,
81
-								ISession $session,
82
-								ISecureRandom $random,
83
-								?string $userId,
84
-								IManager $activityManager,
85
-								ILogger $logger) {
86
-		parent::__construct($appName, $request);
87
-		$this->tokenProvider = $tokenProvider;
88
-		$this->uid = $userId;
89
-		$this->session = $session;
90
-		$this->random = $random;
91
-		$this->activityManager = $activityManager;
92
-		$this->logger = $logger;
93
-	}
68
+    /**
69
+     * @param string $appName
70
+     * @param IRequest $request
71
+     * @param IProvider $tokenProvider
72
+     * @param ISession $session
73
+     * @param ISecureRandom $random
74
+     * @param string|null $userId
75
+     * @param IManager $activityManager
76
+     * @param ILogger $logger
77
+     */
78
+    public function __construct(string $appName,
79
+                                IRequest $request,
80
+                                IProvider $tokenProvider,
81
+                                ISession $session,
82
+                                ISecureRandom $random,
83
+                                ?string $userId,
84
+                                IManager $activityManager,
85
+                                ILogger $logger) {
86
+        parent::__construct($appName, $request);
87
+        $this->tokenProvider = $tokenProvider;
88
+        $this->uid = $userId;
89
+        $this->session = $session;
90
+        $this->random = $random;
91
+        $this->activityManager = $activityManager;
92
+        $this->logger = $logger;
93
+    }
94 94
 
95
-	/**
96
-	 * @NoAdminRequired
97
-	 * @NoSubadminRequired
98
-	 *
99
-	 * @return JSONResponse|array
100
-	 */
101
-	public function index() {
102
-		$tokens = $this->tokenProvider->getTokenByUser($this->uid);
95
+    /**
96
+     * @NoAdminRequired
97
+     * @NoSubadminRequired
98
+     *
99
+     * @return JSONResponse|array
100
+     */
101
+    public function index() {
102
+        $tokens = $this->tokenProvider->getTokenByUser($this->uid);
103 103
 
104
-		try {
105
-			$sessionId = $this->session->getId();
106
-		} catch (SessionNotAvailableException $ex) {
107
-			return $this->getServiceNotAvailableResponse();
108
-		}
109
-		try {
110
-			$sessionToken = $this->tokenProvider->getToken($sessionId);
111
-		} catch (InvalidTokenException $ex) {
112
-			return $this->getServiceNotAvailableResponse();
113
-		}
104
+        try {
105
+            $sessionId = $this->session->getId();
106
+        } catch (SessionNotAvailableException $ex) {
107
+            return $this->getServiceNotAvailableResponse();
108
+        }
109
+        try {
110
+            $sessionToken = $this->tokenProvider->getToken($sessionId);
111
+        } catch (InvalidTokenException $ex) {
112
+            return $this->getServiceNotAvailableResponse();
113
+        }
114 114
 
115
-		return array_map(function (IToken $token) use ($sessionToken) {
116
-			$data = $token->jsonSerialize();
117
-			$data['canDelete'] = true;
118
-			$data['canRename'] = $token instanceof INamedToken;
119
-			if ($sessionToken->getId() === $token->getId()) {
120
-				$data['canDelete'] = false;
121
-				$data['canRename'] = false;
122
-				$data['current'] = true;
123
-			}
124
-			return $data;
125
-		}, $tokens);
126
-	}
115
+        return array_map(function (IToken $token) use ($sessionToken) {
116
+            $data = $token->jsonSerialize();
117
+            $data['canDelete'] = true;
118
+            $data['canRename'] = $token instanceof INamedToken;
119
+            if ($sessionToken->getId() === $token->getId()) {
120
+                $data['canDelete'] = false;
121
+                $data['canRename'] = false;
122
+                $data['current'] = true;
123
+            }
124
+            return $data;
125
+        }, $tokens);
126
+    }
127 127
 
128
-	/**
129
-	 * @NoAdminRequired
130
-	 * @NoSubadminRequired
131
-	 * @PasswordConfirmationRequired
132
-	 *
133
-	 * @param string $name
134
-	 * @return JSONResponse
135
-	 */
136
-	public function create($name) {
137
-		try {
138
-			$sessionId = $this->session->getId();
139
-		} catch (SessionNotAvailableException $ex) {
140
-			return $this->getServiceNotAvailableResponse();
141
-		}
128
+    /**
129
+     * @NoAdminRequired
130
+     * @NoSubadminRequired
131
+     * @PasswordConfirmationRequired
132
+     *
133
+     * @param string $name
134
+     * @return JSONResponse
135
+     */
136
+    public function create($name) {
137
+        try {
138
+            $sessionId = $this->session->getId();
139
+        } catch (SessionNotAvailableException $ex) {
140
+            return $this->getServiceNotAvailableResponse();
141
+        }
142 142
 
143
-		try {
144
-			$sessionToken = $this->tokenProvider->getToken($sessionId);
145
-			$loginName = $sessionToken->getLoginName();
146
-			try {
147
-				$password = $this->tokenProvider->getPassword($sessionToken, $sessionId);
148
-			} catch (PasswordlessTokenException $ex) {
149
-				$password = null;
150
-			}
151
-		} catch (InvalidTokenException $ex) {
152
-			return $this->getServiceNotAvailableResponse();
153
-		}
143
+        try {
144
+            $sessionToken = $this->tokenProvider->getToken($sessionId);
145
+            $loginName = $sessionToken->getLoginName();
146
+            try {
147
+                $password = $this->tokenProvider->getPassword($sessionToken, $sessionId);
148
+            } catch (PasswordlessTokenException $ex) {
149
+                $password = null;
150
+            }
151
+        } catch (InvalidTokenException $ex) {
152
+            return $this->getServiceNotAvailableResponse();
153
+        }
154 154
 
155
-		$token = $this->generateRandomDeviceToken();
156
-		$deviceToken = $this->tokenProvider->generateToken($token, $this->uid, $loginName, $password, $name, IToken::PERMANENT_TOKEN);
157
-		$tokenData = $deviceToken->jsonSerialize();
158
-		$tokenData['canDelete'] = true;
159
-		$tokenData['canRename'] = true;
155
+        $token = $this->generateRandomDeviceToken();
156
+        $deviceToken = $this->tokenProvider->generateToken($token, $this->uid, $loginName, $password, $name, IToken::PERMANENT_TOKEN);
157
+        $tokenData = $deviceToken->jsonSerialize();
158
+        $tokenData['canDelete'] = true;
159
+        $tokenData['canRename'] = true;
160 160
 
161
-		$this->publishActivity(Provider::APP_TOKEN_CREATED, $deviceToken->getId(), $deviceToken->getName());
161
+        $this->publishActivity(Provider::APP_TOKEN_CREATED, $deviceToken->getId(), $deviceToken->getName());
162 162
 
163
-		return new JSONResponse([
164
-			'token' => $token,
165
-			'loginName' => $loginName,
166
-			'deviceToken' => $tokenData,
167
-		]);
168
-	}
163
+        return new JSONResponse([
164
+            'token' => $token,
165
+            'loginName' => $loginName,
166
+            'deviceToken' => $tokenData,
167
+        ]);
168
+    }
169 169
 
170
-	/**
171
-	 * @return JSONResponse
172
-	 */
173
-	private function getServiceNotAvailableResponse() {
174
-		$resp = new JSONResponse();
175
-		$resp->setStatus(Http::STATUS_SERVICE_UNAVAILABLE);
176
-		return $resp;
177
-	}
170
+    /**
171
+     * @return JSONResponse
172
+     */
173
+    private function getServiceNotAvailableResponse() {
174
+        $resp = new JSONResponse();
175
+        $resp->setStatus(Http::STATUS_SERVICE_UNAVAILABLE);
176
+        return $resp;
177
+    }
178 178
 
179
-	/**
180
-	 * Return a 25 digit device password
181
-	 *
182
-	 * Example: AbCdE-fGhJk-MnPqR-sTwXy-23456
183
-	 *
184
-	 * @return string
185
-	 */
186
-	private function generateRandomDeviceToken() {
187
-		$groups = [];
188
-		for ($i = 0; $i < 5; $i++) {
189
-			$groups[] = $this->random->generate(5, ISecureRandom::CHAR_HUMAN_READABLE);
190
-		}
191
-		return implode('-', $groups);
192
-	}
179
+    /**
180
+     * Return a 25 digit device password
181
+     *
182
+     * Example: AbCdE-fGhJk-MnPqR-sTwXy-23456
183
+     *
184
+     * @return string
185
+     */
186
+    private function generateRandomDeviceToken() {
187
+        $groups = [];
188
+        for ($i = 0; $i < 5; $i++) {
189
+            $groups[] = $this->random->generate(5, ISecureRandom::CHAR_HUMAN_READABLE);
190
+        }
191
+        return implode('-', $groups);
192
+    }
193 193
 
194
-	/**
195
-	 * @NoAdminRequired
196
-	 * @NoSubadminRequired
197
-	 *
198
-	 * @param int $id
199
-	 * @return array|JSONResponse
200
-	 */
201
-	public function destroy($id) {
202
-		try {
203
-			$token = $this->findTokenByIdAndUser($id);
204
-		} catch (InvalidTokenException $e) {
205
-			return new JSONResponse([], Http::STATUS_NOT_FOUND);
206
-		}
194
+    /**
195
+     * @NoAdminRequired
196
+     * @NoSubadminRequired
197
+     *
198
+     * @param int $id
199
+     * @return array|JSONResponse
200
+     */
201
+    public function destroy($id) {
202
+        try {
203
+            $token = $this->findTokenByIdAndUser($id);
204
+        } catch (InvalidTokenException $e) {
205
+            return new JSONResponse([], Http::STATUS_NOT_FOUND);
206
+        }
207 207
 
208
-		$this->tokenProvider->invalidateTokenById($this->uid, $token->getId());
209
-		$this->publishActivity(Provider::APP_TOKEN_DELETED, $token->getId(), $token->getName());
210
-		return [];
211
-	}
208
+        $this->tokenProvider->invalidateTokenById($this->uid, $token->getId());
209
+        $this->publishActivity(Provider::APP_TOKEN_DELETED, $token->getId(), $token->getName());
210
+        return [];
211
+    }
212 212
 
213
-	/**
214
-	 * @NoAdminRequired
215
-	 * @NoSubadminRequired
216
-	 *
217
-	 * @param int $id
218
-	 * @param array $scope
219
-	 * @param string $name
220
-	 * @return array|JSONResponse
221
-	 */
222
-	public function update($id, array $scope, string $name) {
223
-		try {
224
-			$token = $this->findTokenByIdAndUser($id);
225
-		} catch (InvalidTokenException $e) {
226
-			return new JSONResponse([], Http::STATUS_NOT_FOUND);
227
-		}
213
+    /**
214
+     * @NoAdminRequired
215
+     * @NoSubadminRequired
216
+     *
217
+     * @param int $id
218
+     * @param array $scope
219
+     * @param string $name
220
+     * @return array|JSONResponse
221
+     */
222
+    public function update($id, array $scope, string $name) {
223
+        try {
224
+            $token = $this->findTokenByIdAndUser($id);
225
+        } catch (InvalidTokenException $e) {
226
+            return new JSONResponse([], Http::STATUS_NOT_FOUND);
227
+        }
228 228
 
229
-		$token->setScope([
230
-			'filesystem' => $scope['filesystem']
231
-		]);
229
+        $token->setScope([
230
+            'filesystem' => $scope['filesystem']
231
+        ]);
232 232
 
233 233
 
234
-		if ($token instanceof INamedToken) {
235
-			$token->setName($name);
236
-		}
234
+        if ($token instanceof INamedToken) {
235
+            $token->setName($name);
236
+        }
237 237
 
238
-		$this->tokenProvider->updateToken($token);
239
-		$this->publishActivity(Provider::APP_TOKEN_UPDATED, $token->getId(), $token->getName());
240
-		return [];
241
-	}
238
+        $this->tokenProvider->updateToken($token);
239
+        $this->publishActivity(Provider::APP_TOKEN_UPDATED, $token->getId(), $token->getName());
240
+        return [];
241
+    }
242 242
 
243
-	/**
244
-	 * @param string $subject
245
-	 * @param int $id
246
-	 * @param string|null $tokenName
247
-	 */
248
-	private function publishActivity(string $subject, int $id, ?string $tokenName = null): void {
249
-		$event = $this->activityManager->generateEvent();
250
-		$event->setApp('settings')
251
-			->setType('security')
252
-			->setAffectedUser($this->uid)
253
-			->setAuthor($this->uid)
254
-			->setSubject($subject, [$tokenName])
255
-			->setObject('app_token', $id, 'App Password');
243
+    /**
244
+     * @param string $subject
245
+     * @param int $id
246
+     * @param string|null $tokenName
247
+     */
248
+    private function publishActivity(string $subject, int $id, ?string $tokenName = null): void {
249
+        $event = $this->activityManager->generateEvent();
250
+        $event->setApp('settings')
251
+            ->setType('security')
252
+            ->setAffectedUser($this->uid)
253
+            ->setAuthor($this->uid)
254
+            ->setSubject($subject, [$tokenName])
255
+            ->setObject('app_token', $id, 'App Password');
256 256
 
257
-		try {
258
-			$this->activityManager->publish($event);
259
-		} catch (BadMethodCallException $e) {
260
-			$this->logger->warning('could not publish activity');
261
-			$this->logger->logException($e);
262
-		}
263
-	}
257
+        try {
258
+            $this->activityManager->publish($event);
259
+        } catch (BadMethodCallException $e) {
260
+            $this->logger->warning('could not publish activity');
261
+            $this->logger->logException($e);
262
+        }
263
+    }
264 264
 
265
-	/**
266
-	 * Find a token by given id and check if uid for current session belongs to this token
267
-	 *
268
-	 * @param int $id
269
-	 * @return IToken
270
-	 * @throws InvalidTokenException
271
-	 * @throws \OC\Authentication\Exceptions\ExpiredTokenException
272
-	 */
273
-	private function findTokenByIdAndUser(int $id): IToken {
274
-		$token = $this->tokenProvider->getTokenById($id);
275
-		if ($token->getUID() !== $this->uid) {
276
-			throw new InvalidTokenException('This token does not belong to you!');
277
-		}
278
-		return $token;
279
-	}
265
+    /**
266
+     * Find a token by given id and check if uid for current session belongs to this token
267
+     *
268
+     * @param int $id
269
+     * @return IToken
270
+     * @throws InvalidTokenException
271
+     * @throws \OC\Authentication\Exceptions\ExpiredTokenException
272
+     */
273
+    private function findTokenByIdAndUser(int $id): IToken {
274
+        $token = $this->tokenProvider->getTokenById($id);
275
+        if ($token->getUID() !== $this->uid) {
276
+            throw new InvalidTokenException('This token does not belong to you!');
277
+        }
278
+        return $token;
279
+    }
280 280
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@
 block discarded – undo
112 112
 			return $this->getServiceNotAvailableResponse();
113 113
 		}
114 114
 
115
-		return array_map(function (IToken $token) use ($sessionToken) {
115
+		return array_map(function(IToken $token) use ($sessionToken) {
116 116
 			$data = $token->jsonSerialize();
117 117
 			$data['canDelete'] = true;
118 118
 			$data['canRename'] = $token instanceof INamedToken;
Please login to merge, or discard this patch.
lib/private/Authentication/Token/DefaultToken.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -40,168 +40,168 @@
 block discarded – undo
40 40
  */
41 41
 class DefaultToken extends Entity implements INamedToken {
42 42
 
43
-	const VERSION = 1;
44
-
45
-	/** @var string user UID */
46
-	protected $uid;
47
-
48
-	/** @var string login name used for generating the token */
49
-	protected $loginName;
50
-
51
-	/** @var string encrypted user password */
52
-	protected $password;
53
-
54
-	/** @var string token name (e.g. browser/OS) */
55
-	protected $name;
56
-
57
-	/** @var string */
58
-	protected $token;
59
-
60
-	/** @var int */
61
-	protected $type;
62
-
63
-	/** @var int */
64
-	protected $remember;
65
-
66
-	/** @var int */
67
-	protected $lastActivity;
68
-
69
-	/** @var int */
70
-	protected $lastCheck;
71
-
72
-	/** @var string */
73
-	protected $scope;
74
-
75
-	/** @var int */
76
-	protected $expires;
77
-
78
-	/** @var int */
79
-	protected $version;
80
-
81
-	public function __construct() {
82
-		$this->addType('uid', 'string');
83
-		$this->addType('loginName', 'string');
84
-		$this->addType('password', 'string');
85
-		$this->addType('name', 'string');
86
-		$this->addType('token', 'string');
87
-		$this->addType('type', 'int');
88
-		$this->addType('remember', 'int');
89
-		$this->addType('lastActivity', 'int');
90
-		$this->addType('lastCheck', 'int');
91
-		$this->addType('scope', 'string');
92
-		$this->addType('expires', 'int');
93
-		$this->addType('version', 'int');
94
-	}
95
-
96
-	public function getId(): int {
97
-		return $this->id;
98
-	}
99
-
100
-	public function getUID(): string {
101
-		return $this->uid;
102
-	}
103
-
104
-	/**
105
-	 * Get the login name used when generating the token
106
-	 *
107
-	 * @return string
108
-	 */
109
-	public function getLoginName(): string {
110
-		return parent::getLoginName();
111
-	}
112
-
113
-	/**
114
-	 * Get the (encrypted) login password
115
-	 *
116
-	 * @return string|null
117
-	 */
118
-	public function getPassword() {
119
-		return parent::getPassword();
120
-	}
121
-
122
-	public function jsonSerialize() {
123
-		return [
124
-			'id' => $this->id,
125
-			'name' => $this->name,
126
-			'lastActivity' => $this->lastActivity,
127
-			'type' => $this->type,
128
-			'scope' => $this->getScopeAsArray()
129
-		];
130
-	}
131
-
132
-	/**
133
-	 * Get the timestamp of the last password check
134
-	 *
135
-	 * @return int
136
-	 */
137
-	public function getLastCheck(): int {
138
-		return parent::getLastCheck();
139
-	}
140
-
141
-	/**
142
-	 * Get the timestamp of the last password check
143
-	 *
144
-	 * @param int $time
145
-	 */
146
-	public function setLastCheck(int $time) {
147
-		parent::setLastCheck($time);
148
-	}
149
-
150
-	public function getScope(): string {
151
-		$scope = parent::getScope();
152
-		if ($scope === null) {
153
-			return '';
154
-		}
155
-
156
-		return $scope;
157
-	}
158
-
159
-	public function getScopeAsArray(): array {
160
-		$scope = json_decode($this->getScope(), true);
161
-		if (!$scope) {
162
-			return [
163
-				'filesystem'=> true
164
-			];
165
-		}
166
-		return $scope;
167
-	}
168
-
169
-	public function setScope($scope) {
170
-		if (\is_array($scope)) {
171
-			parent::setScope(json_encode($scope));
172
-		} else {
173
-			parent::setScope((string)$scope);
174
-		}
175
-	}
176
-
177
-	public function getName(): string {
178
-		return parent::getName();
179
-	}
180
-
181
-	public function setName(string $name): void {
182
-		parent::setName($name);
183
-	}
184
-
185
-	public function getRemember(): int {
186
-		return parent::getRemember();
187
-	}
188
-
189
-	public function setToken(string $token) {
190
-		parent::setToken($token);
191
-	}
192
-
193
-	public function setPassword(string $password = null) {
194
-		parent::setPassword($password);
195
-	}
196
-
197
-	public function setExpires($expires) {
198
-		parent::setExpires($expires);
199
-	}
200
-
201
-	/**
202
-	 * @return int|null
203
-	 */
204
-	public function getExpires() {
205
-		return parent::getExpires();
206
-	}
43
+    const VERSION = 1;
44
+
45
+    /** @var string user UID */
46
+    protected $uid;
47
+
48
+    /** @var string login name used for generating the token */
49
+    protected $loginName;
50
+
51
+    /** @var string encrypted user password */
52
+    protected $password;
53
+
54
+    /** @var string token name (e.g. browser/OS) */
55
+    protected $name;
56
+
57
+    /** @var string */
58
+    protected $token;
59
+
60
+    /** @var int */
61
+    protected $type;
62
+
63
+    /** @var int */
64
+    protected $remember;
65
+
66
+    /** @var int */
67
+    protected $lastActivity;
68
+
69
+    /** @var int */
70
+    protected $lastCheck;
71
+
72
+    /** @var string */
73
+    protected $scope;
74
+
75
+    /** @var int */
76
+    protected $expires;
77
+
78
+    /** @var int */
79
+    protected $version;
80
+
81
+    public function __construct() {
82
+        $this->addType('uid', 'string');
83
+        $this->addType('loginName', 'string');
84
+        $this->addType('password', 'string');
85
+        $this->addType('name', 'string');
86
+        $this->addType('token', 'string');
87
+        $this->addType('type', 'int');
88
+        $this->addType('remember', 'int');
89
+        $this->addType('lastActivity', 'int');
90
+        $this->addType('lastCheck', 'int');
91
+        $this->addType('scope', 'string');
92
+        $this->addType('expires', 'int');
93
+        $this->addType('version', 'int');
94
+    }
95
+
96
+    public function getId(): int {
97
+        return $this->id;
98
+    }
99
+
100
+    public function getUID(): string {
101
+        return $this->uid;
102
+    }
103
+
104
+    /**
105
+     * Get the login name used when generating the token
106
+     *
107
+     * @return string
108
+     */
109
+    public function getLoginName(): string {
110
+        return parent::getLoginName();
111
+    }
112
+
113
+    /**
114
+     * Get the (encrypted) login password
115
+     *
116
+     * @return string|null
117
+     */
118
+    public function getPassword() {
119
+        return parent::getPassword();
120
+    }
121
+
122
+    public function jsonSerialize() {
123
+        return [
124
+            'id' => $this->id,
125
+            'name' => $this->name,
126
+            'lastActivity' => $this->lastActivity,
127
+            'type' => $this->type,
128
+            'scope' => $this->getScopeAsArray()
129
+        ];
130
+    }
131
+
132
+    /**
133
+     * Get the timestamp of the last password check
134
+     *
135
+     * @return int
136
+     */
137
+    public function getLastCheck(): int {
138
+        return parent::getLastCheck();
139
+    }
140
+
141
+    /**
142
+     * Get the timestamp of the last password check
143
+     *
144
+     * @param int $time
145
+     */
146
+    public function setLastCheck(int $time) {
147
+        parent::setLastCheck($time);
148
+    }
149
+
150
+    public function getScope(): string {
151
+        $scope = parent::getScope();
152
+        if ($scope === null) {
153
+            return '';
154
+        }
155
+
156
+        return $scope;
157
+    }
158
+
159
+    public function getScopeAsArray(): array {
160
+        $scope = json_decode($this->getScope(), true);
161
+        if (!$scope) {
162
+            return [
163
+                'filesystem'=> true
164
+            ];
165
+        }
166
+        return $scope;
167
+    }
168
+
169
+    public function setScope($scope) {
170
+        if (\is_array($scope)) {
171
+            parent::setScope(json_encode($scope));
172
+        } else {
173
+            parent::setScope((string)$scope);
174
+        }
175
+    }
176
+
177
+    public function getName(): string {
178
+        return parent::getName();
179
+    }
180
+
181
+    public function setName(string $name): void {
182
+        parent::setName($name);
183
+    }
184
+
185
+    public function getRemember(): int {
186
+        return parent::getRemember();
187
+    }
188
+
189
+    public function setToken(string $token) {
190
+        parent::setToken($token);
191
+    }
192
+
193
+    public function setPassword(string $password = null) {
194
+        parent::setPassword($password);
195
+    }
196
+
197
+    public function setExpires($expires) {
198
+        parent::setExpires($expires);
199
+    }
200
+
201
+    /**
202
+     * @return int|null
203
+     */
204
+    public function getExpires() {
205
+        return parent::getExpires();
206
+    }
207 207
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Token/PublicKeyToken.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -46,184 +46,184 @@
 block discarded – undo
46 46
  */
47 47
 class PublicKeyToken extends Entity implements INamedToken {
48 48
 
49
-	const VERSION = 2;
50
-
51
-	/** @var string user UID */
52
-	protected $uid;
53
-
54
-	/** @var string login name used for generating the token */
55
-	protected $loginName;
56
-
57
-	/** @var string encrypted user password */
58
-	protected $password;
59
-
60
-	/** @var string token name (e.g. browser/OS) */
61
-	protected $name;
62
-
63
-	/** @var string */
64
-	protected $token;
65
-
66
-	/** @var int */
67
-	protected $type;
68
-
69
-	/** @var int */
70
-	protected $remember;
71
-
72
-	/** @var int */
73
-	protected $lastActivity;
74
-
75
-	/** @var int */
76
-	protected $lastCheck;
77
-
78
-	/** @var string */
79
-	protected $scope;
80
-
81
-	/** @var int */
82
-	protected $expires;
83
-
84
-	/** @var string */
85
-	protected $privateKey;
86
-
87
-	/** @var string */
88
-	protected $publicKey;
89
-
90
-	/** @var int */
91
-	protected $version;
92
-
93
-	/** @var bool */
94
-	protected $passwordInvalid;
95
-
96
-	public function __construct() {
97
-		$this->addType('uid', 'string');
98
-		$this->addType('loginName', 'string');
99
-		$this->addType('password', 'string');
100
-		$this->addType('name', 'string');
101
-		$this->addType('token', 'string');
102
-		$this->addType('type', 'int');
103
-		$this->addType('remember', 'int');
104
-		$this->addType('lastActivity', 'int');
105
-		$this->addType('lastCheck', 'int');
106
-		$this->addType('scope', 'string');
107
-		$this->addType('expires', 'int');
108
-		$this->addType('publicKey', 'string');
109
-		$this->addType('privateKey', 'string');
110
-		$this->addType('version', 'int');
111
-		$this->addType('passwordInvalid', 'bool');
112
-	}
113
-
114
-	public function getId(): int {
115
-		return $this->id;
116
-	}
117
-
118
-	public function getUID(): string {
119
-		return $this->uid;
120
-	}
121
-
122
-	/**
123
-	 * Get the login name used when generating the token
124
-	 *
125
-	 * @return string
126
-	 */
127
-	public function getLoginName(): string {
128
-		return parent::getLoginName();
129
-	}
130
-
131
-	/**
132
-	 * Get the (encrypted) login password
133
-	 *
134
-	 * @return string|null
135
-	 */
136
-	public function getPassword() {
137
-		return parent::getPassword();
138
-	}
139
-
140
-	public function jsonSerialize() {
141
-		return [
142
-			'id' => $this->id,
143
-			'name' => $this->name,
144
-			'lastActivity' => $this->lastActivity,
145
-			'type' => $this->type,
146
-			'scope' => $this->getScopeAsArray()
147
-		];
148
-	}
149
-
150
-	/**
151
-	 * Get the timestamp of the last password check
152
-	 *
153
-	 * @return int
154
-	 */
155
-	public function getLastCheck(): int {
156
-		return parent::getLastCheck();
157
-	}
158
-
159
-	/**
160
-	 * Get the timestamp of the last password check
161
-	 *
162
-	 * @param int $time
163
-	 */
164
-	public function setLastCheck(int $time) {
165
-		parent::setLastCheck($time);
166
-	}
167
-
168
-	public function getScope(): string {
169
-		$scope = parent::getScope();
170
-		if ($scope === null) {
171
-			return '';
172
-		}
173
-
174
-		return $scope;
175
-	}
176
-
177
-	public function getScopeAsArray(): array {
178
-		$scope = json_decode($this->getScope(), true);
179
-		if (!$scope) {
180
-			return [
181
-				'filesystem'=> true
182
-			];
183
-		}
184
-		return $scope;
185
-	}
186
-
187
-	public function setScope($scope) {
188
-		if (is_array($scope)) {
189
-			parent::setScope(json_encode($scope));
190
-		} else {
191
-			parent::setScope((string)$scope);
192
-		}
193
-	}
194
-
195
-	public function getName(): string {
196
-		return parent::getName();
197
-	}
198
-
199
-	public function setName(string $name): void {
200
-		parent::setName($name);
201
-	}
202
-
203
-	public function getRemember(): int {
204
-		return parent::getRemember();
205
-	}
206
-
207
-	public function setToken(string $token) {
208
-		parent::setToken($token);
209
-	}
210
-
211
-	public function setPassword(string $password = null) {
212
-		parent::setPassword($password);
213
-	}
214
-
215
-	public function setExpires($expires) {
216
-		parent::setExpires($expires);
217
-	}
218
-
219
-	/**
220
-	 * @return int|null
221
-	 */
222
-	public function getExpires() {
223
-		return parent::getExpires();
224
-	}
225
-
226
-	public function setPasswordInvalid(bool $invalid) {
227
-		parent::setPasswordInvalid($invalid);
228
-	}
49
+    const VERSION = 2;
50
+
51
+    /** @var string user UID */
52
+    protected $uid;
53
+
54
+    /** @var string login name used for generating the token */
55
+    protected $loginName;
56
+
57
+    /** @var string encrypted user password */
58
+    protected $password;
59
+
60
+    /** @var string token name (e.g. browser/OS) */
61
+    protected $name;
62
+
63
+    /** @var string */
64
+    protected $token;
65
+
66
+    /** @var int */
67
+    protected $type;
68
+
69
+    /** @var int */
70
+    protected $remember;
71
+
72
+    /** @var int */
73
+    protected $lastActivity;
74
+
75
+    /** @var int */
76
+    protected $lastCheck;
77
+
78
+    /** @var string */
79
+    protected $scope;
80
+
81
+    /** @var int */
82
+    protected $expires;
83
+
84
+    /** @var string */
85
+    protected $privateKey;
86
+
87
+    /** @var string */
88
+    protected $publicKey;
89
+
90
+    /** @var int */
91
+    protected $version;
92
+
93
+    /** @var bool */
94
+    protected $passwordInvalid;
95
+
96
+    public function __construct() {
97
+        $this->addType('uid', 'string');
98
+        $this->addType('loginName', 'string');
99
+        $this->addType('password', 'string');
100
+        $this->addType('name', 'string');
101
+        $this->addType('token', 'string');
102
+        $this->addType('type', 'int');
103
+        $this->addType('remember', 'int');
104
+        $this->addType('lastActivity', 'int');
105
+        $this->addType('lastCheck', 'int');
106
+        $this->addType('scope', 'string');
107
+        $this->addType('expires', 'int');
108
+        $this->addType('publicKey', 'string');
109
+        $this->addType('privateKey', 'string');
110
+        $this->addType('version', 'int');
111
+        $this->addType('passwordInvalid', 'bool');
112
+    }
113
+
114
+    public function getId(): int {
115
+        return $this->id;
116
+    }
117
+
118
+    public function getUID(): string {
119
+        return $this->uid;
120
+    }
121
+
122
+    /**
123
+     * Get the login name used when generating the token
124
+     *
125
+     * @return string
126
+     */
127
+    public function getLoginName(): string {
128
+        return parent::getLoginName();
129
+    }
130
+
131
+    /**
132
+     * Get the (encrypted) login password
133
+     *
134
+     * @return string|null
135
+     */
136
+    public function getPassword() {
137
+        return parent::getPassword();
138
+    }
139
+
140
+    public function jsonSerialize() {
141
+        return [
142
+            'id' => $this->id,
143
+            'name' => $this->name,
144
+            'lastActivity' => $this->lastActivity,
145
+            'type' => $this->type,
146
+            'scope' => $this->getScopeAsArray()
147
+        ];
148
+    }
149
+
150
+    /**
151
+     * Get the timestamp of the last password check
152
+     *
153
+     * @return int
154
+     */
155
+    public function getLastCheck(): int {
156
+        return parent::getLastCheck();
157
+    }
158
+
159
+    /**
160
+     * Get the timestamp of the last password check
161
+     *
162
+     * @param int $time
163
+     */
164
+    public function setLastCheck(int $time) {
165
+        parent::setLastCheck($time);
166
+    }
167
+
168
+    public function getScope(): string {
169
+        $scope = parent::getScope();
170
+        if ($scope === null) {
171
+            return '';
172
+        }
173
+
174
+        return $scope;
175
+    }
176
+
177
+    public function getScopeAsArray(): array {
178
+        $scope = json_decode($this->getScope(), true);
179
+        if (!$scope) {
180
+            return [
181
+                'filesystem'=> true
182
+            ];
183
+        }
184
+        return $scope;
185
+    }
186
+
187
+    public function setScope($scope) {
188
+        if (is_array($scope)) {
189
+            parent::setScope(json_encode($scope));
190
+        } else {
191
+            parent::setScope((string)$scope);
192
+        }
193
+    }
194
+
195
+    public function getName(): string {
196
+        return parent::getName();
197
+    }
198
+
199
+    public function setName(string $name): void {
200
+        parent::setName($name);
201
+    }
202
+
203
+    public function getRemember(): int {
204
+        return parent::getRemember();
205
+    }
206
+
207
+    public function setToken(string $token) {
208
+        parent::setToken($token);
209
+    }
210
+
211
+    public function setPassword(string $password = null) {
212
+        parent::setPassword($password);
213
+    }
214
+
215
+    public function setExpires($expires) {
216
+        parent::setExpires($expires);
217
+    }
218
+
219
+    /**
220
+     * @return int|null
221
+     */
222
+    public function getExpires() {
223
+        return parent::getExpires();
224
+    }
225
+
226
+    public function setPasswordInvalid(bool $invalid) {
227
+        parent::setPasswordInvalid($invalid);
228
+    }
229 229
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Token/INamedToken.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@
 block discarded – undo
24 24
 
25 25
 
26 26
 interface INamedToken extends IToken {
27
-	/**
28
-	 * Set token name
29
-	 *
30
-	 * @param string $name
31
-	 * @return void
32
-	 */
33
-	public function setName(string $name): void;
27
+    /**
28
+     * Set token name
29
+     *
30
+     * @param string $name
31
+     * @return void
32
+     */
33
+    public function setName(string $name): void;
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.