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
@@ -33,11 +33,11 @@ final class RequestedAuthnContext extends AbstractSamlpElement implements Schema
3333 * \SimpleSAML\SAML2\XML\saml\AuthnContextClassRef|
3434 * \SimpleSAML\SAML2\XML\saml\AuthnContextDeclRef
3535 * )[] $requestedAuthnContexts
36- * @param \SimpleSAML\SAML2\XML\Comparison $Comparison
36+ * @param \SimpleSAML\SAML2\Type\AuthnContextComparisonTypeValue $Comparison
3737 */
3838 public function __construct (
3939 protected array $ requestedAuthnContexts = [],
40- protected ?Comparison $ Comparison = null ,
40+ protected ?AuthnContextComparisonTypeValue $ Comparison = null ,
4141 ) {
4242 Assert::maxCount ($ requestedAuthnContexts , C::UNBOUNDED_LIMIT );
4343 Assert::minCount ($ requestedAuthnContexts , 1 , SchemaViolationException::class);
@@ -79,9 +79,9 @@ public function getRequestedAuthnContexts(): array
7979 /**
8080 * Collect the value of the Comparison-property
8181 *
82- * @return \SimpleSAML\SAML2\XML\Comparison |null
82+ * @return \SimpleSAML\SAML2\Type\AuthnContextComparisonTypeValue |null
8383 */
84- public function getComparison (): ?Comparison
84+ public function getComparison (): ?AuthnContextComparisonTypeValue
8585 {
8686 return $ this ->Comparison ;
8787 }
@@ -101,19 +101,12 @@ public static function fromXML(DOMElement $xml): static
101101 Assert::same ($ xml ->localName , 'RequestedAuthnContext ' , InvalidDOMElementException::class);
102102 Assert::same ($ xml ->namespaceURI , RequestedAuthnContext::NS , InvalidDOMElementException::class);
103103
104- $ Comparison = self ::getOptionalAttribute (
105- $ xml ,
106- 'Comparison ' ,
107- SAMLStringValue::class,
108- SAMLStringValue::fromString ('unknown ' ),
109- );
110-
111104 return new static (
112105 array_merge (
113106 AuthnContextClassRef::getChildrenOfClass ($ xml ),
114107 AuthnContextDeclRef::getChildrenOfClass ($ xml ),
115108 ),
116- Comparison:: tryFrom ( $ Comparison-> getValue () ),
109+ self :: getOptionalAttribute ( $ xml , ' Comparison ' , AuthnContextComparisonTypeValue::class, null ),
117110 );
118111 }
119112
@@ -133,7 +126,7 @@ public function toXML(?DOMElement $parent = null): DOMElement
133126 }
134127
135128 if ($ this ->getComparison () !== null ) {
136- $ e ->setAttribute ('Comparison ' , $ this ->getComparison ()-> value );
129+ $ e ->setAttribute ('Comparison ' , strval ( $ this ->getComparison ()) );
137130 }
138131
139132 return $ e ;
0 commit comments