@@ -162,8 +162,8 @@ private function __construct($transient = FALSE) {
162162 public function __wakeup () {
163163 $ this ->addShutdownFunction ();
164164 }
165-
166-
165+
166+
167167 /**
168168 * Retrieves the current session. Will create a new session if there isn't a session.
169169 *
@@ -240,7 +240,8 @@ public function getSessionId() {
240240 public function getTrackID () {
241241 return $ this ->trackid ;
242242 }
243-
243+
244+
244245 /**
245246 * Who authorized this session. could be in example saml2, shib13, login,login-admin etc.
246247 */
@@ -277,7 +278,8 @@ public function getAuthnRequest($protocol, $requestid) {
277278
278279 return $ authnRequest ;
279280 }
280-
281+
282+
281283 /**
282284 * This method sets a cached assoc array to the authentication request cache storage.
283285 *
@@ -286,40 +288,81 @@ public function getAuthnRequest($protocol, $requestid) {
286288 * @param $cache The assoc array that will be stored.
287289 */
288290 public function setAuthnRequest ($ protocol , $ requestid , array $ cache ) {
289-
291+
290292 SimpleSAML_Logger::debug ('Library - Session: Set authnrequest ' . $ protocol . ' time: ' . time () . ' size: ' . count ($ cache ) . ' id: ' . $ requestid );
291293
292294 $ type = 'AuthnRequest- ' . $ protocol ;
293295 $ this ->setData ($ type , $ requestid , $ cache );
294296 }
295-
296-
297297
298298
299+ /**
300+ * Set the IdP we are authenticated against.
301+ *
302+ * @param string|NULL $idp Our current IdP, or NULL if we aren't authenticated with an IdP.
303+ */
299304 public function setIdP ($ idp ) {
300-
305+ assert ('is_string($idp) || is_null($idp) ' );
306+
301307 SimpleSAML_Logger::debug ('Library - Session: Set IdP to : ' . $ idp );
302308 $ this ->dirty = true ;
303309 $ this ->idp = $ idp ;
304310 }
311+
312+
313+ /**
314+ * Retrieve the IdP we are currently authenticated against.
315+ *
316+ * @return string|NULL Our current IdP, or NULL if we aren't authenticated with an IdP.
317+ */
305318 public function getIdP () {
306319 return $ this ->idp ;
307320 }
308-
309321
322+
323+ /**
324+ * Set the SessionIndex we received from our IdP.
325+ *
326+ * @param string|NULL $sessionindex Our SessionIndex.
327+ */
310328 public function setSessionIndex ($ sessionindex ) {
329+ assert ('is_string($sessionindex) || is_null($sessionindex) ' );
330+
311331 SimpleSAML_Logger::debug ('Library - Session: Set sessionindex: ' . $ sessionindex );
312332 $ this ->dirty = true ;
313333 $ this ->sessionindex = $ sessionindex ;
314334 }
335+
336+
337+ /**
338+ * Retrieve our SessionIndex.
339+ *
340+ * @return string|NULL Our SessionIndex.
341+ */
315342 public function getSessionIndex () {
316343 return $ this ->sessionindex ;
317344 }
345+
346+
347+ /**
348+ * Set our current NameID.
349+ *
350+ * @param array|NULL $nameid The NameID we received from the IdP
351+ */
318352 public function setNameID ($ nameid ) {
353+ assert ('is_array($nameid) || is_null($nameid) ' );
354+
319355 SimpleSAML_Logger::debug ('Library - Session: Set nameID: ' );
320356 $ this ->dirty = true ;
321357 $ this ->nameid = $ nameid ;
322358 }
359+
360+
361+ /**
362+ * Get our NameID.
363+ *
364+ * @return array|NULL The NameID we received from the IdP.
365+ */
323366 public function getNameID () {
324367 return $ this ->nameid ;
325368 }
@@ -382,14 +425,21 @@ public function doLogout() {
382425 }
383426
384427
428+ /**
429+ * Set the lifetime of our current authentication session.
430+ *
431+ * @param int $duration The number of seconds this authentication session is valid.
432+ */
385433 public function setSessionDuration ($ duration ) {
434+ assert ('is_int($duration) ' );
435+
386436 SimpleSAML_Logger::debug ('Library - Session: Set session duration ' . $ duration );
387437 $ this ->dirty = true ;
388438 $ this ->sessionduration = $ duration ;
389439 }
390-
391-
392- /*
440+
441+
442+ /**
393443 * Is the session representing an authenticated user, and is the session still alive.
394444 * This function will return false after the user has timed out.
395445 *
@@ -413,16 +463,21 @@ public function isValid($authority) {
413463
414464 return $ this ->remainingTime () > 0 ;
415465 }
416-
417- /*
466+
467+
468+ /**
418469 * If the user is authenticated, how much time is left of the session.
470+ *
471+ * @return int The number of seconds until the session expires.
419472 */
420473 public function remainingTime () {
421474 return $ this ->sessionduration - (time () - $ this ->sessionstarted );
422475 }
423476
424- /*
477+ /**
425478 * Is the user authenticated. This function does not check the session duration.
479+ *
480+ * @return bool TRUE if the user is authenticated, FALSE otherwise.
426481 */
427482 public function isAuthenticated () {
428483 return $ this ->authenticated ;
@@ -441,28 +496,52 @@ public function getAuthnInstant() {
441496
442497 return $ this ->sessionstarted ;
443498 }
444-
445-
446- // *** Attributes ***
447-
499+
500+
501+ /**
502+ * Retrieve the attributes associated with this session.
503+ *
504+ * @return array|NULL The attributes.
505+ */
448506 public function getAttributes () {
449507 return $ this ->attributes ;
450508 }
451509
510+
511+ /**
512+ * Retrieve a single attribute.
513+ *
514+ * @param string $name The name of the attribute.
515+ * @return array|NULL The values of the given attribute.
516+ */
452517 public function getAttribute ($ name ) {
453518 return $ this ->attributes [$ name ];
454519 }
455520
521+
522+ /**
523+ * Set the attributes for this session.
524+ *
525+ * @param array|NULL $attributes The attributes of this session.
526+ */
456527 public function setAttributes ($ attributes ) {
457528 $ this ->dirty = true ;
458529 $ this ->attributes = $ attributes ;
459530 }
460-
531+
532+
533+ /**
534+ * Set the values of a single attribute.
535+ *
536+ * @param string $name The name of the attribute.
537+ * @param array $value The values of the attribute.
538+ */
461539 public function setAttribute ($ name , $ value ) {
462540 $ this ->dirty = true ;
463541 $ this ->attributes [$ name ] = $ value ;
464542 }
465-
543+
544+
466545 /**
467546 * Calculates the size of the session object after serialization
468547 *
@@ -825,8 +904,7 @@ private function addShutdownFunction() {
825904 *
826905 * @param array $state The state array.
827906 */
828- public function setLogoutState ($ state ) {
829- assert ('is_array($state) ' );
907+ public function setLogoutState (array $ state ) {
830908
831909 $ this ->dirty = TRUE ;
832910 $ this ->logoutState = $ state ;
@@ -1009,5 +1087,3 @@ public function get_sp_list() {
10091087 }
10101088
10111089}
1012-
1013- ?>
0 commit comments