|
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\StepupRa\RaBundle\Exception\LogicException; |
|
23
|
|
|
use Surfnet\StepupRa\RaBundle\Exception\RuntimeException; |
|
24
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; |
|
25
|
|
|
use Symfony\Component\Security\Core\Role\RoleInterface; |
|
26
|
|
|
|
|
27
|
|
|
class SamlToken extends AbstractToken |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var \SAML2\Assertion |
|
31
|
|
|
*/ |
|
32
|
|
|
public $assertion; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var \Surfnet\StepupBundle\Value\Loa |
|
36
|
|
|
*/ |
|
37
|
|
|
private $loa; |
|
38
|
|
|
|
|
39
|
|
|
public function __construct(Loa $loa, array $roles = []) |
|
40
|
|
|
{ |
|
41
|
|
|
parent::__construct($roles); |
|
42
|
|
|
|
|
43
|
|
|
$this->loa = $loa; |
|
44
|
|
|
$this->setAuthenticated(count($roles)); |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Returns the user credentials. |
|
49
|
|
|
* |
|
50
|
|
|
* @return mixed The user credentials |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getCredentials() |
|
53
|
|
|
{ |
|
54
|
|
|
return ''; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return Loa |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getLoa() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->loa; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function serialize() |
|
66
|
|
|
{ |
|
67
|
|
|
return serialize( |
|
68
|
|
|
[ |
|
69
|
|
|
parent::serialize(), |
|
70
|
|
|
$this->loa, |
|
71
|
|
|
] |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function unserialize($serialized) |
|
76
|
|
|
{ |
|
77
|
|
|
list( |
|
78
|
|
|
$parent, |
|
79
|
|
|
$this->loa, |
|
80
|
|
|
) = unserialize( |
|
81
|
|
|
$serialized |
|
82
|
|
|
); |
|
83
|
|
|
|
|
84
|
|
|
parent::unserialize($parent); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: