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\StepupMiddlewareClientBundle\Identity\Dto; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupMiddlewareClientBundle\Dto\Dto; |
22
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
23
|
|
|
|
24
|
|
|
class RegistrationAuthorityCredentials implements Dto |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @Assert\NotBlank(message="middleware_client.dto.ra_credentials.identity_id.must_not_be_blank") |
28
|
|
|
* @Assert\Type(type="string", message="middleware_client.dto.ra_credentials.identity_id.must_be_string") |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
public $identityId; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @Assert\Expression( |
36
|
|
|
* "this.assertNullOrString(value)", |
37
|
|
|
* message="middleware_client.dto.ra_credentials.institution.must_be_null_or_string" |
38
|
|
|
* ) |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public $institution; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @Assert\Expression( |
46
|
|
|
* "this.assertNullOrString(value)", |
47
|
|
|
* message="middleware_client.dto.ra_credentials.common_name.must_be_null_or_string" |
48
|
|
|
* ) |
49
|
|
|
* |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
public $commonName; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @Assert\Expression( |
56
|
|
|
* "this.assertNullOrString(value)", |
57
|
|
|
* message="middleware_client.dto.ra_credentials.location.must_be_null_or_string" |
58
|
|
|
* ) |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
public $location; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @Assert\Expression( |
66
|
|
|
* "this.assertNullOrString(value)", |
67
|
|
|
* message="middleware_client.dto.ra_credentials.contact_information.must_be_null_or_string" |
68
|
|
|
* ) |
69
|
|
|
* |
70
|
|
|
* @var string |
71
|
|
|
*/ |
72
|
|
|
public $contactInformation; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @Assert\Type(type="bool", message="middleware_client.dto.ra_credentials.is_raa.must_be_boolean") |
76
|
|
|
* |
77
|
|
|
* @var bool |
78
|
|
|
*/ |
79
|
|
|
public $isRaa; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @Assert\Type(type="bool", message="middleware_client.dto.ra_credentials.is_sraa.must_be_boolean") |
83
|
|
|
* |
84
|
|
|
* @var bool |
85
|
|
|
*/ |
86
|
|
|
public $isSraa; |
87
|
|
|
|
88
|
|
|
public static function fromData(array $data) |
89
|
|
|
{ |
90
|
|
|
$credentials = new self(); |
91
|
|
|
$credentials->identityId = $data['id']; |
92
|
|
|
$credentials->institution = $data['attributes']['institution']; |
93
|
|
|
$credentials->commonName = $data['attributes']['common_name']; |
94
|
|
|
$credentials->location = $data['attributes']['location']; |
95
|
|
|
$credentials->contactInformation = $data['attributes']['contact_information']; |
96
|
|
|
$credentials->isRaa = $data['attributes']['is_raa']; |
97
|
|
|
$credentials->isSraa = $data['attributes']['is_sraa']; |
98
|
|
|
|
99
|
|
|
return $credentials; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param mixed $value |
104
|
|
|
* @return bool |
105
|
|
|
*/ |
106
|
|
|
public function assertNullOrString($value) |
107
|
|
|
{ |
108
|
|
|
return is_null($value) || is_string($value); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|