-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAuthorizationResult.php
More file actions
119 lines (102 loc) · 2.35 KB
/
AuthorizationResult.php
File metadata and controls
119 lines (102 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
namespace PhpMiddleware\HttpAuthentication;
final class AuthorizationResult implements AuthorizationResultInterface
{
/**
* @var bool
*/
private $isAuthorized;
/**
* @var array
*/
private $challenge;
/**
* @var string
*/
private $scheme;
/**
* @var array
*/
private $attributes;
private function __construct()
{
}
/**
* @param string $scheme
* @param array $challenge
* @param array $attributes
*
* @return self
*/
public static function authorized($scheme, array $challenge = [], array $attributes = [])
{
$instance = new self();
$instance->isAuthorized = true;
$instance->scheme = $scheme;
$instance->challenge = $challenge;
$instance->attributes = $attributes;
return $instance;
}
/**
* @param string $scheme
* @param array $challenge
* @param array $attributes
*
* @return self
*/
public static function notAuthorized($scheme, array $challenge = [], array $attributes = [])
{
$instance = new self();
$instance->isAuthorized = false;
$instance->scheme = $scheme;
$instance->challenge = $challenge;
$instance->attributes = $attributes;
return $instance;
}
/**
* @param string $scheme
* @param array $challenge
* @param array $attributes
*
* @return self
*/
public static function error($scheme, $error, $errorDescription, array $challenge = [], array $attributes = [])
{
$challenge['error'] = $error;
$challenge['error_description'] = $errorDescription;
$instance = new self();
$instance->isAuthorized = false;
$instance->scheme = $scheme;
$instance->challenge = $challenge;
$instance->attributes = $attributes;
return $instance;
}
/**
* @return array
*/
public function getChallenge()
{
return $this->challenge;
}
/**
* @return string
*/
public function getScheme()
{
return $this->scheme;
}
/**
* @return bool
*/
public function isAuthorized()
{
return $this->isAuthorized;
}
/**
* @return array
*/
public function getAttributes()
{
return $this->attributes;
}
}