|
1
|
|
|
<?php |
|
2
|
|
|
namespace Equip\Auth\Exception; |
|
3
|
|
|
|
|
4
|
|
|
use Exception; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Exception that occurs when a user specifies an authentication token that is |
|
8
|
|
|
* invalid or credentials that are not recognized to obtain an authentication |
|
9
|
|
|
* token. |
|
10
|
|
|
*/ |
|
11
|
|
|
class InvalidException extends AuthException |
|
12
|
|
|
{ |
|
13
|
|
|
const CODE = 403; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @param string $token |
|
17
|
|
|
* @param Exception $previous |
|
18
|
|
|
*/ |
|
19
|
2 |
|
public static function tokenExpired($token, Exception $previous = null) |
|
20
|
|
|
{ |
|
21
|
2 |
|
return new static( |
|
22
|
2 |
|
sprintf('Provided auth token `%s` is expired', $token), |
|
23
|
2 |
|
static::CODE, |
|
24
|
|
|
$previous |
|
25
|
2 |
|
); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param string $token |
|
30
|
|
|
* @param Exception $previous |
|
31
|
|
|
*/ |
|
32
|
2 |
|
public static function tokenUnparseable($token, Exception $previous = null) |
|
33
|
|
|
{ |
|
34
|
2 |
|
return new static( |
|
35
|
2 |
|
sprintf('Provided auth token `%s` could not be parsed', $token), |
|
36
|
2 |
|
static::CODE, |
|
37
|
|
|
$previous |
|
38
|
2 |
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param string $token |
|
43
|
|
|
* @param Exception $previous |
|
44
|
|
|
*/ |
|
45
|
2 |
|
public static function invalidSignature($token, Exception $previous = null) |
|
46
|
|
|
{ |
|
47
|
2 |
|
return new static( |
|
48
|
2 |
|
sprintf('Signature of provided auth token `%s` is not valid', $token), |
|
49
|
2 |
|
static::CODE, |
|
50
|
|
|
$previous |
|
51
|
2 |
|
); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param string $token |
|
56
|
|
|
* @param Exception $previous |
|
57
|
|
|
*/ |
|
58
|
2 |
|
public static function invalidToken($token, Exception $previous = null) |
|
59
|
|
|
{ |
|
60
|
2 |
|
return new static( |
|
61
|
2 |
|
sprintf('Provided auth token `%s` is expired or otherwise invalid', $token), |
|
62
|
2 |
|
static::CODE, |
|
63
|
|
|
$previous |
|
64
|
2 |
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param string $identifier |
|
69
|
|
|
* @param Exception $previous |
|
70
|
|
|
*/ |
|
71
|
1 |
|
public static function unknownIdentifier($identifier, Exception $previous = null) |
|
72
|
|
|
{ |
|
73
|
1 |
|
return new static( |
|
74
|
1 |
|
sprintf('Specified identifier `%s` is not recognized', $identifier), |
|
75
|
1 |
|
static::CODE, |
|
76
|
|
|
$previous |
|
77
|
1 |
|
); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param string $identifier |
|
82
|
|
|
* @param Exception $previous |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public static function incorrectPassword($identifier, Exception $previous = null) |
|
85
|
|
|
{ |
|
86
|
1 |
|
return new static( |
|
87
|
1 |
|
sprintf('Incorrect password specified for identifier `%s`', $identifier), |
|
88
|
1 |
|
static::CODE, |
|
89
|
|
|
$previous |
|
90
|
1 |
|
); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|