Passed
Pull Request — master (#317)
by Tim
12:30
created

AbstractSSODescriptor::getSingleLogoutService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\md;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
10
use SimpleSAML\XML\Utils as XMLUtils;
11
12
/**
13
 * Class representing SAML 2 SSODescriptorType.
14
 *
15
 * @package simplesamlphp/saml2
16
 */
17
abstract class AbstractSSODescriptor extends AbstractRoleDescriptor
18
{
19
    /**
20
     * Initialize a RoleDescriptor.
21
     *
22
     * @param string[] $protocolSupportEnumeration A set of URI specifying the protocols supported.
23
     * @param string|null $ID The ID for this document. Defaults to null.
24
     * @param int|null $validUntil Unix time of validity for this document. Defaults to null.
25
     * @param string|null $cacheDuration Maximum time this document can be cached. Defaults to null.
26
     * @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions An array of extensions. Defaults to an empty array.
27
     * @param string|null $errorURL An URI where to redirect users for support. Defaults to null.
28
     * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors An array of KeyDescriptor elements.
29
     *   Defaults to an empty array.
30
     * @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
31
     *   The organization running this entity. Defaults to null.
32
     * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts An array of contacts for this entity.
33
     *   Defaults to an empty array.
34
     * @param \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType[] $artifactResolutionService An array of
35
     *   ArtifactResolutionEndpoint. Defaults to an empty array.
36
     * @param \SimpleSAML\SAML2\XML\md\AbstractEndpointType[] $singleLogoutService An array of SingleLogoutEndpoint.
37
     *   Defaults to an empty array.
38
     * @param \SimpleSAML\SAML2\XML\md\AbstractEndpointType[] $manageNameIDService An array of ManageNameIDService.
39
     *   Defaults to an empty array.
40
     * @param \SimpleSAML\SAML2\XML\md\NameIDFormat[] $nameIDFormat An array of supported NameID formats.
41
     *   Defaults to an empty array.
42
     */
43
    public function __construct(
44
        array $protocolSupportEnumeration,
45
        ?string $ID = null,
46
        ?int $validUntil = null,
47
        ?string $cacheDuration = null,
48
        ?Extensions $extensions = null,
49
        ?string $errorURL = null,
50
        array $keyDescriptors = [],
51
        ?Organization $organization = null,
52
        array $contacts = [],
53
        protected array $artifactResolutionService = [],
54
        protected array $singleLogoutService = [],
55
        protected array $manageNameIDService = [],
56
        protected array $nameIDFormat = [],
57
    ) {
58
        Assert::allIsInstanceOf(
59
            $artifactResolutionService,
60
            ArtifactResolutionService::class,
61
            'All md:ArtifactResolutionService endpoints must be an instance of ArtifactResolutionService.',
62
        );
63
        Assert::allIsInstanceOf(
64
            $singleLogoutService,
65
            SingleLogoutService::class,
66
            'All md:SingleLogoutService endpoints must be an instance of SingleLogoutService.',
67
        );
68
        Assert::allIsInstanceOf(
69
            $manageNameIDService,
70
            ManageNameIDService::class,
71
            'All md:ManageNameIDService endpoints must be an instance of ManageNameIDService.',
72
        );
73
        Assert::allIsInstanceOf($nameIDFormat, NameIDFormat::class, ProtocolViolationException::class);
74
75
        parent::__construct(
76
            $protocolSupportEnumeration,
77
            $ID,
78
            $validUntil,
79
            $cacheDuration,
80
            $extensions,
81
            $errorURL,
82
            $keyDescriptors,
83
            $organization,
84
            $contacts,
85
        );
86
    }
87
88
89
    /**
90
     * Collect the value of the ArtifactResolutionService-property
91
     *
92
     * @return \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType[]
93
     */
94
    public function getArtifactResolutionService(): array
95
    {
96
        return $this->artifactResolutionService;
97
    }
98
99
100
    /**
101
     * Collect the value of the SingleLogoutService-property
102
     *
103
     * @return \SimpleSAML\SAML2\XML\md\AbstractEndpointType[]
104
     */
105
    public function getSingleLogoutService(): array
106
    {
107
        return $this->singleLogoutService;
108
    }
109
110
111
    /**
112
     * Collect the value of the ManageNameIDService-property
113
     *
114
     * @return \SimpleSAML\SAML2\XML\md\AbstractEndpointType[]
115
     */
116
    public function getManageNameIDService(): array
117
    {
118
        return $this->manageNameIDService;
119
    }
120
121
122
    /**
123
     * Collect the value of the NameIDFormat-property
124
     *
125
     * @return \SimpleSAML\SAML2\XML\md\NameIDFormat[]
126
     */
127
    public function getNameIDFormat(): array
128
    {
129
        return $this->nameIDFormat;
130
    }
131
132
133
    /**
134
     * Add this SSODescriptorType to an EntityDescriptor.
135
     *
136
     * @param  \DOMElement|null $parent The EntityDescriptor we should append this SSODescriptorType to.
137
     * @return \DOMElement The generated SSODescriptor DOMElement.
138
     */
139
    public function toUnsignedXML(DOMElement $parent = null): DOMElement
140
    {
141
        $e = parent::toUnsignedXML($parent);
142
143
        foreach ($this->getArtifactResolutionService() as $ep) {
144
            $ep->toXML($e);
145
        }
146
147
        foreach ($this->getSingleLogoutService() as $ep) {
148
            $ep->toXML($e);
149
        }
150
151
        foreach ($this->getManageNameIDService() as $ep) {
152
            $ep->toXML($e);
153
        }
154
155
        foreach ($this->getNameIDFormat() as $nidFormat) {
156
            $nidFormat->toXML($e);
157
        }
158
159
        return $e;
160
    }
161
}
162