*/ class XsrfTokenValidator extends \tao_helpers_form_Validator { /** * Validate an active XSRF token. * * @param string $values should be the token * @return boolean true only if valid * @throws \common_exception_Unauthorized if the token is not valid */ public function evaluate($values) { $tokenService = $this->getServiceManager()->get(TokenService::SERVICE_ID); if ($tokenService->checkToken($values)) { $tokenService->revokeToken($values); return true; } \common_Logger::e('Attempt to post a form with the incorrect token'); throw new \common_exception_Unauthorized('Invalid token ' . $values); } protected function getServiceManager() { return ServiceManager::getServiceManager(); } }