77use DOMElement ;
88use SimpleSAML \SAML2 \Assert \Assert ;
99use SimpleSAML \SAML2 \Constants as C ;
10- use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
11- use SimpleSAML \SAML2 \Type \SAMLStringValue ;
12- use SimpleSAML \SAML2 \XML \Decision ;
10+ use SimpleSAML \SAML2 \Type \DecisionTypeValue ;
1311use SimpleSAML \XML \Exception \{
1412 InvalidDOMElementException ,
1513 MissingElementException ,
1816};
1917use SimpleSAML \XML \{SchemaValidatableElementInterface , SchemaValidatableElementTrait };
2018use SimpleSAML \XML \Type \AnyURIValue ;
21- use ValueError ;
2219
2320use function array_pop ;
24- use function sprintf ;
21+ use function strval ;
2522
2623/**
2724 * Class representing a SAML2 AuthzDecisionStatement
@@ -35,15 +32,15 @@ final class AuthzDecisionStatement extends AbstractStatementType implements Sche
3532 /**
3633 * Initialize an AuthzDecisionStatement.
3734 *
38- * @param \SimpleSAML\SAML2 \Type\SAMLAnyURIValue $resource
39- * @param \SimpleSAML\SAML2\XML\Decision $decision
35+ * @param \SimpleSAML\XML \Type\AnyURIValue $resource
36+ * @param \SimpleSAML\SAML2\Type\DecisionTypeValue $decision
4037 * @param \SimpleSAML\SAML2\XML\saml\Action[] $action
4138 * @param \SimpleSAML\SAML2\XML\saml\Evidence|null $evidence
4239 */
4340 public function __construct (
4441 // Uses the base AnyURIValue because the SAML-specification allows this attribute to be an empty string
4542 protected AnyURIValue $ resource ,
46- protected Decision $ decision ,
43+ protected DecisionTypeValue $ decision ,
4744 protected array $ action ,
4845 protected ?Evidence $ evidence = null ,
4946 ) {
@@ -66,9 +63,9 @@ public function getResource(): AnyURIValue
6663 /**
6764 * Collect the value of the decision-property
6865 *
69- * @return \SimpleSAML\SAML2\XML\Decision
66+ * @return \SimpleSAML\SAML2\Type\DecisionTypeValue
7067 */
71- public function getDecision (): Decision
68+ public function getDecision (): DecisionTypeValue
7269 {
7370 return $ this ->decision ;
7471 }
@@ -129,16 +126,10 @@ public static function fromXML(DOMElement $xml): static
129126 TooManyElementsException::class,
130127 );
131128
132- $ decision = self ::getAttribute ($ xml , 'Decision ' , SAMLStringValue::class);
133- try {
134- $ decision = Decision::from ($ decision ->getValue ());
135- } catch (ValueError ) {
136- throw new ProtocolViolationException (sprintf ('Unknown value \'%s \' for Decision attribute. ' , $ decision ));
137- }
138129
139130 return new static (
140131 self ::getAttribute ($ xml , 'Resource ' , AnyURIValue::class),
141- $ decision ,
132+ self :: getAttribute ( $ xml , ' Decision ' , DecisionTypeValue::class) ,
142133 $ action ,
143134 array_pop ($ evidence ),
144135 );
@@ -155,8 +146,8 @@ public function toXML(?DOMElement $parent = null): DOMElement
155146 {
156147 $ e = $ this ->instantiateParentElement ($ parent );
157148
158- $ e ->setAttribute ('Resource ' , $ this ->getResource ()-> getValue ( ));
159- $ e ->setAttribute ('Decision ' , $ this ->getDecision ()-> value );
149+ $ e ->setAttribute ('Resource ' , strval ( $ this ->getResource ()));
150+ $ e ->setAttribute ('Decision ' , strval ( $ this ->getDecision ()) );
160151
161152 foreach ($ this ->getAction () as $ action ) {
162153 $ action ->toXML ($ e );
0 commit comments