@@ -102,6 +102,8 @@ private function casValidate($ticket, $service)
102102 'service ' => $ service ,
103103 ]);
104104 $ result = \SimpleSAML \Utils \HTTP ::fetch ($ url );
105+
106+ /** @var string $result */
105107 $ res = preg_split ("/ \r? \n/ " , $ result );
106108
107109 if (strcmp ($ res [0 ], "yes " ) == 0 ) {
@@ -131,6 +133,7 @@ private function casServiceValidate($ticket, $service)
131133 );
132134 $ result = \SimpleSAML \Utils \HTTP ::fetch ($ url );
133135
136+ /** @var string $result */
134137 $ dom = \SAML2 \DOMDocumentFactory::fromString ($ result );
135138 $ xPath = new \DOMXpath ($ dom );
136139 $ xPath ->registerNamespace ("cas " , 'http://www.yale.edu/tp/cas ' );
@@ -149,7 +152,12 @@ private function casServiceValidate($ticket, $service)
149152 }
150153 }
151154 }
152- $ casusername = $ success ->item (0 )->textContent ;
155+
156+ $ item = $ success ->item (0 );
157+ if (is_null ($ item )) {
158+ throw new \Exception ("Error parsing serviceResponse. " );
159+ }
160+ $ casusername = $ item ->textContent ;
153161
154162 return [$ casusername , $ attributes ];
155163 }
@@ -195,7 +203,7 @@ public function finalStep(&$state)
195203 'Authentication source ' .var_export ($ this ->authId , true )
196204 );
197205 if ($ this ->ldapConfig ['servers ' ]) {
198- $ ldap = new \SimpleSAML \Auth \LDAP (
206+ $ ldap = new \SimpleSAML \Module \ ldap \ Auth \Ldap (
199207 $ config ->getString ('servers ' ),
200208 $ config ->getBoolean ('enable_tls ' , false ),
201209 $ config ->getBoolean ('debug ' , false ),
@@ -204,6 +212,9 @@ public function finalStep(&$state)
204212 $ config ->getBoolean ('referrals ' , true )
205213 );
206214 $ ldapattributes = $ ldap ->validate ($ this ->ldapConfig , $ username );
215+ if ($ ldapattributes === false ) {
216+ throw new \Exception ("Failed to authenticate against LDAP-server. " );
217+ }
207218 }
208219 $ attributes = array_merge_recursive ($ casattributes , $ ldapattributes );
209220 $ state ['Attributes ' ] = $ attributes ;
0 commit comments