/**
  * Change level flags
  *
  * @param string $list
  * @param bool $state
  */
 private function _changeLevelFlags($list, $state)
 {
     $flags = Steelcode_String_Helper::explode(',', $list);
     foreach ($flags as $flag) {
         $this->_levelFlags[trim($flag)] = $state;
     }
 }
 /**
  * Decode the token
  *
  * @param string $token
  * @return true
  */
 protected function _decode($token)
 {
     $segments64 = Steelcode_String_Helper::explode('.', $token);
     if (count($segments64) !== 3) {
         $this->_setMessage('Wrong number of segments. Token is not a valid JSON web token');
         return false;
     }
     $segments = $segments64;
     foreach ($segments as $index => $value) {
         $segments[$index] = $this->urlSafeB64Decode($value);
         if ($index < 2) {
             $segments[$index] = Steelcode_Json_Helper::decode($segments[$index]);
         }
     }
     if (empty($segments[0])) {
         $this->_setMessage('Invalid header encoding');
         return false;
     }
     if (empty($segments[1])) {
         $this->_setMessage('Invalid claims encoding');
         return false;
     }
     if (empty($segments[0]->alg) || !isset($this->_methods[$segments[0]->alg])) {
         $this->_setMessage('Invalid or unsupported algorithm');
         return false;
     }
     $this->_algorithm = $segments[0]->alg;
     if (!$this->_verify("{$segments64[0]}.{$segments64[1]}", $segments[2], $this->_key, $this->_algorithm)) {
         $this->_setMessage('Signature verification failed');
         return false;
     }
     if (isset($segments[1]->nbf) && $segments[1]->nbf > Steelcode_Date_Helper::time() + $this->_leeway) {
         $this->_setMessage('Cannot handle this token before ' . Steelcode_Date_Helper::date(DateTime::ISO8601, $segments[1]->nbf));
         return false;
     }
     if (isset($segments[1]->iat) && $segments[1]->iat > Steelcode_Date_Helper::time() + $this->_leeway) {
         $this->_setMessage('Cannot handle token prior to ' . Steelcode_Date_Helper::date(DateTime::ISO8601, $segments[1]->iat));
         return false;
     }
     if (isset($segments[1]->exp) && Steelcode_Date_Helper::time() - $this->_leeway >= $segments[1]->exp) {
         $this->_setMessage('Token expired');
         return false;
     }
     $this->_header = (array) $segments[0];
     $this->_payload = (array) $segments[1];
     $this->_signature = $segments[2];
     return true;
 }
 /**
  * Check date of format yyyy-mm-dd is valid
  *
  * @param string $date
  * @return bool
  */
 public static function isValidDate($date)
 {
     if (empty($date)) {
         return false;
     }
     $segments = Steelcode_String_Helper::explode('-', $date);
     if (count($segments) != 3) {
         return false;
     }
     return checkdate($segments[1], $segments[2], $segments[0]);
 }
 /**
  * Extract controller and domain paths from request
  *
  * @param string $requestPath
  */
 private function _extractPath($requestPath)
 {
     $lastChar = substr($requestPath, -1);
     if ($lastChar == '/') {
         $this->_config->setDomain(trim($requestPath, '/'));
         $this->_config->setController('index');
         return;
     }
     $arrayReq = Steelcode_String_Helper::explode('/', $requestPath);
     if ($arrayReq[0] == '') {
         unset($arrayReq[0]);
     }
     $arrayLen = count($arrayReq);
     if ($arrayLen === 1) {
         $this->_config->setDomain('index');
         $this->_config->setController($arrayReq[1]);
     } elseif ($arrayLen > 1) {
         $this->_config->setDomain($arrayReq[1]);
         $this->_config->setController($arrayReq[2]);
         if ($arrayLen > 2) {
             unset($arrayReq[1], $arrayReq[2]);
             $this->_setUriAttributes($arrayReq);
         }
     } else {
         $this->_config->defaults();
     }
 }