@@ -16,10 +16,12 @@ class OneLogin_Saml2_IdPMetadataParser
1616 * metadata contains more than one
1717 * IDPSSODescriptor, the first is returned
1818 * @param string $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
19+ * @param string $desiredSSOBinding Parse specific binding SSO endpoint.
20+ * @param string $desiredSLOBinding Parse specific binding SLO endpoint.
1921 *
2022 * @return array metadata info in php-saml settings format
2123 */
22- public static function parseRemoteXML ($ url , $ entityId = null , $ desiredNameIdFormat = null )
24+ public static function parseRemoteXML ($ url , $ entityId = null , $ desiredNameIdFormat = null , $ desiredSSOBinding = OneLogin_Saml2_Constants:: BINDING_HTTP_REDIRECT , $ desiredSLOBinding = OneLogin_Saml2_Constants:: BINDING_HTTP_REDIRECT )
2325 {
2426 $ metadataInfo = array ();
2527
@@ -33,7 +35,7 @@ public static function parseRemoteXML($url, $entityId = null, $desiredNameIdForm
3335
3436 $ xml = curl_exec ($ ch );
3537 if ($ xml !== false ) {
36- $ metadataInfo = self ::parseXML ($ xml , $ entityId );
38+ $ metadataInfo = self ::parseXML ($ xml , $ entityId, $ desiredSSOBinding , $ desiredSLOBinding );
3739 } else {
3840 throw new Exception (curl_error ($ ch ), curl_errno ($ ch ));
3941 }
@@ -51,17 +53,19 @@ public static function parseRemoteXML($url, $entityId = null, $desiredNameIdForm
5153 * metadata contains more than one
5254 * IDPSSODescriptor, the first is returned
5355 * @param string $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
56+ * @param string $desiredSSOBinding Parse specific binding SSO endpoint.
57+ * @param string $desiredSLOBinding Parse specific binding SLO endpoint.
5458 *
5559 * @return array metadata info in php-saml settings format
5660 */
57- public static function parseFileXML ($ filepath , $ entityId = null , $ desiredNameIdFormat = null )
61+ public static function parseFileXML ($ filepath , $ entityId = null , $ desiredNameIdFormat = null , $ desiredSSOBinding = OneLogin_Saml2_Constants:: BINDING_HTTP_REDIRECT , $ desiredSLOBinding = OneLogin_Saml2_Constants:: BINDING_HTTP_REDIRECT )
5862 {
5963 $ metadataInfo = array ();
6064
6165 try {
6266 if (file_exists ($ filepath )) {
6367 $ data = file_get_contents ($ filepath );
64- $ metadataInfo = self ::parseXML ($ data , $ entityId );
68+ $ metadataInfo = self ::parseXML ($ data , $ entityId, $ desiredSSOBinding , $ desiredSLOBinding );
6569 }
6670 } catch (Exception $ e ) {
6771 }
@@ -77,10 +81,12 @@ public static function parseFileXML($filepath, $entityId = null, $desiredNameIdF
7781 * metadata contains more than one
7882 * IDPSSODescriptor, the first is returned
7983 * @param string $desiredNameIdFormat If available on IdP metadata, use that nameIdFormat
84+ * @param string $desiredSSOBinding Parse specific binding SSO endpoint.
85+ * @param string $desiredSLOBinding Parse specific binding SLO endpoint.
8086 *
8187 * @return array metadata info in php-saml settings format
8288 */
83- public static function parseXML ($ xml , $ entityId = null , $ desiredNameIdFormat = null )
89+ public static function parseXML ($ xml , $ entityId = null , $ desiredNameIdFormat = null , $ desiredSSOBinding = OneLogin_Saml2_Constants:: BINDING_HTTP_REDIRECT , $ desiredSLOBinding = OneLogin_Saml2_Constants:: BINDING_HTTP_REDIRECT )
8490 {
8591 $ metadataInfo = array ();
8692
@@ -114,7 +120,7 @@ public static function parseXML($xml, $entityId = null, $desiredNameIdFormat = n
114120 $ metadataInfo ['idp ' ]['entityId ' ] = $ entityId ;
115121 }
116122
117- $ ssoNodes = OneLogin_Saml2_Utils::query ($ dom , './md:SingleSignOnService[@Binding=" ' .OneLogin_Saml2_Constants:: BINDING_HTTP_REDIRECT .'"] ' , $ idpDescriptor );
123+ $ ssoNodes = OneLogin_Saml2_Utils::query ($ dom , './md:SingleSignOnService[@Binding=" ' .$ desiredSSOBinding .'"] ' , $ idpDescriptor );
118124 if ($ ssoNodes ->length < 1 ) {
119125 $ ssoNodes = OneLogin_Saml2_Utils::query ($ dom , './md:SingleSignOnService ' , $ idpDescriptor );
120126 }
@@ -125,7 +131,7 @@ public static function parseXML($xml, $entityId = null, $desiredNameIdFormat = n
125131 );
126132 }
127133
128- $ sloNodes = OneLogin_Saml2_Utils::query ($ dom , './md:SingleLogoutService[@Binding=" ' .OneLogin_Saml2_Constants:: BINDING_HTTP_REDIRECT .'"] ' , $ idpDescriptor );
134+ $ sloNodes = OneLogin_Saml2_Utils::query ($ dom , './md:SingleLogoutService[@Binding=" ' .$ desiredSLOBinding .'"] ' , $ idpDescriptor );
129135 if ($ sloNodes ->length < 1 ) {
130136 $ sloNodes = OneLogin_Saml2_Utils::query ($ dom , './md:SingleLogoutService ' , $ idpDescriptor );
131137 }
@@ -156,7 +162,9 @@ public static function parseXML($xml, $entityId = null, $desiredNameIdFormat = n
156162 }
157163
158164 $ idpCertdata = $ metadataInfo ['idp ' ]['x509certMulti ' ];
159- if (count ($ idpCertdata ) == 1 || ((isset ($ idpCertdata ['signing ' ]) && count ($ idpCertdata ['signing ' ]) == 1 ) && isset ($ idpCertdata ['encryption ' ]) && count ($ idpCertdata ['encryption ' ]) == 1 && strcmp ($ idpCertdata ['signing ' ][0 ], $ idpCertdata ['encryption ' ][0 ]) == 0 )) {
165+ if (count ($ idpCertdata ) == 1 and
166+ ((isset ($ idpCertdata ['signing ' ]) and count ($ idpCertdata ['signing ' ]) == 1 ) or (isset ($ idpCertdata ['encryption ' ]) and count ($ idpCertdata ['encryption ' ]) == 1 )) or
167+ ((isset ($ idpCertdata ['signing ' ]) && count ($ idpCertdata ['signing ' ]) == 1 ) && isset ($ idpCertdata ['encryption ' ]) && count ($ idpCertdata ['encryption ' ]) == 1 && strcmp ($ idpCertdata ['signing ' ][0 ], $ idpCertdata ['encryption ' ][0 ]) == 0 )) {
160168 if (isset ($ metadataInfo ['idp ' ]['x509certMulti ' ]['signing ' ][0 ])) {
161169 $ metadataInfo ['idp ' ]['x509cert ' ] = $ metadataInfo ['idp ' ]['x509certMulti ' ]['signing ' ][0 ];
162170 } else {
0 commit comments