99
1010class ADFS
1111{
12+ /**
13+ * @param \SimpleSAML\IdP @idp
14+ * @return void
15+ * @throws \SimpleSAML\Error\Error
16+ */
1217 public static function receiveAuthnRequest (\SimpleSAML \IdP $ idp )
1318 {
1419 try {
@@ -41,6 +46,15 @@ public static function receiveAuthnRequest(\SimpleSAML\IdP $idp)
4146 $ idp ->handleAuthenticationRequest ($ state );
4247 }
4348
49+
50+ /**
51+ * @param string $issuer
52+ * @param string $target
53+ * @param string $nameid
54+ * @param array $attributes
55+ * @param int $assertionLifetime
56+ * @return string
57+ */
4458 private static function generateResponse ($ issuer , $ target , $ nameid , $ attributes , $ assertionLifetime )
4559 {
4660 $ issueInstant = \SimpleSAML \Utils \Time::generateTimestamp ();
@@ -108,13 +122,26 @@ private static function generateResponse($issuer, $target, $nameid, $attributes,
108122 return $ result ;
109123 }
110124
125+
126+ /**
127+ * @param string $response
128+ * @param string $key
129+ * @param string $cert
130+ * @param string $algo
131+ * @return string
132+ */
111133 private static function signResponse ($ response , $ key , $ cert , $ algo )
112134 {
113135 $ objXMLSecDSig = new XMLSecurityDSig ();
114136 $ objXMLSecDSig ->idKeys = ['AssertionID ' ];
115137 $ objXMLSecDSig ->setCanonicalMethod (XMLSecurityDSig::EXC_C14N );
116138 $ responsedom = \SAML2 \DOMDocumentFactory::fromString (str_replace ("\r" , "" , $ response ));
117139 $ firstassertionroot = $ responsedom ->getElementsByTagName ('Assertion ' )->item (0 );
140+
141+ if (is_null ($ firstassertionroot )) {
142+ throw new \Exception ("No assertion found in response. " );
143+ }
144+
118145 $ objXMLSecDSig ->addReferenceList (
119146 [$ firstassertionroot ],
120147 XMLSecurityDSig::SHA256 ,
@@ -129,11 +156,20 @@ private static function signResponse($response, $key, $cert, $algo)
129156 $ public_cert = file_get_contents ($ cert );
130157 $ objXMLSecDSig ->add509Cert ($ public_cert , true );
131158 }
159+
160+ /** @var \DOMElement $objXMLSecDSig->sigNode */
132161 $ newSig = $ responsedom ->importNode ($ objXMLSecDSig ->sigNode , true );
133162 $ firstassertionroot ->appendChild ($ newSig );
134163 return $ responsedom ->saveXML ();
135164 }
136165
166+
167+ /**
168+ * @param string $url
169+ * @param string $wresult
170+ * @param string $wctx
171+ * @return void
172+ */
137173 private static function postResponse ($ url , $ wresult , $ wctx )
138174 {
139175 $ config = \SimpleSAML \Configuration::getInstance ();
@@ -193,6 +229,7 @@ public static function getHostedMetadata($entityid)
193229 $ hasNewCert = true ;
194230 }
195231
232+ /** @var array $certInfo */
196233 $ certInfo = Crypto::loadPublicKey ($ config , true );
197234 $ keys [] = [
198235 'type ' => 'X509Certificate ' ,
@@ -203,6 +240,7 @@ public static function getHostedMetadata($entityid)
203240 ];
204241
205242 if ($ config ->hasValue ('https.certificate ' )) {
243+ /** @var array $httpsCert */
206244 $ httpsCert = Crypto::loadPublicKey ($ config , true , 'https. ' );
207245 $ keys [] = [
208246 'type ' => 'X509Certificate ' ,
@@ -223,7 +261,7 @@ public static function getHostedMetadata($entityid)
223261 );
224262
225263 if (!$ config ->hasValue ('OrganizationURL ' )) {
226- throw new \SimpleSAMl \Error \Exception ('If OrganizationName is set, OrganizationURL must also be set. ' );
264+ throw new \SimpleSAML \Error \Exception ('If OrganizationName is set, OrganizationURL must also be set. ' );
227265 }
228266 $ metadata ['OrganizationURL ' ] = $ config ->getLocalizedString ('OrganizationURL ' );
229267 }
@@ -271,6 +309,11 @@ public static function getHostedMetadata($entityid)
271309 }
272310
273311
312+ /**
313+ * @param array $state
314+ * @throws \Exception
315+ * @return void
316+ */
274317 public static function sendResponse (array $ state )
275318 {
276319 $ spMetadata = $ state ["SPMetadata " ];
@@ -323,6 +366,12 @@ public static function sendResponse(array $state)
323366 ADFS ::postResponse ($ wreply , $ wresult , $ wctx );
324367 }
325368
369+
370+ /**
371+ * @param \SimpleSAML\IdP $idp
372+ * @param array $state
373+ * @return void
374+ */
326375 public static function sendLogoutResponse (\SimpleSAML \IdP $ idp , array $ state )
327376 {
328377 // NB:: we don't know from which SP the logout request came from
@@ -332,6 +381,12 @@ public static function sendLogoutResponse(\SimpleSAML\IdP $idp, array $state)
332381 );
333382 }
334383
384+
385+ /**
386+ * @param \SimpleSAML\IdP $idp
387+ * @throws \Exception
388+ * @return void
389+ */
335390 public static function receiveLogoutMessage (\SimpleSAML \IdP $ idp )
336391 {
337392 // if a redirect is to occur based on wreply, we will redirect to url as
@@ -351,7 +406,15 @@ public static function receiveLogoutMessage(\SimpleSAML\IdP $idp)
351406 $ idp ->handleLogoutRequest ($ state , $ assocId );
352407 }
353408
354- // accepts an association array, and returns a URL that can be accessed to terminate the association
409+
410+ /**
411+ * accepts an association array, and returns a URL that can be accessed to terminate the association
412+ *
413+ * @param \SimpleSAML\IdP $idp
414+ * @param array $association
415+ * @param string $relayState
416+ * @return string
417+ */
355418 public static function getLogoutURL (\SimpleSAML \IdP $ idp , array $ association , $ relayState )
356419 {
357420 $ metadata = \SimpleSAML \Metadata \MetaDataStorageHandler::getMetadataHandler ();
0 commit comments