setHTTPRequest($server->httpRequest); $digest->setHTTPResponse($server->httpResponse); $digest->setRealm($realm); $digest->init(); $username = $digest->getUsername(); // No username was given if (!$username) { $digest->requireLogin(); throw new Sabre_DAV_Exception_NotAuthenticated('No digest authentication headers were found'); } $hash = $this->getDigestHash($realm, $username); // If this was false, the user account didn't exist if ($hash===false || is_null($hash)) { $digest->requireLogin(); throw new Sabre_DAV_Exception_NotAuthenticated('The supplied username was not on file'); } if (!is_string($hash)) { throw new Sabre_DAV_Exception('The returned value from getDigestHash must be a string or null'); } // If this was false, the password or part of the hash was incorrect. if (!$digest->validateA1($hash)) { $digest->requireLogin(); throw new Sabre_DAV_Exception_NotAuthenticated('Incorrect username'); } $this->currentUser = $username; return true; } /** * Returns the currently logged in username. * * @return string|null */ public function getCurrentUser() { return $this->currentUser; } }