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\StepupMiddleware\ApiBundle\Identity\Value; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity; |
22
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VerifiedSecondFactor; |
23
|
|
|
|
24
|
|
|
class VerifiedTokenInformation |
25
|
|
|
{ |
26
|
|
|
private $email; |
27
|
|
|
|
28
|
|
|
private $tokenId; |
29
|
|
|
|
30
|
|
|
private $tokenType; |
31
|
|
|
|
32
|
|
|
private $commonName; |
33
|
|
|
|
34
|
|
|
private $requestedAt; |
35
|
|
|
|
36
|
|
|
private $preferredLocale; |
37
|
|
|
|
38
|
|
|
private $institution; |
39
|
|
|
|
40
|
|
|
private $registrationCode; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param $email |
44
|
|
|
* @param $tokenId |
45
|
|
|
* @param $tokenType |
46
|
|
|
* @param $commonName |
47
|
|
|
* @param $requestedAt |
48
|
|
|
* @param $preferredLocale |
49
|
|
|
* @param $institution |
50
|
|
|
* @param $registrationCode |
51
|
|
|
*/ |
52
|
|
|
public function __construct( |
53
|
|
|
$email, |
54
|
|
|
$tokenId, |
55
|
|
|
$tokenType, |
56
|
|
|
$commonName, |
57
|
|
|
$requestedAt, |
58
|
|
|
$preferredLocale, |
59
|
|
|
$institution, |
60
|
|
|
$registrationCode |
61
|
|
|
) { |
62
|
|
|
$this->email = $email; |
63
|
|
|
$this->tokenId = $tokenId; |
64
|
|
|
$this->tokenType = $tokenType; |
65
|
|
|
$this->commonName = $commonName; |
66
|
|
|
$this->requestedAt = $requestedAt; |
67
|
|
|
$this->preferredLocale = $preferredLocale; |
68
|
|
|
$this->institution = $institution; |
69
|
|
|
$this->registrationCode = $registrationCode; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public static function fromEntity(VerifiedSecondFactor $token, Identity $identity) |
73
|
|
|
{ |
74
|
|
|
$tokenInformation = new self( |
75
|
|
|
(string) $identity->email, |
76
|
|
|
$token->id, |
77
|
|
|
$token->type, |
78
|
|
|
(string) $identity->commonName, |
79
|
|
|
$token->registrationRequestedAt, |
80
|
|
|
(string) $identity->preferredLocale, |
81
|
|
|
$identity->institution, |
82
|
|
|
$token->registrationCode |
83
|
|
|
); |
84
|
|
|
|
85
|
|
|
return $tokenInformation; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getEmail() |
|
|
|
|
89
|
|
|
{ |
90
|
|
|
return $this->email; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getTokenId() |
|
|
|
|
94
|
|
|
{ |
95
|
|
|
return $this->tokenId; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function getTokenType() |
|
|
|
|
99
|
|
|
{ |
100
|
|
|
return $this->tokenType; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function getCommonName() |
|
|
|
|
104
|
|
|
{ |
105
|
|
|
return $this->commonName; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getRequestedAt() |
|
|
|
|
109
|
|
|
{ |
110
|
|
|
return $this->requestedAt; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function getPreferredLocale() |
|
|
|
|
114
|
|
|
{ |
115
|
|
|
return $this->preferredLocale; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function getInstitution() |
|
|
|
|
119
|
|
|
{ |
120
|
|
|
return $this->institution; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function getRegistrationCode() |
|
|
|
|
124
|
|
|
{ |
125
|
|
|
return $this->registrationCode; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.