-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathSsoToken.php
More file actions
91 lines (73 loc) · 2.23 KB
/
SsoToken.php
File metadata and controls
91 lines (73 loc) · 2.23 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
<?php
namespace BeSimple\SsoAuthBundle\Security\Core\Authentication\Token;
use BeSimple\SsoAuthBundle\Sso\Manager;
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
class SsoToken extends AbstractToken
{
private $manager;
private $credentials;
/**
* Constructor.
*
* @param Manager $manager The SSO manager
* @param string $credentials The SSO token
* @param string $user The username
* @param array $roles An array of roles
* @param array $validationAttributes An array of attributes
*
* @throws \InvalidArgumentException
*/
public function __construct(Manager $manager, $credentials, $user = null, array $roles = array(), array $validationAttributes = array())
{
parent::__construct($roles);
$this->manager = $manager;
$this->credentials = $credentials;
$this->setAttribute('sso:validation', $validationAttributes);
if (!is_null($user)) {
$this->setUser($user);
parent::setAuthenticated(true);
}
}
/**
* {@inheritdoc}
*/
public function setAuthenticated($isAuthenticated)
{
if ($isAuthenticated) {
throw new \LogicException('Cannot set this token to trusted after instantiation.');
}
parent::setAuthenticated(false);
}
public function getCredentials()
{
return $this->credentials;
}
public function getManager()
{
return $this->manager;
}
public function getValidationAttributes()
{
if (!$this->hasAttribute('sso:validation')) {
return array();
}
return $this->getAttribute('sso:validation');
}
/**
* {@inheritdoc}
*/
public function eraseCredentials()
{
parent::eraseCredentials();
$this->credentials = null;
}
public function serialize()
{
return serialize(array($this->credentials, $this->manager, parent::serialize()));
}
public function unserialize($str)
{
list($this->credentials, $this->manager, $parentStr) = unserialize($str);
parent::unserialize($parentStr);
}
}