1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2020 SURFnet B.V. |
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\StepupSelfService\SelfServiceBundle\Service\RemoteVetting\Encryption; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupBundle\DateTime\DateTime; |
22
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Assert; |
23
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Service\RemoteVetting\Value\AttributeCollectionInterface; |
24
|
|
|
|
25
|
|
|
class IdentityData |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var AttributeCollectionInterface |
29
|
|
|
*/ |
30
|
|
|
private $attributeCollectionAggregate; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
private $nameId; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $applicationVersion; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
private $institution; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
private $remoteVettingSource; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param AttributeCollectionInterface $attributeCollectionAggregate |
54
|
|
|
* @param string $nameId |
55
|
|
|
* @param string $applicationVersion |
56
|
|
|
* @param $institution |
57
|
|
|
* @param $remoteVettingSource |
58
|
|
|
* @throws \Assert\AssertionFailedException |
59
|
|
|
*/ |
60
|
|
|
public function __construct( |
61
|
|
|
AttributeCollectionInterface $attributeCollectionAggregate, |
62
|
|
|
$nameId, |
63
|
|
|
$applicationVersion, |
64
|
|
|
$institution, |
65
|
|
|
$remoteVettingSource |
66
|
|
|
) { |
67
|
|
|
Assert::string($nameId, 'The name id must have a string value'); |
68
|
|
|
Assert::string($applicationVersion, 'The application version must have a string value'); |
69
|
|
|
Assert::string($institution, 'The SHO of the institution must have a string value'); |
70
|
|
|
Assert::string($remoteVettingSource, 'The remote vetting source must have a string value'); |
71
|
|
|
|
72
|
|
|
$this->attributeCollectionAggregate = $attributeCollectionAggregate; |
73
|
|
|
$this->nameId = $nameId; |
74
|
|
|
$this->applicationVersion = $applicationVersion; |
75
|
|
|
$this->institution = $institution; |
76
|
|
|
$this->remoteVettingSource = $remoteVettingSource; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function serialize() |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
return json_encode( |
82
|
|
|
[ |
83
|
|
|
'attribute-data' => $this->attributeCollectionAggregate->getAttributes(), |
84
|
|
|
'name-id' => $this->nameId, |
85
|
|
|
'institution' => $this->institution, |
86
|
|
|
'remote-vetting-source' => $this->remoteVettingSource, |
87
|
|
|
'application-version' => $this->applicationVersion, |
88
|
|
|
'time' => DateTime::now()->format('c'), |
89
|
|
|
] |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
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.