Пример #1
0
 $conf = new ConfigurationDao($db);
 $session = new WebDavSession();
 $env = new ServiceEnvironment($db, $session, new VoidResponseHandler(), $conf, $settings);
 $env->plugins()->setup();
 $rq = new Kloudspeaker_DAV_Request();
 $env->initialize($rq);
 // only basic auth supported
 $auth = new Sabre_HTTP_BasicAuth();
 $result = $auth->getUserPass();
 if (!$result) {
     Logging::logDebug("DAV authentication missing");
     $auth->requireLogin();
     echo "Authentication required\n";
     die;
 }
 $user = $env->configuration()->getUserByNameOrEmail($result[0]);
 if (!$user) {
     Logging::logDebug("DAV authentication failure");
     $auth->requireLogin();
     echo "Authentication required\n";
     die;
 }
 if (!$env->authentication()->authenticate($user["id"], $result[1])) {
     //$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");
Пример #2
0
    public function removeAllSessionBefore($time)
    {
    }
}
$settings = new Settings($CONFIGURATION);
$session = new CMDSession();
$f = new DBConnectionFactory();
$db = $f->createConnection($settings);
$configuration = new ConfigurationDao($db);
$env = new ServiceEnvironment($db, $session, new VoidResponseHandler(), $configuration, $settings);
$env->initialize(Request::get(TRUE));
$env->plugins()->setup();
$options = $opts["options"];
if (isset($options["user"])) {
    //TODO validate & auth
    $user = $env->configuration()->getUser($options["user"]);
    if (!$user) {
        echo "Invalid user: "******"user"] . "\n";
        return;
    }
    echo "Running as user: id=" . $user["id"] . " name=" . $user["name"] . "\n";
    $env->authentication()->setAuth($user);
}
$command = $opts["commands"][0];
if (!$env->commands()->exists($command)) {
    echo "Invalid command: " . $command . "\n";
    return;
}
echo "Command [" . $command . "]\n";
//TODO allow command registrations from plugins etc
try {