1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2010 SURFnet B.V. |
4
|
|
|
* |
5
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
6
|
|
|
* you may not use this file except in compliance with the License. |
7
|
|
|
* You may obtain a copy of the License at |
8
|
|
|
* |
9
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
10
|
|
|
* |
11
|
|
|
* Unless required by applicable law or agreed to in writing, software |
12
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
13
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14
|
|
|
* See the License for the specific language governing permissions and |
15
|
|
|
* limitations under the License. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace Surfnet\StepupSelfService\SelfServiceBundle\Service\RemoteVetting\Dto; |
19
|
|
|
|
20
|
|
|
use Serializable; |
21
|
|
|
|
22
|
|
|
class RemoteVettingTokenDto implements Serializable |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $identityId; |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $secondFactorId; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param string $identityId |
35
|
|
|
* @param string $secondFactorId |
36
|
|
|
* @return RemoteVettingTokenDto |
37
|
|
|
*/ |
38
|
|
|
public static function create($identityId, $secondFactorId) |
39
|
|
|
{ |
40
|
|
|
return new self($identityId, $secondFactorId); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return RemoteVettingTokenDto |
45
|
|
|
*/ |
46
|
|
|
public static function notSet() |
47
|
|
|
{ |
48
|
|
|
return new self('', ''); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $serialized |
53
|
|
|
* @return RemoteVettingTokenDto |
54
|
|
|
*/ |
55
|
|
|
public static function deserialize($serialized) |
56
|
|
|
{ |
57
|
|
|
$instance = new self('', ''); |
58
|
|
|
$instance->unserialize($serialized); |
59
|
|
|
return $instance; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string $identityId |
64
|
|
|
* @param string $secondFactorId |
65
|
|
|
*/ |
66
|
|
|
private function __construct($identityId, $secondFactorId) |
67
|
|
|
{ |
68
|
|
|
$this->identityId = $identityId; |
69
|
|
|
$this->secondFactorId = $secondFactorId; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function getIdentityId() |
76
|
|
|
{ |
77
|
|
|
return $this->identityId; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
|
|
public function getSecondFactorId() |
84
|
|
|
{ |
85
|
|
|
return $this->secondFactorId; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @inheritDoc |
90
|
|
|
*/ |
91
|
|
|
public function serialize() |
92
|
|
|
{ |
93
|
|
|
return json_encode([ |
94
|
|
|
'identityId' => $this->identityId, |
95
|
|
|
'secondFactorId' => $this->secondFactorId, |
96
|
|
|
]); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @inheritDoc |
101
|
|
|
*/ |
102
|
|
|
public function unserialize($serialized) |
103
|
|
|
{ |
104
|
|
|
$data = json_decode($serialized, true); |
105
|
|
|
|
106
|
|
|
$this->identityId = $data['identityId']; |
107
|
|
|
$this->secondFactorId = $data['secondFactorId']; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|