1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 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\StepupRa\RaBundle\Security\Authentication\Token; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupBundle\Value\Loa; |
22
|
|
|
use Surfnet\StepupMiddlewareClientBundle\Configuration\Dto\InstitutionConfigurationOptions; |
23
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; |
24
|
|
|
|
25
|
|
|
class SamlToken extends AbstractToken |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var \SAML2_Assertion |
29
|
|
|
*/ |
30
|
|
|
public $assertion; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var \Surfnet\StepupBundle\Value\Loa |
34
|
|
|
*/ |
35
|
|
|
private $loa; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var InstitutionConfigurationOptions |
39
|
|
|
*/ |
40
|
|
|
private $institutionConfigurationOptions; |
41
|
|
|
|
42
|
|
|
public function __construct( |
43
|
|
|
Loa $loa, |
44
|
|
|
array $roles = [], |
45
|
|
|
InstitutionConfigurationOptions $institutionConfigurationOptions = null |
|
|
|
|
46
|
|
|
) { |
47
|
|
|
parent::__construct($roles); |
48
|
|
|
|
49
|
|
|
$this->loa = $loa; |
50
|
|
|
$this->institutionConfigurationOptions = $institutionConfigurationOptions; |
51
|
|
|
$this->setAuthenticated(count($roles)); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return InstitutionConfigurationOptions |
56
|
|
|
*/ |
57
|
|
|
public function getInstitutionConfigurationOptions() |
58
|
|
|
{ |
59
|
|
|
return $this->institutionConfigurationOptions; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns the user credentials. |
64
|
|
|
* |
65
|
|
|
* @return mixed The user credentials |
66
|
|
|
*/ |
67
|
|
|
public function getCredentials() |
68
|
|
|
{ |
69
|
|
|
return ''; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return Loa |
74
|
|
|
*/ |
75
|
|
|
public function getLoa() |
76
|
|
|
{ |
77
|
|
|
return $this->loa; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function serialize() |
81
|
|
|
{ |
82
|
|
|
return serialize([parent::serialize(), $this->loa, $this->institutionConfigurationOptions]); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function unserialize($serialized) |
86
|
|
|
{ |
87
|
|
|
list($parent, $this->loa, $this->institutionConfigurationOptions) = unserialize($serialized); |
88
|
|
|
|
89
|
|
|
parent::unserialize($parent); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.