66
77use DOMElement ;
88use SimpleSAML \SAML2 \Assert \Assert ;
9+ use SimpleSAML \SAML2 \Constants as C ;
10+ use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
911use SimpleSAML \SAML2 \Type \SAMLAnyURIValue ;
1012use SimpleSAML \SAML2 \Type \SAMLStringValue ;
1113use SimpleSAML \XML \TypedTextContentTrait ;
1214use SimpleSAML \XMLSchema \Exception \InvalidDOMElementException ;
1315
16+ use function array_column ;
1417use function strval ;
1518
1619/**
@@ -38,6 +41,26 @@ public function __construct(
3841 protected SAMLAnyURIValue $ namespace ,
3942 SAMLStringValue $ content ,
4043 ) {
44+ if ($ namespace ->equals (C::ACTION_RWEDC )) {
45+ Assert::oneOf (
46+ $ content ->getValue (),
47+ array_column (RWEDCEnum::cases (), 'value ' ),
48+ ProtocolViolationException::class,
49+ );
50+ } elseif ($ namespace ->equals (C::ACTION_RWEDC_NEGATION )) {
51+ Assert::oneOf (
52+ $ content ->getValue (),
53+ array_column (RWEDCNegationEnum::cases (), 'value ' ),
54+ ProtocolViolationException::class,
55+ );
56+ } elseif ($ namespace ->equals (C::ACTION_GHPP )) {
57+ Assert::oneOf (
58+ $ content ->getValue (),
59+ array_column (GHPPEnum::cases (), 'value ' ),
60+ ProtocolViolationException::class,
61+ );
62+ }
63+
4164 $ this ->setContent ($ content );
4265 }
4366
@@ -61,7 +84,7 @@ public function getNamespace(): SAMLAnyURIValue
6184 */
6285 public static function fromXML (DOMElement $ xml ): static
6386 {
64- Assert::same ($ xml ->localName , ' Action ' , InvalidDOMElementException::class);
87+ Assert::same ($ xml ->localName , static :: getLocalName () , InvalidDOMElementException::class);
6588 Assert::same ($ xml ->namespaceURI , Action::NS , InvalidDOMElementException::class);
6689
6790 return new self (
0 commit comments