public function testDigest()
 {
     list($nonce, $opaque) = $this->getServerTokens();
     $username = '******';
     $password = 12345;
     $nc = '00002';
     $cnonce = uniqid();
     $digestHash = md5(md5($username . ':' . self::REALM . ':' . $password) . ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . 'auth:' . md5('GET' . ':' . '/'));
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'GET', 'PHP_AUTH_DIGEST' => 'username="******", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth,nc=' . $nc . ',cnonce="' . $cnonce . '"'));
     $this->auth->setHTTPRequest($request);
     $this->auth->init();
     $this->assertEquals($username, $this->auth->getUserName());
     $this->assertEquals(self::REALM, $this->auth->getRealm());
     $this->assertTrue($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . $password)), 'Authentication is deemed invalid through validateA1');
     $this->assertTrue($this->auth->validatePassword($password), 'Authentication is deemed invalid through validatePassword');
 }
Example #2
0
         echo "Authentication required\n";
         die;
     }
     $userAuth = $env->configuration()->getUserAuth($user["id"]);
     if (!$env->passwordHash()->isEqual($result[1], $userAuth["hash"], $userAuth["salt"])) {
         Logging::logDebug("DAV authentication failure");
         $auth->requireLogin();
         echo "Authentication required\n";
         die;
     }
     $env->authentication()->setAuth($user, "pw");
 } else {
     $auth = new Sabre_HTTP_DigestAuth();
     $auth->setRealm($env->authentication()->realm());
     $auth->init();
     $username = $auth->getUserName();
     if (!$username) {
         Logging::logDebug("DAV digest authentication missing");
         $auth->requireLogin();
         echo "Authentication required\n";
         die;
     }
     $user = $env->configuration()->getUserByNameOrEmail($username);
     if (!$user) {
         Logging::logDebug("DAV digest authentication failure");
         $auth->requireLogin();
         echo "Authentication required\n";
         die;
     }
     $userAuth = $env->configuration()->getUserAuth($user["id"]);
     if (!$auth->validateA1($userAuth["a1hash"])) {