File tree Expand file tree Collapse file tree 5 files changed +54
-30
lines changed
Expand file tree Collapse file tree 5 files changed +54
-30
lines changed Original file line number Diff line number Diff line change 2525 */
2626abstract class Binding
2727{
28- /**
29- * The RelayState associated with the message.
30- *
31- * @var string|null
32- */
33- protected ?string $ relayState = null ;
34-
3528 /**
3629 * The destination of messages.
3730 *
@@ -156,29 +149,6 @@ public function getDestination(): ?string
156149 }
157150
158151
159- /**
160- * Set the RelayState associated with he message.
161- *
162- * @param string|null $relayState The RelayState.
163- */
164- public function setRelayState (?string $ relayState = null ): void
165- {
166- Assert::nullOrValidRelayState ($ relayState );
167- $ this ->relayState = $ relayState ;
168- }
169-
170-
171- /**
172- * Get the RelayState associated with the message.
173- *
174- * @return string|null The RelayState.
175- */
176- public function getRelayState (): ?string
177- {
178- return $ this ->relayState ;
179- }
180-
181-
182152 /**
183153 * Override the destination of a message.
184154 *
Original file line number Diff line number Diff line change 1414use SimpleSAML \Metadata \MetaDataStorageHandler ;
1515use SimpleSAML \Module \saml \Message as MSG ;
1616use SimpleSAML \SAML2 \Binding ;
17+ use SimpleSAML \SAML2 \Binding \RelayStateTrait ;
1718use SimpleSAML \SAML2 \SOAPClient ;
1819use SimpleSAML \SAML2 \Utils ;
1920use SimpleSAML \SAML2 \XML \saml \Issuer ;
4344 */
4445class HTTPArtifact extends Binding
4546{
47+ use RelayStateTrait;
48+
4649 /**
4750 * @psalm-suppress UndefinedDocblockClass
4851 * @psalm-suppress UndefinedClass
Original file line number Diff line number Diff line change 1010use Psr \Http \Message \ServerRequestInterface ;
1111use SimpleSAML \Assert \Assert ;
1212use SimpleSAML \SAML2 \Binding ;
13+ use SimpleSAML \SAML2 \Binding \RelayStateTrait ;
1314use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
1415use SimpleSAML \SAML2 \Utils ;
1516use SimpleSAML \SAML2 \XML \samlp \AbstractMessage ;
2829 */
2930class HTTPPost extends Binding
3031{
32+ use RelayStateTrait;
33+
3134 /**
3235 * Send a SAML 2 message using the HTTP-POST binding.
3336 *
Original file line number Diff line number Diff line change 1010use Psr \Http \Message \ServerRequestInterface ;
1111use SimpleSAML \Assert \Assert ;
1212use SimpleSAML \SAML2 \Binding ;
13+ use SimpleSAML \SAML2 \Binding \RelayStateTrait ;
1314use SimpleSAML \SAML2 \Compat \ContainerSingleton ;
1415use SimpleSAML \SAML2 \Constants as C ;
1516use SimpleSAML \SAML2 \Exception \ProtocolViolationException ;
3940 */
4041class HTTPRedirect extends Binding
4142{
43+ use RelayStateTrait;
44+
4245 /**
4346 * Create the redirect URL for a message.
4447 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace SimpleSAML \SAML2 \Binding ;
6+
7+ use SimpleSAML \SAML2 \Assert \Assert ;
8+
9+ /**
10+ * Trait grouping common functionality for binding that use a RelayState.
11+ *
12+ * @package simplesamlphp/saml2
13+ */
14+ trait RelayStateTrait
15+ {
16+ /**
17+ * The relay state.
18+ *
19+ * @var string|null
20+ */
21+ protected ?string $ relayState = null ;
22+
23+
24+ /**
25+ * Set the RelayState associated with he message.
26+ *
27+ * @param string|null $relayState The RelayState.
28+ */
29+ public function setRelayState (?string $ relayState = null ): void
30+ {
31+ Assert::nullOrValidRelayState ($ relayState );
32+ $ this ->relayState = $ relayState ;
33+ }
34+
35+
36+ /**
37+ * Get the RelayState associated with the message.
38+ *
39+ * @return string|null The RelayState.
40+ */
41+ public function getRelayState (): ?string
42+ {
43+ return $ this ->relayState ;
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments