Skip to content

Commit

Permalink
Code de-dup
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 25, 2024
1 parent bc31e1a commit 9d2b4d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 46 deletions.
23 changes: 0 additions & 23 deletions src/SAML2/XML/saml/Issuer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,4 @@ public function __construct(

parent::__construct($value, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
}


/**
* Convert XML into an Issuer
*
* @param \DOMElement $xml The XML element we should load
* @return static
*
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
{
Assert::same($xml->localName, 'Issuer', InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, Issuer::NS, InvalidDOMElementException::class);

$Format = self::getOptionalAttribute($xml, 'Format', null);
$SPProvidedID = self::getOptionalAttribute($xml, 'SPProvidedID', null);
$NameQualifier = self::getOptionalAttribute($xml, 'NameQualifier', null);
$SPNameQualifier = self::getOptionalAttribute($xml, 'SPNameQualifier', null);

return new static($xml->textContent, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
}
}
23 changes: 0 additions & 23 deletions src/SAML2/XML/saml/NameID.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,6 @@ public function __construct(
}


/**
* Convert XML into an NameID
*
* @param \DOMElement $xml The XML element we should load
* @return static
*
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
{
Assert::same($xml->localName, 'NameID', InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, NameID::NS, InvalidDOMElementException::class);

$NameQualifier = self::getOptionalAttribute($xml, 'NameQualifier', null);
$SPNameQualifier = self::getOptionalAttribute($xml, 'SPNameQualifier', null);
$Format = self::getOptionalAttribute($xml, 'Format', null);
$SPProvidedID = self::getOptionalAttribute($xml, 'SPProvidedID', null);

return new static($xml->textContent, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
}


public function getBlacklistedAlgorithms(): ?array
{
$container = ContainerSingleton::getInstance();
Expand Down
23 changes: 23 additions & 0 deletions src/SAML2/XML/saml/NameIDType.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,29 @@ protected function validateContent(string $content): void
}


/**
* Convert XML into an NameID
*
* @param \DOMElement $xml The XML element we should load
* @return static
*
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
{
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);

$NameQualifier = self::getOptionalAttribute($xml, 'NameQualifier', null);
$SPNameQualifier = self::getOptionalAttribute($xml, 'SPNameQualifier', null);
$Format = self::getOptionalAttribute($xml, 'Format', null);
$SPProvidedID = self::getOptionalAttribute($xml, 'SPProvidedID', null);

return new static($xml->textContent, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
}


/**
* Convert this NameIDType to XML.
*
Expand Down

0 comments on commit 9d2b4d8

Please sign in to comment.