1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2018 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupSelfService\SelfServiceBundle\Value; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupSelfService\SamlStepupProviderBundle\Provider\ViewConfig; |
22
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException; |
23
|
|
|
|
24
|
|
|
class GsspToken implements AvailableTokenInterface |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var ViewConfig |
28
|
|
|
*/ |
29
|
|
|
private $viewConfig; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $type; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param ViewConfig $viewConfig |
38
|
|
|
* @param $type |
39
|
|
|
* @return GsspToken |
40
|
|
|
*/ |
41
|
|
|
public static function fromViewConfig(ViewConfig $viewConfig, $type) |
42
|
|
|
{ |
43
|
|
|
if (!is_string($type) || empty($type)) { |
44
|
|
|
throw InvalidArgumentException::invalidType('a non empty string', 'type', $type); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return new self($viewConfig, $type); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* GsspToken constructor. |
52
|
|
|
* @param ViewConfig $viewConfig |
53
|
|
|
* @param string $type |
54
|
|
|
*/ |
55
|
|
|
private function __construct(ViewConfig $viewConfig, $type) |
56
|
|
|
{ |
57
|
|
|
$this->viewConfig = $viewConfig; |
58
|
|
|
$this->type = $type; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return string |
63
|
|
|
*/ |
64
|
|
|
public function getRoute() |
65
|
|
|
{ |
66
|
|
|
return 'ss_registration_gssf_initiate'; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return mixed |
71
|
|
|
*/ |
72
|
|
|
public function getType() |
73
|
|
|
{ |
74
|
|
|
return $this->type; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return int |
79
|
|
|
*/ |
80
|
|
|
public function getLoaLevel() |
81
|
|
|
{ |
82
|
|
|
return (int) $this->viewConfig->getLoa(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return boolean |
87
|
|
|
*/ |
88
|
|
|
public function isGssp() |
89
|
|
|
{ |
90
|
|
|
return true; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getRouteParams() |
94
|
|
|
{ |
95
|
|
|
return [ |
96
|
|
|
'provider' => $this->type, |
97
|
|
|
]; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getViewConfig() |
101
|
|
|
{ |
102
|
|
|
return $this->viewConfig; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|