/**
  * This class allows to check if the user is authorized to access the application
  * 
  * @return boolean True iuf he is authorized, false otherwise
  */
 public static function isAuthorized()
 {
     if (is_null(self::$isAuthorized)) {
         self::$isAuthorized = false;
         $configs = Config::get('auth_unittest_applications');
         if (!$configs || !is_array($configs)) {
             throw new ConfigMissingParameterException();
         }
         if (isset(self::$attributes['application_name']) && isset(self::$attributes['application_secret'])) {
             foreach ($configs as $app => $secret) {
                 if (self::$attributes['application_name'] == $app && self::$attributes['application_secret'] == $secret) {
                     self::$isAuthorized = true;
                 }
             }
         }
     }
     return self::$isAuthorized;
 }
예제 #2
0
 /**
  * Delegates authentication check.
  * 
  * @return bool
  */
 public static function isAuthorized()
 {
     if (is_null(self::$attributes)) {
         // Not already cached
         self::user();
     }
     if (is_null(self::$authorized)) {
         // Not already cached
         self::$authorized = false;
         if (self::$isLocal && AuthLocalApplication::isAuthorized()) {
             // SP
             self::$authorized = true;
         } else {
             if (self::$isSP && AuthSP::isAuthorized()) {
                 // SP
                 self::$authorized = true;
             }
         }
     }
     return self::$authorized;
 }