Code Duplication    Length = 13-13 lines in 4 locations

lib/private/Authentication/Token/DefaultTokenProvider.php 2 locations

@@ 158-170 (lines=13) @@
155
	 * @throws ExpiredTokenException
156
	 * @return IToken
157
	 */
158
	public function getToken(string $tokenId): IToken {
159
		try {
160
			$token = $this->mapper->getToken($this->hashToken($tokenId));
161
		} catch (DoesNotExistException $ex) {
162
			throw new InvalidTokenException();
163
		}
164
165
		if ((int)$token->getExpires() !== 0 && $token->getExpires() < $this->time->getTime()) {
166
			throw new ExpiredTokenException($token);
167
		}
168
169
		return $token;
170
	}
171
172
	/**
173
	 * Get a token by token id
@@ 180-192 (lines=13) @@
177
	 * @throws ExpiredTokenException
178
	 * @return IToken
179
	 */
180
	public function getTokenById(int $tokenId): IToken {
181
		try {
182
			$token = $this->mapper->getTokenById($tokenId);
183
		} catch (DoesNotExistException $ex) {
184
			throw new InvalidTokenException();
185
		}
186
187
		if ($token->getExpires() !== null && $token->getExpires() < $this->time->getTime()) {
188
			throw new ExpiredTokenException($token);
189
		}
190
191
		return $token;
192
	}
193
194
	/**
195
	 * @param string $oldSessionId

lib/private/Authentication/Token/PublicKeyTokenProvider.php 2 locations

@@ 76-88 (lines=13) @@
73
		return $dbToken;
74
	}
75
76
	public function getToken(string $tokenId): IToken {
77
		try {
78
			$token = $this->mapper->getToken($this->hashToken($tokenId));
79
		} catch (DoesNotExistException $ex) {
80
			throw new InvalidTokenException();
81
		}
82
83
		if ($token->getExpires() !== null && $token->getExpires() < $this->time->getTime()) {
84
			throw new ExpiredTokenException($token);
85
		}
86
87
		return $token;
88
	}
89
90
	public function getTokenById(int $tokenId): IToken {
91
		try {
@@ 90-102 (lines=13) @@
87
		return $token;
88
	}
89
90
	public function getTokenById(int $tokenId): IToken {
91
		try {
92
			$token = $this->mapper->getTokenById($tokenId);
93
		} catch (DoesNotExistException $ex) {
94
			throw new InvalidTokenException();
95
		}
96
97
		if ($token->getExpires() !== null && $token->getExpires() < $this->time->getTime()) {
98
			throw new ExpiredTokenException($token);
99
		}
100
101
		return $token;
102
	}
103
104
	public function renewSessionToken(string $oldSessionId, string $sessionId) {
105
		$token = $this->getToken($oldSessionId);