function testGetUserPassApacheEdgeCase()
 {
     $server = array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic ' . base64_encode('admin:1234'));
     $request = new Sabre_HTTP_Request($server);
     $this->basicAuth->setHTTPRequest($request);
     $userPass = $this->basicAuth->getUserPass();
     $this->assertEquals(array('admin', '1234'), $userPass, 'We did not get the username and password we expected');
 }
 /**
  * Authenticates the user based on the current request.
  *
  * If authentication is succesful, true must be returned.
  * If authentication fails, an exception must be thrown.
  *
  * @throws Sabre_DAV_Exception_NotAuthenticated
  * @return bool
  */
 public function authenticate(Sabre_DAV_Server $server, $realm)
 {
     $auth = new Sabre_HTTP_BasicAuth();
     $auth->setHTTPRequest($server->httpRequest);
     $auth->setHTTPResponse($server->httpResponse);
     $auth->setRealm($realm);
     $userpass = $auth->getUserPass();
     if (!$userpass) {
         $auth->requireLogin();
         throw new Sabre_DAV_Exception_NotAuthenticated('No basic authentication headers were found');
     }
     // Authenticates the user
     if (!$this->validateUserPass($userpass[0], $userpass[1])) {
         $auth->requireLogin();
         throw new Sabre_DAV_Exception_NotAuthenticated('Username or password does not match');
     }
     $this->currentUser = $userpass[0];
     return true;
 }
 public function authenticate(Sabre_DAV_Server $server, $realm)
 {
     $auth = new Sabre_HTTP_BasicAuth();
     $auth->setHTTPRequest($server->httpRequest);
     $auth->setHTTPResponse($server->httpResponse);
     $auth->setRealm($realm);
     $userpass = $auth->getUserPass();
     if (!$userpass) {
         if (in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD', 'OPTIONS'))) {
             $userpass = array('', '');
         } else {
             $auth->requireLogin();
             throw new Sabre_DAV_Exception_NotAuthenticated('No basic authentication headers were found');
         }
     }
     // Authenticates the user
     if (!$this->validateUserPass($userpass[0], $userpass[1])) {
         $auth->requireLogin();
         throw new Sabre_DAV_Exception_NotAuthenticated('Username or password does not match');
     }
     $this->currentUser = $userpass[0];
     return true;
 }