Passed
Pull Request — master (#351)
by Tim
02:15
created

Issuer::fromXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML2\Constants as C;
10
use SimpleSAML\XML\Exception\InvalidDOMElementException;
11
12
/**
13
 * Class representing the saml:Issuer element.
14
 *
15
 * @package simplesamlphp/saml2
16
 */
17
final class Issuer extends NameIDType
18
{
19
    /**
20
     * Initialize a saml:Issuer
21
     *
22
     * @param string $value
23
     * @param string|null $NameQualifier
24
     * @param string|null $SPNameQualifier
25
     * @param string|null $Format
26
     * @param string|null $SPProvidedID
27
     */
28
    public function __construct(
29
        string $value,
30
        ?string $NameQualifier = null,
31
        ?string $SPNameQualifier = null,
32
        ?string $Format = null,
33
        ?string $SPProvidedID = null,
34
    ) {
35
        /**
36
         * The format of this NameIDType.
37
         *
38
         * Defaults to urn:oasis:names:tc:SAML:2.0:nameid-format:entity:
39
         *
40
         * Indicates that the content of the element is the identifier of an entity that provides SAML-based services
41
         * (such as a SAML authority, requester, or responder) or is a participant in SAML profiles (such as a service
42
         * provider supporting the browser SSO profile). Such an identifier can be used in the <Issuer> element to
43
         * identify the issuer of a SAML request, response, or assertion, or within the <NameID> element to make
44
         * assertions about system entities that can issue SAML requests, responses, and assertions. It can also be
45
         * used in other elements and attributes whose purpose is to identify a system entity in various protocol
46
         * exchanges.
47
         *
48
         * The syntax of such an identifier is a URI of not more than 1024 characters in length. It is RECOMMENDED that
49
         * a system entity use a URL containing its own domain name to identify itself.
50
         *
51
         * @see saml-core-2.0-os
52
         *
53
         * From saml-core-2.0-os 8.3.6, when the entity Format is used: "The NameQualifier, SPNameQualifier, and
54
         * SPProvidedID attributes MUST be omitted."
55
         *
56
         * @var string
57
         */
58
        if ($Format === C::NAMEID_ENTITY || $Format === null) {
59
            Assert::allNull(
60
                [$NameQualifier, $SPNameQualifier, $SPProvidedID],
61
                'Illegal combination of attributes being used',
62
            );
63
        }
64
65
        parent::__construct($value, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
66
    }
67
}
68