1919
2020use Stormpath \Client ;
2121use Stormpath \DataStore \InternalDataStore ;
22+ use Stormpath \Saml \AttributeStatementMappingRules ;
2223use Stormpath \Stormpath ;
2324
2425/** @since 1.13.0 */
25- class SamlProvider extends Provider
26+ class SamlProvider extends Provider implements Saveable
2627{
27- const SSO_LOGIN_URL = "ssoLoginUrl " ;
28- const SSO_LOGOUT_URL = "ssoLogoutUrl " ;
29- const ENCODED_X509_SIGNING_CERT = "encodedX509SigningCert " ;
30- const REQUEST_SIGNATURE_ALGOITHM = "requestSignatureAlgorithm " ;
31- const SAML_PROVIDER_METADATA = "serviceProviderMetadata " ;
32- const SAML_PROVIDER_ID = "saml " ;
28+ const SSO_LOGIN_URL = "ssoLoginUrl " ;
29+ const SSO_LOGOUT_URL = "ssoLogoutUrl " ;
30+ const ENCODED_X509_SIGNING_CERT = "encodedX509SigningCert " ;
31+ const REQUEST_SIGNATURE_ALGOITHM = "requestSignatureAlgorithm " ;
32+ const ATTRIBUTE_STATEMENT_MAPPING_RULES = "attributeStatementMappingRules " ;
33+ const SAML_PROVIDER_METADATA = "serviceProviderMetadata " ;
34+
35+ const SAML_PROVIDER_ID = "saml " ;
36+
37+ public function __construct (InternalDataStore $ dataStore = null , \stdClass $ properties = null )
38+ {
39+ parent ::__construct ($ dataStore , $ properties );
40+ $ this ->setProperty (self ::PROVIDER_ID , self ::SAML_PROVIDER_ID );
41+ }
3342
3443 /**
3544 * Retreive a SAML Provider based on the Href.
@@ -46,27 +55,21 @@ public static function get($href, array $options = [])
4655 $ href = $ href .'/ ' .self ::PATH ;
4756 }
4857
49- return Client::get ($ href , Stormpath::SAML_PROVIDER , Directory:: PATH , $ options );
58+ return Client::get ($ href , Stormpath::SAML_PROVIDER , null , $ options );
5059 }
5160
5261 /**
53- * Create an instance of SAML Provider.
62+ * Create a new SAML Provider instance with properties .
5463 *
5564 * @since 1.13.0
56- * @param null| array $properties
65+ * @param array|null $properties
5766 * @return \Stormpath\Resource\SamlProvider
5867 */
5968 public static function instantiate ($ properties = null )
6069 {
6170 return Client::instantiate (Stormpath::SAML_PROVIDER , $ properties );
6271 }
6372
64- public function __construct (InternalDataStore $ dataStore = null , \stdClass $ properties = null )
65- {
66- parent ::__construct ($ dataStore , $ properties );
67- $ this ->setProperty (self ::PROVIDER_ID , self ::SAML_PROVIDER_ID );
68- }
69-
7073 /**
7174 * The URL at the IdP to which SAML authentication requests should be sent.
7275 * This is often called an “SSO URL”, “Login URL” or “Sign-in URL”
@@ -121,13 +124,26 @@ public function getRequestSignatureAlgorithm()
121124 *
122125 * @since 1.13.0
123126 * @param array $options
124- * @return null| \Stormpath\DataStore\a
127+ * @return \Stormpath\Resource\SamlProviderData
125128 */
126129 public function getServiceProviderMetadata (array $ options = [])
127130 {
128- return $ this ->getResourceProperty (self ::SAML_PROVIDER_METADATA , Stormpath::SAML_PROVIDER_METADATA , $ options );
131+ return $ this ->getResourceProperty (self ::SAML_PROVIDER_METADATA , Stormpath::SAML_PROVIDER_DATA , $ options );
129132 }
130133
134+ /**
135+ * Get the Attribute Statement Mapping Rules for the SAML Provider.
136+ *
137+ * @since 1.13.0
138+ * @param array $options
139+ * @return \Stormpath\Saml\AttributeStatementMappingRules
140+ */
141+ public function getAttributeStatementMappingRules (array $ options = [])
142+ {
143+ return $ this ->getResourceProperty (self ::ATTRIBUTE_STATEMENT_MAPPING_RULES , Stormpath::ATTRIBUTE_STATEMENT_MAPPING_RULES , $ options );
144+ }
145+
146+
131147 /**
132148 * Set the URL at the IdP to which SAML authentication requests should be sent.
133149 * This is often called an “SSO URL”, “Login URL” or “Sign-in URL”
@@ -185,4 +201,21 @@ public function setRequestSignatureAlgorithm($requestSignatureAlgorithm)
185201 return $ this ;
186202 }
187203
204+ /**
205+ * Set the Attribute Statement Mapping Rules for the SAML Provider.
206+ *
207+ * @since 1.13.0
208+ * @param AttributeStatementMappingRules $attributeStatementMappingRules
209+ * @return self
210+ */
211+ public function setAttributeStatementMappingRules (AttributeStatementMappingRules $ attributeStatementMappingRules )
212+ {
213+ $ this ->setProperty (self ::ATTRIBUTE_STATEMENT_MAPPING_RULES , $ attributeStatementMappingRules );
214+ return $ this ;
215+ }
216+
217+ public function save ()
218+ {
219+ $ this ->getDataStore ()->save ($ this );
220+ }
188221}
0 commit comments