本文整理汇总了PHP中OCP\ISession类的典型用法代码示例。如果您正苦于以下问题:PHP ISession类的具体用法?PHP ISession怎么用?PHP ISession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ISession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
*
*/
protected function setUp()
{
parent::setUp();
$this->sessionMock = $this->getMock('OCP\\ISession');
$this->sessionMock->expects($this->any())->method('set')->will($this->returnCallback([$this, "setValueTester"]));
$this->sessionMock->expects($this->any())->method('get')->will($this->returnCallback([$this, "getValueTester"]));
$this->sessionMock->expects($this->any())->method('remove')->will($this->returnCallback([$this, "removeValueTester"]));
$this->instance = new Session($this->sessionMock);
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:12,代码来源:SessionTest.php
示例2: testUnwrappingGet
public function testUnwrappingGet()
{
$unencryptedValue = 'foobar';
$encryptedValue = $this->crypto->encrypt($unencryptedValue);
$this->wrappedSession->expects($this->once())->method('get')->with('encrypted_session_data')->willReturnCallback(function () use($encryptedValue) {
return $encryptedValue;
});
$this->assertSame($unencryptedValue, $this->wrappedSession->get('encrypted_session_data'));
}
开发者ID:evanjt,项目名称:core,代码行数:9,代码来源:cryptowrappingtest.php
示例3: manipulateStorageConfig
public function manipulateStorageConfig(StorageConfig &$storage)
{
$encrypted = $this->session->get('password::sessioncredentials/credentials');
if (!isset($encrypted)) {
throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
}
$credentials = json_decode($this->crypto->decrypt($encrypted), true);
$storage->setBackendOption('user', $this->session->get('loginname'));
$storage->setBackendOption('password', $credentials['password']);
}
开发者ID:kenwi,项目名称:core,代码行数:10,代码来源:sessioncredentials.php
示例4: testShowLoginFormWithErrorsInSession
public function testShowLoginFormWithErrorsInSession()
{
$this->userSession->expects($this->once())->method('isLoggedIn')->willReturn(false);
$this->session->expects($this->once())->method('get')->with('loginMessages')->willReturn([['ErrorArray1', 'ErrorArray2'], ['MessageArray1', 'MessageArray2']]);
$expectedResponse = new TemplateResponse('core', 'login', ['ErrorArray1' => true, 'ErrorArray2' => true, 'messages' => ['MessageArray1', 'MessageArray2'], 'loginName' => '', 'user_autofocus' => true, 'canResetPassword' => true, 'alt_login' => [], 'rememberLoginAllowed' => \OC_Util::rememberLoginAllowed(), 'rememberLoginState' => 0], 'guest');
$this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', '', ''));
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:7,代码来源:LoginControllerTest.php
示例5: create
/**
* @NoAdminRequired
* @NoSubadminRequired
*
* @return JSONResponse
*/
public function create($name)
{
try {
$sessionId = $this->session->getId();
} catch (SessionNotAvailableException $ex) {
$resp = new JSONResponse();
$resp->setStatus(Http::STATUS_SERVICE_UNAVAILABLE);
return $resp;
}
try {
$sessionToken = $this->tokenProvider->getToken($sessionId);
$loginName = $sessionToken->getLoginName();
try {
$password = $this->tokenProvider->getPassword($sessionToken, $sessionId);
} catch (PasswordlessTokenException $ex) {
$password = null;
}
} catch (InvalidTokenException $ex) {
$resp = new JSONResponse();
$resp->setStatus(Http::STATUS_SERVICE_UNAVAILABLE);
return $resp;
}
$token = $this->generateRandomDeviceToken();
$deviceToken = $this->tokenProvider->generateToken($token, $this->uid, $loginName, $password, $name, IToken::PERMANENT_TOKEN);
return ['token' => $token, 'deviceToken' => $deviceToken];
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:32,代码来源:AuthSettingsController.php
示例6: proxy
/**
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $src
*
* TODO: Cache the proxied content to prevent unnecessary requests from the oC server
* The caching should also already happen in a cronjob so that the sender of the
* mail does not know whether the mail has been opened.
*
* @return ProxyDownloadResponse
*/
public function proxy($src)
{
// close the session to allow parallel downloads
$this->session->close();
$content = $this->helper->getUrlContent($src);
return new ProxyDownloadResponse($content, $src, 'application/octet-stream');
}
开发者ID:matiasdelellis,项目名称:mail,代码行数:19,代码来源:proxycontroller.php
示例7: checkSession
/**
* Makes sure the user is already properly authenticated when a password is required and none
* was provided
*
* @param array|bool $linkItem
*
* @throws CheckException
*/
private function checkSession($linkItem)
{
// Not authenticated ?
if (!$this->session->exists('public_link_authenticated') || $this->session->get('public_link_authenticated') !== $linkItem['id']) {
throw new CheckException("Missing password", Http::STATUS_UNAUTHORIZED);
}
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:15,代码来源:envcheckmiddleware.php
示例8: checkSession
/**
* Makes sure the user is already properly authenticated when a password is required and none
* was provided
*
* @param IShare $share
*
* @throws CheckException
*/
private function checkSession($share)
{
// Not authenticated ?
if (!$this->session->exists('public_link_authenticated') || $this->session->get('public_link_authenticated') !== (string) $share->getId()) {
throw new CheckException("Missing password", Http::STATUS_UNAUTHORIZED);
}
}
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:15,代码来源:envcheckmiddleware.php
示例9: getTimeZone
/**
* Get the timezone of the current user, based on his session information and config data
*
* @param bool|int $timestamp
* @return \DateTimeZone
*/
public function getTimeZone($timestamp = false)
{
$timeZone = $this->config->getUserValue($this->session->get('user_id'), 'core', 'timezone', null);
if ($timeZone === null) {
if ($this->session->exists('timezone')) {
return $this->guessTimeZoneFromOffset($this->session->get('timezone'), $timestamp);
}
$timeZone = $this->getDefaultTimeZone();
}
try {
return new \DateTimeZone($timeZone);
} catch (\Exception $e) {
\OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", \OCP\Util::DEBUG);
return new \DateTimeZone($this->getDefaultTimeZone());
}
}
开发者ID:GitHubUser4234,项目名称:core,代码行数:22,代码来源:DateTimeZone.php
示例10: proxy
/**
* @NoAdminRequired
* @NoCSRFRequired
*
* TODO: Cache the proxied content to prevent unnecessary requests from the oC server
* The caching should also already happen in a cronjob so that the sender of the
* mail does not know whether the mail has been opened.
*
* @return ProxyDownloadResponse
*/
public function proxy()
{
// close the session to allow parallel downloads
$this->session->close();
$resourceURL = $this->request->getParam('src');
$content = \OC::$server->getHelper()->getUrlContent($resourceURL);
return new ProxyDownloadResponse($content, $resourceURL, 'application/octet-stream');
}
开发者ID:jakobsack,项目名称:mail,代码行数:18,代码来源:proxycontroller.php
示例11: clear
/**
* remove keys from session
*/
public function clear()
{
$this->session->remove('publicSharePrivateKey');
$this->session->remove('privateKey');
$this->session->remove('encryptionInitialized');
$this->session->remove('decryptAll');
$this->session->remove('decryptAllKey');
$this->session->remove('decryptAllUid');
}
开发者ID:evanjt,项目名称:core,代码行数:12,代码来源:session.php
示例12: close
/**
* Close the session and release the lock, also writes all changed data in batch
*/
public function close()
{
if ($this->isModified) {
$encryptedValue = $this->crypto->encrypt(json_encode($this->sessionValues), $this->passphrase);
$this->session->set(self::encryptedSessionName, $encryptedValue);
$this->isModified = false;
}
$this->session->close();
}
开发者ID:hyb148,项目名称:core,代码行数:12,代码来源:cryptosessiondata.php
示例13: testAuthenticateAlreadyLoggedIn
public function testAuthenticateAlreadyLoggedIn()
{
$server = $this->getMockBuilder('\\Sabre\\DAV\\Server')->disableOriginalConstructor()->getMock();
$this->userSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true));
$this->session->expects($this->once())->method('get')->with('AUTHENTICATED_TO_DAV_BACKEND')->will($this->returnValue(null));
$user = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
$user->expects($this->once())->method('getUID')->will($this->returnValue('MyWrongDavUser'));
$this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($user));
$this->session->expects($this->once())->method('close');
$this->assertTrue($this->auth->authenticate($server, 'TestRealm'));
}
开发者ID:nem0xff,项目名称:core,代码行数:11,代码来源:auth.php
示例14: auth
/**
* @param \Sabre\DAV\Server $server
* @param $realm
* @return bool
*/
private function auth(\Sabre\DAV\Server $server, $realm)
{
if (\OC_User::handleApacheAuth() || $this->userSession->isLoggedIn() && is_null($this->session->get(self::DAV_AUTHENTICATED))) {
$user = $this->userSession->getUser()->getUID();
\OC_Util::setupFS($user);
$this->currentUser = $user;
$this->session->close();
return true;
}
return parent::authenticate($server, $realm);
}
开发者ID:leechan530,项目名称:calendar,代码行数:16,代码来源:auth.php
示例15: testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjaxButUserIsStillLoggedIn
public function testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjaxButUserIsStillLoggedIn()
{
/** @var \Sabre\HTTP\RequestInterface $httpRequest */
$httpRequest = $this->getMockBuilder('\\Sabre\\HTTP\\RequestInterface')->disableOriginalConstructor()->getMock();
/** @var \Sabre\HTTP\ResponseInterface $httpResponse */
$httpResponse = $this->getMockBuilder('\\Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
$this->userSession->expects($this->any())->method('isLoggedIn')->will($this->returnValue(true));
$this->session->expects($this->once())->method('get')->with('AUTHENTICATED_TO_DAV_BACKEND')->will($this->returnValue('MyTestUser'));
$httpRequest->expects($this->once())->method('getHeader')->with('Authorization')->will($this->returnValue(null));
$this->auth->check($httpRequest, $httpResponse);
}
开发者ID:TechArea,项目名称:core,代码行数:11,代码来源:auth.php
示例16: getTimeZone
/**
* Get the timezone of the current user, based on his session information and config data
*
* @return \DateTimeZone
*/
public function getTimeZone()
{
$timeZone = $this->config->getUserValue($this->session->get('user_id'), 'core', 'timezone', null);
if ($timeZone === null) {
if ($this->session->exists('timezone')) {
$offsetHours = $this->session->get('timezone');
// Note: the timeZone name is the inverse to the offset,
// so a positive offset means negative timeZone
// and the other way around.
if ($offsetHours > 0) {
return new \DateTimeZone('Etc/GMT-' . $offsetHours);
} else {
return new \DateTimeZone('Etc/GMT+' . abs($offsetHours));
}
} else {
return new \DateTimeZone('UTC');
}
}
return new \DateTimeZone($timeZone);
}
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:25,代码来源:datetimezone.php
示例17: updateSessionTokenPassword
/**
* Update password of the browser session token if there is one
*
* @param string $password
*/
public function updateSessionTokenPassword($password)
{
try {
$sessionId = $this->session->getId();
$token = $this->tokenProvider->getToken($sessionId);
$this->tokenProvider->setPassword($token, $sessionId, $password);
} catch (SessionNotAvailableException $ex) {
// Nothing to do
} catch (InvalidTokenException $ex) {
// Nothing to do
}
}
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:17,代码来源:Session.php
示例18: testAuthenticateAlreadyLoggedIn
public function testAuthenticateAlreadyLoggedIn()
{
$request = $this->getMockBuilder('Sabre\\HTTP\\RequestInterface')->disableOriginalConstructor()->getMock();
$response = $this->getMockBuilder('Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
$this->userSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true));
$this->session->expects($this->once())->method('get')->with('AUTHENTICATED_TO_DAV_BACKEND')->will($this->returnValue(null));
$user = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
$user->expects($this->once())->method('getUID')->will($this->returnValue('MyWrongDavUser'));
$this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($user));
$this->session->expects($this->once())->method('close');
$response = $this->auth->check($request, $response);
$this->assertEquals([true, 'principals/users/MyWrongDavUser'], $response);
}
开发者ID:kebenxiaoming,项目名称:core,代码行数:13,代码来源:auth.php
示例19: testSharePasswordLinkInvalidSession
public function testSharePasswordLinkInvalidSession()
{
$share = $this->getMock('OCP\\Share\\IShare');
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getId')->willReturn('42');
$this->shareManager->expects($this->once())->method('getShareByToken')->willReturn($share);
$this->shareManager->method('checkPassword')->with($this->equalTo($share), $this->equalTo('password'))->willReturn(false);
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
$this->session->method('get')->with('public_link_authenticated')->willReturn('43');
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
$this->assertFalse($result);
}
开发者ID:GitHubUser4234,项目名称:core,代码行数:13,代码来源:PublicAuthTest.php
示例20: validateUserPass
/**
* 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
* @throws \Sabre\DAV\Exception\NotAuthenticated
*/
protected function validateUserPass($username, $password)
{
try {
$share = $this->shareManager->getShareByToken($username);
} catch (ShareNotFound $e) {
return false;
}
$this->share = $share;
\OC_User::setIncognitoMode(true);
// check if the share is password protected
if ($share->getPassword() !== null) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
if ($this->shareManager->checkPassword($share, $password)) {
return true;
} else {
if ($this->session->exists('public_link_authenticated') && $this->session->get('public_link_authenticated') === $share->getId()) {
return true;
} else {
if (in_array('XMLHttpRequest', explode(',', $this->request->getHeader('X-Requested-With')))) {
// do not re-authenticate over ajax, use dummy auth name to prevent browser popup
http_response_code(401);
header('WWW-Authenticate', 'DummyBasic real="ownCloud"');
throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
}
return false;
}
}
} else {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
return true;
} else {
return false;
}
}
} else {
return true;
}
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:50,代码来源:publicauth.php
注:本文中的OCP\ISession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论