/**
  * Checks that we have a token and an optional password giving access to a
  * valid resource. Sets the token based environment after that
  *
  * @throws CheckException
  */
 private function validateAndSetTokenBasedEnv()
 {
     $token = $this->request->getParam('token');
     if (!$token) {
         throw new CheckException("Can't access a public resource without a token", Http::STATUS_NOT_FOUND);
     } else {
         $linkItem = $this->getLinkItem($token);
         $password = $this->request->getParam('password');
         // Let's see if the user needs to provide a password
         $this->checkAuthorisation($linkItem, $password);
         $this->environment->setTokenBasedEnv($linkItem);
     }
 }
 /**
  * Checks that we have a token and an optional password giving access to a
  * valid resource. Sets the token based environment after that
  */
 private function validateAndSetTokenBasedEnv()
 {
     $token = $this->request->getParam('token');
     if (!$token) {
         $this->noTokenFound();
     } else {
         // We have a token
         // Let's see if it's linked to a valid resource
         $linkItem = $this->getLinkItem($token);
         $password = $this->request->getParam('password');
         // Let's see if the user needs to provide a password
         $this->checkAuthorisation($linkItem, $password);
         $this->environment->setTokenBasedEnv($linkItem);
     }
 }