/**
  * @param string $absoluteURI
  * @param array  $variables
  * @test
  * @dataProvider provideDataForAbsoluteURI
  */
 public function getsTheAbsoluteUri($absoluteURI, array $variables)
 {
     foreach ($variables as $key => $value) {
         $_SERVER[$key] = $value;
     }
     $this->assertEquals($absoluteURI, Stagehand_HTTP_ServerEnv::getAbsoluteURI());
 }
 /**
  * Invokes the plugin specific code.
  *
  * @return boolean
  * @throws Piece_Unity_Exception
  */
 public function intercept()
 {
     $this->_prepareAuthenticationState();
     $uri = $this->getConfiguration('uri');
     if (!$uri) {
         throw new Piece_Unity_Exception("The value of the configuration point [ uri ] on the plug-in [ {$this->_name} ] is required");
     }
     if ($this->_isAuthenticationURI($uri)) {
         return true;
     }
     $excludes = $this->getConfiguration('excludes');
     if ($excludes) {
         if (!is_array($excludes)) {
             throw new Piece_Unity_Exception("The value of the configuration point [ excludes ] on the plug-in [ {$this->_name} ] should be an array");
         }
         foreach ($excludes as $exclude) {
             if (preg_match("!{$exclude}!", $this->_scriptName)) {
                 return true;
             }
         }
     }
     $isProtectedResource = false;
     $includes = $this->getConfiguration('includes');
     if ($includes) {
         if (!is_array($includes)) {
             throw new Piece_Unity_Exception("The value of the configuration point [ includes ] on the plug-in [ {$this->_name} ] should be an array");
         }
         foreach ($includes as $include) {
             if (preg_match("!{$include}!", $this->_scriptName)) {
                 $isProtectedResource = true;
                 break;
             }
         }
     }
     $session = $this->context->getSession();
     $session->setPreloadCallback('_Interceptor_Authentication_StateLoader', array(__CLASS__, 'loadAuthenticationState'));
     $session->addPreloadClass('_Interceptor_Authentication_StateLoader', 'Piece_Unity_Service_Autentication_State');
     if (!$isProtectedResource) {
         return true;
     }
     $realm = $this->getConfiguration('realm');
     if ($this->_authenticationState->isAuthenticated($realm)) {
         if ($this->_authenticationState->hasCallbackURI($realm)) {
             $this->_authenticationState->removeCallbackURI($realm);
         }
         return true;
     } else {
         $this->_authenticationState->setCallbackURI($realm, Stagehand_HTTP_ServerEnv::getAbsoluteURI());
         $this->context->setView($uri);
         return false;
     }
 }