77use DOMElement ;
88use SimpleSAML \SAML2 \Assert \Assert ;
99use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
10- use SimpleSAML \SAML2 \Type \SAMLStringValue ;
11- use SimpleSAML \SAML2 \XML \Comparison ;
10+ use SimpleSAML \SAML2 \Type \{AuthnContextComparisonTypeValue , SAMLStringValue };
1211use SimpleSAML \SAML2 \XML \saml \{AuthnContextClassRef , AuthnContextDeclRef };
1312use SimpleSAML \XML \Constants as C ;
1413use SimpleSAML \XML \Exception \{InvalidDOMElementException , SchemaViolationException };
1514use SimpleSAML \XML \{SchemaValidatableElementInterface , SchemaValidatableElementTrait };
1615
1716use function array_merge ;
17+ use function strval ;
1818
1919/**
2020 * Class representing SAML2 RequestedAuthnContext
@@ -32,11 +32,11 @@ final class RequestedAuthnContext extends AbstractSamlpElement implements Schema
3232 * \SimpleSAML\SAML2\XML\saml\AuthnContextClassRef|
3333 * \SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef
3434 * )[] $requestedAuthnContexts
35- * @param \SimpleSAML\SAML2\XML\Comparison $Comparison
35+ * @param \SimpleSAML\SAML2\Type\AuthnContextComparisonTypeValue $Comparison
3636 */
3737 public function __construct (
3838 protected array $ requestedAuthnContexts = [],
39- protected ?Comparison $ Comparison = null ,
39+ protected ?AuthnContextComparisonTypeValue $ Comparison = null ,
4040 ) {
4141 Assert::maxCount ($ requestedAuthnContexts , C::UNBOUNDED_LIMIT );
4242 Assert::minCount ($ requestedAuthnContexts , 1 , SchemaViolationException::class);
@@ -78,9 +78,9 @@ public function getRequestedAuthnContexts(): array
7878 /**
7979 * Collect the value of the Comparison-property
8080 *
81- * @return \SimpleSAML\SAML2\XML\Comparison |null
81+ * @return \SimpleSAML\SAML2\Type\AuthnContextComparisonTypeValue |null
8282 */
83- public function getComparison (): ?Comparison
83+ public function getComparison (): ?AuthnContextComparisonTypeValue
8484 {
8585 return $ this ->Comparison ;
8686 }
@@ -100,19 +100,12 @@ public static function fromXML(DOMElement $xml): static
100100 Assert::same ($ xml ->localName , 'RequestedAuthnContext ' , InvalidDOMElementException::class);
101101 Assert::same ($ xml ->namespaceURI , RequestedAuthnContext::NS , InvalidDOMElementException::class);
102102
103- $ Comparison = self ::getOptionalAttribute (
104- $ xml ,
105- 'Comparison ' ,
106- SAMLStringValue::class,
107- SAMLStringValue::fromString ('unknown ' ),
108- );
109-
110103 return new static (
111104 array_merge (
112105 AuthnContextClassRef::getChildrenOfClass ($ xml ),
113106 AuthnContextDeclRef::getChildrenOfClass ($ xml ),
114107 ),
115- Comparison:: tryFrom ( $ Comparison-> getValue () ),
108+ self :: getOptionalAttribute ( $ xml , ' Comparison ' , AuthnContextComparisonTypeValue::class, null ),
116109 );
117110 }
118111
@@ -132,7 +125,7 @@ public function toXML(?DOMElement $parent = null): DOMElement
132125 }
133126
134127 if ($ this ->getComparison () !== null ) {
135- $ e ->setAttribute ('Comparison ' , $ this ->getComparison ()-> value );
128+ $ e ->setAttribute ('Comparison ' , strval ( $ this ->getComparison ()) );
136129 }
137130
138131 return $ e ;
0 commit comments