コード例 #1
0
ファイル: migrate.php プロジェクト: olucao/owncloud-core
 public function tearDown()
 {
     $u = new OC_User();
     foreach ($this->users as $user) {
         $u->deleteUser($user);
     }
     foreach ($this->tmpfiles as $file) {
         \OC_Helper::rmdirr($file);
     }
 }
コード例 #2
0
 public function authenticate(Sabre_DAV_Server $server, $realm)
 {
     $config = array("introspectionEndpoint" => $this->introspectionEndpoint, "realm" => $realm);
     try {
         $resourceServer = new RemoteResourceServer($config);
         $tokenIntrospection = $resourceServer->verifyRequest(apache_request_headers(), $_GET);
         $this->currentUser = $tokenIntrospection->getSub();
         OC_User::setUserid($this->currentUser);
         OC_Util::setupFS($this->currentUser);
         return true;
     } catch (RemoteResourceServerException $e) {
         switch ($e->getMessage()) {
             case "insufficient_entitlement":
             case "insufficient_scope":
                 $server->httpResponse->setHeader('WWW-Authenticate', $e->getAuthenticateHeader());
                 throw new Sabre_DAV_Exception_Forbidden($e->getDescription());
             case "invalid_request":
                 throw new Sabre_DAV_Exception_NotAuthenticated($e->getDescription());
             case "invalid_token":
             case "no_token":
                 $server->httpResponse->setHeader('WWW-Authenticate', $e->getAuthenticateHeader());
                 throw new Sabre_DAV_Exception_NotAuthenticated($e->getDescription());
             case "internal_server_error":
                 throw new Sabre_DAV_Exception($e->getDescription());
         }
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: venjek/ocdownloader
 public function __construct($AppName, IRequest $Request, $CurrentUID, IL10N $L10N)
 {
     parent::__construct($AppName, $Request);
     $this->CurrentUID = $CurrentUID;
     $this->L10N = $L10N;
     if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) {
         $this->DbType = 1;
     }
     $this->CanCheckForUpdate = Tools::CanCheckForUpdate();
     $this->Settings = new Settings();
     $this->Settings->SetKey('WhichDownloader');
     $this->WhichDownloader = $this->Settings->GetValue();
     $this->WhichDownloader = is_null($this->WhichDownloader) ? 'ARIA2' : $this->WhichDownloader;
     $this->Settings->SetKey('AllowProtocolHTTP');
     $this->AllowProtocolHTTP = $this->Settings->GetValue();
     $this->AllowProtocolHTTP = is_null($this->AllowProtocolHTTP) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolHTTP, 'Y') == 0;
     $this->Settings->SetKey('AllowProtocolFTP');
     $this->AllowProtocolFTP = $this->Settings->GetValue();
     $this->AllowProtocolFTP = is_null($this->AllowProtocolFTP) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolFTP, 'Y') == 0;
     $this->Settings->SetKey('AllowProtocolYT');
     $this->AllowProtocolYT = $this->Settings->GetValue();
     $this->AllowProtocolYT = is_null($this->AllowProtocolYT) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolYT, 'Y') == 0;
     $this->Settings->SetKey('AllowProtocolBT');
     $this->AllowProtocolBT = $this->Settings->GetValue();
     $this->AllowProtocolBT = is_null($this->AllowProtocolBT) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolBT, 'Y') == 0;
 }
コード例 #4
0
 public function register()
 {
     $loginRecord = function ($user) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('core', "user:"******" role:" . $UserRole . " action:login success", Util::INFO);
     };
     $logoutRecord = function () {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('core', "user:"******" role:" . $this->UserRole . " action:logout success", Util::INFO);
     };
     $createRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:"******" role:" . $UserRole . " action:creates " . $node->getName() . " success", Util::INFO);
     };
     $deleteRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:"******" role:" . $UserRole . " action:deletes " . $node->getName() . " success", Util::INFO);
     };
     $renameRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:"******" role:" . $UserRole . " action:renames " . $node->getName() . " success", Util::INFO);
     };
     $touchRecord = function ($node) {
         $UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
         Util::writeLog('activity', "user:"******" role:" . $UserRole . " action:touches " . $node->getName() . " success", Util::INFO);
     };
     Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity_Logging\\UserHooks', 'share');
     $this->userManager->listen('\\OC\\User', 'postLogin', $loginRecord);
     $this->userManager->listen('\\OC\\User', 'logout', $logoutRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postCreate', $createRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postDelete', $deleteRecord);
     $this->UserFolder->listen('\\OC\\Files', 'postRename', $renameRecord);
 }
コード例 #5
0
 function testBasic()
 {
     $uid = uniqid();
     $this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
     OC_User::setUserId($uid);
     $calId1 = OC_Calendar_Calendar::addCalendar($uid, 'test');
     $all = OC_Calendar_Calendar::allCalendars($uid);
     $this->assertEquals(count($all), 1);
     $this->assertEquals($all[0]['id'], $calId1);
     $this->assertEquals($all[0]['displayname'], 'test');
     $this->assertEquals($all[0]['uri'], 'test');
     $this->assertEquals($uid, $all[0]['userid']);
     $calId2 = OC_Calendar_Calendar::addCalendar($uid, 'test');
     $this->assertNotEquals($calId1, $calId2);
     $all = OC_Calendar_Calendar::allCalendars($uid);
     $this->assertEquals(count($all), 2);
     $this->assertEquals($all[1]['id'], $calId2);
     $this->assertEquals($all[1]['displayname'], 'test');
     $this->assertEquals($all[1]['uri'], 'test1');
     //$cal1=OC_Calendar_Calendar::find($calId1);
     //$this->assertEquals($cal1,$all[0]);
     OC_Calendar_Calendar::deleteCalendar($calId1);
     OC_Calendar_Calendar::deleteCalendar($calId2);
     $this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
 }
コード例 #6
0
ファイル: trashbin.php プロジェクト: samj1912/repo
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(self::TEST_ENCRYPTION_TRASHBIN_USER1);
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
     parent::tearDownAfterClass();
 }
コード例 #7
0
ファイル: app.php プロジェクト: RomanKreisel/group_everyone
 public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0)
 {
     if ($gid !== self::GroupName) {
         return array();
     }
     return \OC_User::getUsers($search, $limit, $offset);
 }
コード例 #8
0
ファイル: utils.php プロジェクト: RepoHell/agreedisclaimer
 /**
  * Gets the language of the user, including anonymous 
  *
  * @return The user language
  */
 public static function getUserLang()
 {
     $config = \OC::$server->getConfig();
     $lang = \OC_L10N::findLanguage();
     $userLang = $config->getUserValue(\OC_User::getUser(), 'core', 'lang', $lang);
     return $userLang;
 }
コード例 #9
0
ファイル: swift.php プロジェクト: TechArea/core
 protected function setUp()
 {
     parent::setUp();
     if (!getenv('RUN_OBJECTSTORE_TESTS')) {
         $this->markTestSkipped('objectstore tests are unreliable in some environments');
     }
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // create users
     $users = array('test');
     foreach ($users as $userName) {
         $user = \OC::$server->getUserManager()->get($userName);
         if ($user !== null) {
             $user->delete();
         }
         \OC::$server->getUserManager()->createUser($userName, $userName);
     }
     // main test user
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_User::setUserId('test');
     $config = \OC::$server->getConfig()->getSystemValue('objectstore');
     $this->objectStorage = new ObjectStoreToTest($config['arguments']);
     $config['objectstore'] = $this->objectStorage;
     $this->instance = new ObjectStoreStorage($config);
 }
コード例 #10
0
 /**
  * Update all charts for all users
  */
 public function updateChartsForUsers()
 {
     $users = \OC_User::getUsers();
     foreach ($users as $userName) {
         $this->updateChartsForUser($userName);
     }
 }
コード例 #11
0
ファイル: publicauth.php プロジェクト: olucao/owncloud-core
 /**
  * Validates a username and password
  *
  * This method should return true or false depending on if login
  * succeeded.
  *
  * @param string $username
  * @param string $password
  *
  * @return bool
  */
 protected function validateUserPass($username, $password)
 {
     $linkItem = \OCP\Share::getShareByToken($username, false);
     \OC_User::setIncognitoMode(true);
     $this->share = $linkItem;
     if (!$linkItem) {
         return false;
     }
     // check if the share is password protected
     if (isset($linkItem['share_with'])) {
         if ($linkItem['share_type'] == \OCP\Share::SHARE_TYPE_LINK) {
             // Check Password
             $forcePortable = CRYPT_BLOWFISH != 1;
             $hasher = new \PasswordHash(8, $forcePortable);
             if (!$hasher->CheckPassword($password . $this->config->getSystemValue('passwordsalt', ''), $linkItem['share_with'])) {
                 return false;
             } else {
                 return true;
             }
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
コード例 #12
0
ファイル: xcache.php プロジェクト: CDN-Sparks/owncloud
 public function __construct($global = false)
 {
     $this->prefix = OC_Util::getInstanceId() . '/';
     if (!$global) {
         $this->prefix .= OC_User::getUser() . '/';
     }
 }
コード例 #13
0
 /**
  * @brief Constructor.
  * @param $app The application identifier e.g. 'contacts' or 'calendar'.
  * @param $user The user whos data the object will operate on. This
  *   parameter should normally be omitted but to make an app able to
  *   update categories for all users it is made possible to provide it.
  * @param $defcategories An array of default categories to be used if none is stored.
  */
 public function __construct($app, $user = null, $defcategories = array())
 {
     $this->app = $app;
     $this->user = is_null($user) ? OC_User::getUser() : $user;
     $categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, ''));
     $this->categories = $categories != '' ? unserialize($categories) : $defcategories;
 }
コード例 #14
0
ファイル: ajax_rename.php プロジェクト: rosarion/core
 protected function tearDown()
 {
     $result = \OC_User::deleteUser(self::$user);
     $this->assertTrue($result);
     $this->logout();
     parent::tearDown();
 }
コード例 #15
0
ファイル: apitest.php プロジェクト: ynott/activity
 /**
  * @dataProvider getData
  */
 public function testGet($user, $start, $count, $expected)
 {
     $_GET['start'] = $start;
     $_GET['count'] = $count;
     \OC_User::setUserId($user);
     $sessionUser = \OC::$server->getUserSession()->getUser();
     $this->assertInstanceOf('OCP\\IUser', $sessionUser);
     $this->assertEquals($user, $sessionUser->getUID());
     $activityManager = new ActivityManager($this->getMock('OCP\\IRequest'), $this->getMock('OCP\\IUserSession'), $this->getMock('OCP\\IConfig'));
     $activityManager->registerExtension(function () {
         return new Extension(\OCP\Util::getL10N('activity', 'en'), $this->getMock('\\OCP\\IURLGenerator'));
     });
     $this->overwriteService('ActivityManager', $activityManager);
     $result = \OCA\Activity\Api::get(array('_route' => 'get_cloud_activity'));
     $this->restoreService('ActivityManager');
     $this->assertEquals(100, $result->getStatusCode());
     $data = $result->getData();
     $this->assertEquals(sizeof($expected), sizeof($data));
     while (!empty($expected)) {
         $assertExpected = array_shift($expected);
         $assertData = array_shift($data);
         foreach ($assertExpected as $key => $value) {
             $this->assertArrayHasKey($key, $assertData);
             if ($value !== null) {
                 $this->assertEquals($value, $assertData[$key]);
             }
         }
     }
 }
コード例 #16
0
ファイル: cache.php プロジェクト: Romua1d/core
 function setUp()
 {
     parent::setUp();
     \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER1, 'User One');
     \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER2, 'User Two');
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     // prepare user1's dir structure
     $this->view->mkdir('container');
     $this->view->mkdir('container/shareddir');
     $this->view->mkdir('container/shareddir/subdir');
     $this->view->mkdir('container/shareddir/emptydir');
     $textData = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     $this->view->file_put_contents('container/not shared.txt', $textData);
     $this->view->file_put_contents('container/shared single file.txt', $textData);
     $this->view->file_put_contents('container/shareddir/bar.txt', $textData);
     $this->view->file_put_contents('container/shareddir/subdir/another.txt', $textData);
     $this->view->file_put_contents('container/shareddir/subdir/another too.txt', $textData);
     $this->view->file_put_contents('container/shareddir/subdir/not a text file.xml', '<xml></xml>');
     list($this->ownerStorage, $internalPath) = $this->view->resolvePath('');
     $this->ownerCache = $this->ownerStorage->getCache();
     $this->ownerStorage->getScanner()->scan('');
     // share "shareddir" with user2
     $fileinfo = $this->view->getFileInfo('container/shareddir');
     \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $fileinfo = $this->view->getFileInfo('container/shared single file.txt');
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     // login as user2
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // retrieve the shared storage
     $secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
     list($this->sharedStorage, $internalPath) = $secondView->resolvePath('files/shareddir');
     $this->sharedCache = $this->sharedStorage->getCache();
 }
コード例 #17
0
ファイル: MigrationTest.php プロジェクト: 0x17de/core
 public static function tearDownAfterClass()
 {
     \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER1);
     \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER2);
     \OC_User::deleteUser(self::TEST_ENCRYPTION_MIGRATION_USER3);
     parent::tearDownAfterClass();
 }
コード例 #18
0
    /**
     * Handle user removal from ownCloud
     */
    public static function notifyUserDeletion($args)
    {
        try {
            \OCP\DB::beginTransaction();
            $query = \OCP\DB::prepare('SELECT `pid`, `title` FROM `*PREFIX*collaboration_project` WHERE `pid` IN 
										(SELECT DISTINCT(`pid`) FROM `*PREFIX*collaboration_works_on` WHERE `member`=?) AND `completed`=?');
            $result = $query->execute(array($args['uid'], false));
            $projs = $result->fetchAll();
            if (count($projs) != 0) {
                $projects = $projs[0]['title'];
                $pids = $projs[0]['pid'];
                for ($i = 1; $i < count($projs); $i++) {
                    $projects .= ', ' . $projs[$i]['title'];
                    $pids .= ' ' . $projs[$i]['pid'];
                }
                OC_Collaboration_Post::createPost('Member Removed', 'Owncloud member \'' . $args['uid'] . '\' has been removed from owncloud and hence from the project(s) ' . $projects, OC_User::getUser(), NULL, 'Member removal', OC_Collaboration_Project::getMembersWorkingOnProjects(explode(' ', $pids)), true);
            }
            OC_Collaboration_Project::deleteMemberRole(NULL, $args['uid'], NULL, OC_User::getUser(), true);
            OC_Collaboration_Skillset::removeSkillsOfMember($args['uid']);
            OC_Collaboration_Post::removePostsByMember($args['uid'], true);
            \OCP\DB::commit();
            OC_Log::write('collaboration', 'User deletion notification posted.', OCP\Util::INFO);
        } catch (\Exception $e) {
            OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
            return false;
        }
    }
コード例 #19
0
ファイル: swift.php プロジェクト: Combustible/core
 public function setUp()
 {
     if (!getenv('RUN_OBJECTSTORE_TESTS')) {
         $this->markTestSkipped('objectstore tests are unreliable on travis');
     }
     \OC_App::disable('files_sharing');
     \OC_App::disable('files_versions');
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // create users
     $users = array('test');
     foreach ($users as $userName) {
         \OC_User::deleteUser($userName);
         \OC_User::createUser($userName, $userName);
     }
     // main test user
     $userName = '******';
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_User::setUserId('test');
     $testContainer = 'oc-test-container-' . substr(md5(rand()), 0, 7);
     $params = array('username' => 'facebook100000330192569', 'password' => 'Dbdj1sXnRSHxIGc4', 'container' => $testContainer, 'autocreate' => true, 'region' => 'RegionOne', 'url' => 'http://8.21.28.222:5000/v2.0', 'tenantName' => 'facebook100000330192569', 'serviceName' => 'swift', 'user' => \OC_User::getManager()->get($userName));
     $this->objectStorage = new ObjectStoreToTest($params);
     $params['objectstore'] = $this->objectStorage;
     $this->instance = new ObjectStoreStorage($params);
 }
コード例 #20
0
 protected function tearDown()
 {
     \OC_User::setIncognitoMode(false);
     // Set old user
     \OC_User::setUserId($this->oldUser);
     \OC_Util::setupFS($this->oldUser);
     parent::tearDown();
 }
コード例 #21
0
 /**
  * Returns a specific principal, specified by it's path.
  * The returned structure should be the exact same as from
  * getPrincipalsByPrefix.
  *
  * @param string $path
  * @return array
  */
 public function getPrincipalByPath($path)
 {
     list($prefix, $name) = explode('/', $path);
     if ($prefix == 'principals' && OC_User::userExists($name)) {
         return array('uri' => 'principals/' . $name, '{DAV:}displayname' => $name);
     }
     return null;
 }
コード例 #22
0
 protected function tearDown()
 {
     foreach ($this->users as $user) {
         \OC_User::deleteUser($user);
     }
     \OC_Group::deleteGroup('admin');
     parent::tearDown();
 }
コード例 #23
0
ファイル: storage.php プロジェクト: ninjasilicon/core
 protected function tearDown()
 {
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
     $this->logout();
     \OC_User::deleteUser($this->user);
     \OC_Hook::clear();
     parent::tearDown();
 }
コード例 #24
0
 protected function tearDown()
 {
     $result = \OC_User::deleteUser(self::$user);
     $this->assertTrue($result);
     \OC\Files\Filesystem::tearDown();
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     parent::tearDown();
 }
コード例 #25
0
ファイル: json.php プロジェクト: olucao/owncloud-core
 /**
  * Check if the user is a subadmin, send json error msg if not
  */
 public static function checkSubAdminUser()
 {
     if (!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
         $l = OC_L10N::get('lib');
         self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
         exit;
     }
 }
コード例 #26
0
ファイル: remote.php プロジェクト: ninjasilicon/core
 /**
  * Decline a remote share
  *
  * @param array $params contains the shareID 'id' which should be declined
  * @return \OC_OCS_Result
  */
 public static function declineShare($params)
 {
     $externalManager = new Manager(\OC::$server->getDatabaseConnection(), Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC_User::getUser());
     if ($externalManager->declineShare($params['id'])) {
         return new \OC_OCS_Result();
     }
     return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
 }
コード例 #27
0
 protected function tearDown()
 {
     \OC_User::setUserId('');
     $user = \OC::$server->getUserManager()->get($this->user);
     if ($user !== null) {
         $user->delete();
     }
 }
コード例 #28
0
ファイル: helper.php プロジェクト: olucao/owncloud-core
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1);
     \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2);
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
 }
コード例 #29
0
ファイル: auth.php プロジェクト: CDN-Sparks/owncloud
 /**
  * Returns information about the currently logged in username.
  *
  * If nobody is currently logged in, this method should return null.
  *
  * @return string|null
  */
 public function getCurrentUser()
 {
     $user = OC_User::getUser();
     if (!$user) {
         return null;
     }
     return $user;
 }
コード例 #30
0
 /**
  * Update the user storage, called from command
  */
 public function updateUserStorage()
 {
     $users = \OC_User::getUsers();
     foreach($users as $userName)
     {
         $this->updateUserStorageByUser($userName);
     }
 }