1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* security consultant entity |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Graviton\SecurityBundle\Entities; |
7
|
|
|
|
8
|
|
|
use GravitonDyn\ConsultantBundle\Document\Consultant; |
9
|
|
|
use Symfony\Component\Security\Core\Role\Role; |
10
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class SecurityConsultant |
14
|
|
|
* |
15
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
16
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
17
|
|
|
* @link http://swisscom.ch |
18
|
|
|
*/ |
19
|
|
|
class SecurityConsultant implements UserInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var Contract |
23
|
|
|
*/ |
24
|
|
|
private $consultant; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var Role[] |
28
|
|
|
*/ |
29
|
|
|
private $roles; |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Constructor of the class. |
34
|
|
|
* |
35
|
|
|
* @param Contract $consultant contract |
36
|
|
|
* @param Role[] $roles roles for the contract |
37
|
|
|
*/ |
38
|
|
|
public function __construct(Consultant $consultant, array $roles = array()) |
39
|
|
|
{ |
40
|
|
|
$this->consultant = $consultant; |
|
|
|
|
41
|
|
|
$this->roles = $roles; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Returns the roles granted to the user. |
46
|
|
|
* |
47
|
|
|
* @return Role[] The user roles |
48
|
|
|
*/ |
49
|
|
|
public function getRoles() |
50
|
|
|
{ |
51
|
|
|
return $this->roles; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Returns the password used to authenticate the user. |
56
|
|
|
* |
57
|
|
|
* @return string The password |
58
|
|
|
*/ |
59
|
|
|
public function getPassword() |
60
|
|
|
{ |
61
|
|
|
return ''; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Returns the salt that was originally used to encode the password. |
66
|
|
|
* |
67
|
|
|
* @return null The salt |
68
|
|
|
*/ |
69
|
|
|
public function getSalt() |
70
|
|
|
{ |
71
|
|
|
return null; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Returns the username used to authenticate the user. |
76
|
|
|
* |
77
|
|
|
* @return string The username |
78
|
|
|
*/ |
79
|
|
|
public function getUsername() |
80
|
|
|
{ |
81
|
|
|
return $this->consultant->getUsername(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Removes sensitive data from the user. |
86
|
|
|
* |
87
|
|
|
* This is important if, at any given point, sensitive information like |
88
|
|
|
* the plain-text password is stored on this object. |
89
|
|
|
* |
90
|
|
|
* @return void |
91
|
|
|
*/ |
92
|
|
|
public function eraseCredentials() |
93
|
|
|
{ |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Provides the consultant object. |
98
|
|
|
* |
99
|
|
|
* @return Contract |
100
|
|
|
*/ |
101
|
|
|
public function getConsultant() |
102
|
|
|
{ |
103
|
|
|
return $this->consultant; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..