• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Security\ISecureRandom类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中OCP\Security\ISecureRandom的典型用法代码示例。如果您正苦于以下问题:PHP ISecureRandom类的具体用法?PHP ISecureRandom怎么用?PHP ISecureRandom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ISecureRandom类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: sendEmail

 /**
  * @param string $user
  * @throws \Exception
  */
 protected function sendEmail($user)
 {
     if (!$this->userManager->userExists($user)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.'));
     }
     $email = $this->config->getUserValue($user, 'settings', 'email');
     if (empty($email)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email because there is no ' . 'email address for this username. Please ' . 'contact your administrator.'));
     }
     $token = $this->secureRandom->getMediumStrengthGenerator()->generate(21, ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER);
     $this->config->setUserValue($user, 'owncloud', 'lostpassword', $token);
     $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user, 'token' => $token));
     $tmpl = new \OC_Template('core/lostpassword', 'email');
     $tmpl->assign('link', $link, false);
     $msg = $tmpl->fetchPage();
     try {
         $message = $this->mailer->createMessage();
         $message->setTo([$email => $user]);
         $message->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()]));
         $message->setPlainBody($msg);
         $message->setFrom([$this->from => $this->defaults->getName()]);
         $this->mailer->send($message);
     } catch (\Exception $e) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please contact your administrator.'));
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:30,代码来源:lostcontroller.php


示例2: __construct

 /**
  * @param IConfig $config
  * @param ICrypto $crypto
  * @param ISecureRandom $random
  * @param IRequest $request
  */
 public function __construct(IConfig $config, ICrypto $crypto, ISecureRandom $random, IRequest $request)
 {
     $this->crypto = $crypto;
     $this->config = $config;
     $this->random = $random;
     if (!is_null($request->getCookie(self::COOKIE_NAME))) {
         $this->passphrase = $request->getCookie(self::COOKIE_NAME);
     } else {
         $this->passphrase = $this->random->getMediumStrengthGenerator()->generate(128);
         $secureCookie = $request->getServerProtocol() === 'https';
         // FIXME: Required for CI
         if (!defined('PHPUNIT_RUN')) {
             setcookie(self::COOKIE_NAME, $this->passphrase, 0, \OC::$WEBROOT, '', $secureCookie, true);
         }
     }
 }
开发者ID:rosarion,项目名称:core,代码行数:22,代码来源:cryptowrapper.php


示例3: testGetIdWithoutModUnique

 public function testGetIdWithoutModUnique()
 {
     $lowRandomSource = $this->getMockBuilder('\\OCP\\Security\\ISecureRandom')->disableOriginalConstructor()->getMock();
     $lowRandomSource->expects($this->once())->method('generate')->with('20')->will($this->returnValue('GeneratedByOwnCloudItself'));
     $this->secureRandom->expects($this->once())->method('getLowStrengthGenerator')->will($this->returnValue($lowRandomSource));
     $request = new Request([], $this->secureRandom, $this->getMock('\\OCP\\Security\\ICrypto'), $this->config, $this->stream);
     $this->assertSame('GeneratedByOwnCloudItself', $request->getId());
 }
开发者ID:rosarion,项目名称:core,代码行数:8,代码来源:RequestTest.php


示例4: createShare

 /**
  * Share a path
  *
  * @param \OCP\Share\IShare $share
  * @return Share The share object
  * @throws \Exception
  *
  * TODO: handle link share permissions or check them
  */
 public function createShare(\OCP\Share\IShare $share)
 {
     if (!$this->canShare($share)) {
         throw new \Exception('The Share API is disabled');
     }
     $this->generalCreateChecks($share);
     //Verify share type
     if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
         $this->userCreateChecks($share);
     } else {
         if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
             $this->groupCreateChecks($share);
         } else {
             if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
                 $this->linkCreateChecks($share);
                 $this->setLinkParent($share);
                 /*
                  * For now ignore a set token.
                  */
                 $share->setToken($this->secureRandom->generate(\OC\Share\Constants::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER . \OCP\Security\ISecureRandom::CHAR_DIGITS));
                 //Verify the expiration date
                 $this->validateExpirationDate($share);
                 //Verify the password
                 $this->verifyPassword($share->getPassword());
                 // If a password is set. Hash it!
                 if ($share->getPassword() !== null) {
                     $share->setPassword($this->hasher->hash($share->getPassword()));
                 }
             }
         }
     }
     // Verify if there are any issues with the path
     $this->pathCreateChecks($share->getNode());
     // On creation of a share the owner is always the owner of the path
     $share->setShareOwner($share->getNode()->getOwner()->getUID());
     // Cannot share with the owner
     if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() === $share->getShareOwner()) {
         throw new \InvalidArgumentException('Can\'t share with the share owner');
     }
     // Generate the target
     $target = $this->config->getSystemValue('share_folder', '/') . '/' . $share->getNode()->getName();
     $target = \OC\Files\Filesystem::normalizePath($target);
     $share->setTarget($target);
     // Pre share hook
     $run = true;
     $error = '';
     $preHookData = ['itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', 'itemSource' => $share->getNode()->getId(), 'shareType' => $share->getShareType(), 'uidOwner' => $share->getSharedBy(), 'permissions' => $share->getPermissions(), 'fileSource' => $share->getNode()->getId(), 'expiration' => $share->getExpirationDate(), 'token' => $share->getToken(), 'itemTarget' => $share->getTarget(), 'shareWith' => $share->getSharedWith(), 'run' => &$run, 'error' => &$error];
     \OC_Hook::emit('OCP\\Share', 'pre_shared', $preHookData);
     if ($run === false) {
         throw new \Exception($error);
     }
     $provider = $this->factory->getProviderForType($share->getShareType());
     $share = $provider->create($share);
     // Post share hook
     $postHookData = ['itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder', 'itemSource' => $share->getNode()->getId(), 'shareType' => $share->getShareType(), 'uidOwner' => $share->getSharedBy(), 'permissions' => $share->getPermissions(), 'fileSource' => $share->getNode()->getId(), 'expiration' => $share->getExpirationDate(), 'token' => $share->getToken(), 'id' => $share->getId(), 'shareWith' => $share->getSharedWith(), 'itemTarget' => $share->getTarget(), 'fileTarget' => $share->getTarget()];
     \OC_Hook::emit('OCP\\Share', 'post_shared', $postHookData);
     return $share;
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:67,代码来源:manager.php


示例5: renameTableSchema

 /**
  * @param \Doctrine\DBAL\Schema\Table $table
  * @param string $newName
  * @return \Doctrine\DBAL\Schema\Table
  */
 protected function renameTableSchema(Table $table, $newName)
 {
     /**
      * @var \Doctrine\DBAL\Schema\Index[] $indexes
      */
     $indexes = $table->getIndexes();
     $newIndexes = array();
     foreach ($indexes as $index) {
         if ($index->isPrimary()) {
             // do not rename primary key
             $indexName = $index->getName();
         } else {
             // avoid conflicts in index names
             $indexName = $this->config->getSystemValue('dbtableprefix', 'oc_') . $this->random->generate(13, ISecureRandom::CHAR_LOWER);
         }
         $newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary());
     }
     // foreign keys are not supported so we just set it to an empty array
     return new Table($newName, $table->getColumns(), $newIndexes, array(), 0, $table->getOptions());
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:25,代码来源:Migrator.php


示例6: generateToken

 /**
  * generate to token used to authenticate federated shares
  *
  * @return string
  */
 public function generateToken()
 {
     $token = $this->secureRandom->generate(self::TOKEN_LENGTH, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
     return $token;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:10,代码来源:TokenHandler.php


示例7: save

 public function save($email)
 {
     $query = $this->db->prepareQuery('INSERT INTO `*PREFIX*registration`' . ' ( `email`, `token`, `requested` ) VALUES( ?, ?, NOW() )');
     $token = $this->random->generate(30);
     $query->execute(array($email, $token));
     return $token;
 }
开发者ID:WeatherellTechnology,项目名称:weatherstorm7,代码行数:7,代码来源:pendingregist.php


示例8: testCreateCredentials

 public function testCreateCredentials()
 {
     $this->jobList->expects($this->once())->method('add')->with('OCA\\UpdateNotification\\ResetTokenBackgroundJob');
     $this->secureRandom->expects($this->once())->method('generate')->with(64)->willReturn('MyGeneratedToken');
     $this->config->expects($this->once())->method('setSystemValue')->with('updater.secret');
     $this->timeFactory->expects($this->once())->method('getTime')->willReturn(12345);
     $this->config->expects($this->once())->method('setAppValue')->with('core', 'updater.secret.created', 12345);
     $expected = new DataResponse('MyGeneratedToken');
     $this->assertEquals($expected, $this->adminController->createCredentials());
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:10,代码来源:AdminControllerTest.php


示例9: createCredentials

 /**
  * @return DataResponse
  */
 public function createCredentials()
 {
     // Create a new job and store the creation date
     $this->jobList->add('OCA\\UpdateNotification\\ResetTokenBackgroundJob');
     $this->config->setAppValue('core', 'updater.secret.created', $this->timeFactory->getTime());
     // Create a new token
     $newToken = $this->secureRandom->generate(64);
     $this->config->setSystemValue('updater.secret', password_hash($newToken, PASSWORD_DEFAULT));
     return new DataResponse($newToken);
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:13,代码来源:admincontroller.php


示例10: addServer

 /**
  * add server to the list of trusted ownCloud servers
  *
  * @param $url
  * @return int server id
  */
 public function addServer($url)
 {
     $url = $this->updateProtocol($url);
     $result = $this->dbHandler->addServer($url);
     if ($result) {
         $token = $this->secureRandom->generate(16);
         $this->dbHandler->addToken($url, $token);
         $this->jobList->add('OCA\\Federation\\BackgroundJob\\RequestSharedSecret', ['url' => $url, 'token' => $token]);
     }
     return $result;
 }
开发者ID:ZverAleksey,项目名称:core,代码行数:17,代码来源:trustedservers.php


示例11: encrypt

 /**
  * Encrypts a value and adds an HMAC (Encrypt-Then-MAC)
  * @param string $plaintext
  * @param string $password Password to encrypt, if not specified the secret from config.php will be taken
  * @return string Authenticated ciphertext
  */
 public function encrypt($plaintext, $password = '')
 {
     if ($password === '') {
         $password = $this->config->getSystemValue('secret');
     }
     $this->cipher->setPassword($password);
     $iv = $this->random->getLowStrengthGenerator()->generate($this->ivLength);
     $this->cipher->setIV($iv);
     $ciphertext = bin2hex($this->cipher->encrypt($plaintext));
     $hmac = bin2hex($this->calculateHMAC($ciphertext . $iv, $password));
     return $ciphertext . '|' . $iv . '|' . $hmac;
 }
开发者ID:dennisgermany,项目名称:core,代码行数:18,代码来源:crypto.php


示例12: generateRandomDeviceToken

 /**
  * Return a 20 digit device password
  *
  * Example: ABCDE-FGHIJ-KLMNO-PQRST
  *
  * @return string
  */
 private function generateRandomDeviceToken()
 {
     $groups = [];
     for ($i = 0; $i < 4; $i++) {
         $groups[] = $this->random->generate(5, implode('', range('A', 'Z')));
     }
     return implode('-', $groups);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:15,代码来源:AuthSettingsController.php


示例13: getId

 /**
  * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging
  * If `mod_unique_id` is installed this value will be taken.
  * @return string
  */
 public function getId()
 {
     if (isset($this->server['UNIQUE_ID'])) {
         return $this->server['UNIQUE_ID'];
     }
     if (empty($this->requestId)) {
         $this->requestId = $this->secureRandom->getLowStrengthGenerator()->generate(20);
     }
     return $this->requestId;
 }
开发者ID:0x17de,项目名称:core,代码行数:15,代码来源:request.php


示例14: getSharedSecret

 /**
  * create shared secret and return it
  *
  * @return \OC_OCS_Result
  */
 public function getSharedSecret()
 {
     $url = $this->request->getParam('url');
     $token = $this->request->getParam('token');
     if ($this->trustedServers->isTrustedServer($url) === false || $this->isValidToken($url, $token) === false) {
         return new \OC_OCS_Result(null, HTTP::STATUS_FORBIDDEN);
     }
     $sharedSecret = $this->secureRandom->getMediumStrengthGenerator()->generate(32);
     $this->trustedServers->addSharedSecret($url, $sharedSecret);
     // reset token after the exchange of the shared secret was successful
     $this->dbHandler->addToken($url, '');
     return new \OC_OCS_Result(['sharedSecret' => $sharedSecret], Http::STATUS_OK);
 }
开发者ID:mrjoshuap,项目名称:core,代码行数:18,代码来源:ocsauthapi.php


示例15: feed

 /**
  * @NoAdminRequired
  *
  * @param string $enable	'true' if the feed is enabled
  * @return DataResponse
  */
 public function feed($enable)
 {
     $token = $tokenUrl = '';
     if ($enable === 'true') {
         $conflicts = true;
         // Check for collisions
         while (!empty($conflicts)) {
             $token = $this->random->generate(30);
             $conflicts = $this->config->getUsersForUserValue('activity', 'rsstoken', $token);
         }
         $tokenUrl = $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show', ['token' => $token]);
     }
     $this->config->setUserValue($this->user, 'activity', 'rsstoken', $token);
     return new DataResponse(array('data' => array('message' => (string) $this->l10n->t('Your settings have been updated.'), 'rsslink' => $tokenUrl)));
 }
开发者ID:samj1912,项目名称:repo,代码行数:21,代码来源:settings.php


示例16: getSharedSecret

 /**
  * create shared secret and return it
  *
  * @return \OC_OCS_Result
  */
 public function getSharedSecret()
 {
     $url = $this->request->getParam('url');
     $token = $this->request->getParam('token');
     if ($this->trustedServers->isTrustedServer($url) === false) {
         $this->logger->log(\OCP\Util::ERROR, 'remote server not trusted (' . $url . ') while getting shared secret');
         return new \OC_OCS_Result(null, HTTP::STATUS_FORBIDDEN);
     }
     if ($this->isValidToken($url, $token) === false) {
         $this->logger->log(\OCP\Util::ERROR, 'remote server (' . $url . ') didn\'t send a valid token (got ' . $token . ') while getting shared secret');
         return new \OC_OCS_Result(null, HTTP::STATUS_FORBIDDEN);
     }
     $sharedSecret = $this->secureRandom->generate(32);
     $this->trustedServers->addSharedSecret($url, $sharedSecret);
     // reset token after the exchange of the shared secret was successful
     $this->dbHandler->addToken($url, '');
     return new \OC_OCS_Result(['sharedSecret' => $sharedSecret], Http::STATUS_OK);
 }
开发者ID:kenwi,项目名称:core,代码行数:23,代码来源:ocsauthapi.php


示例17: testCreateShareLink

 public function testCreateShareLink()
 {
     $manager = $this->createManagerMock()->setMethods(['canShare', 'generalCreateChecks', 'linkCreateChecks', 'pathCreateChecks', 'validateExpirationDate', 'verifyPassword', 'setLinkParent'])->getMock();
     $shareOwner = $this->getMock('\\OCP\\IUser');
     $shareOwner->method('getUID')->willReturn('shareOwner');
     $storage = $this->getMock('\\OCP\\Files\\Storage');
     $path = $this->getMock('\\OCP\\Files\\File');
     $path->method('getOwner')->willReturn($shareOwner);
     $path->method('getName')->willReturn('target');
     $path->method('getId')->willReturn(1);
     $path->method('getStorage')->willReturn($storage);
     $date = new \DateTime();
     $share = $this->manager->newShare();
     $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)->setNode($path)->setSharedBy('sharedBy')->setPermissions(\OCP\Constants::PERMISSION_ALL)->setExpirationDate($date)->setPassword('password');
     $manager->expects($this->once())->method('canShare')->with($share)->willReturn(true);
     $manager->expects($this->once())->method('generalCreateChecks')->with($share);
     $manager->expects($this->once())->method('linkCreateChecks')->with($share);
     $manager->expects($this->once())->method('pathCreateChecks')->with($path);
     $manager->expects($this->once())->method('validateExpirationDate')->with($share);
     $manager->expects($this->once())->method('verifyPassword')->with('password');
     $manager->expects($this->once())->method('setLinkParent')->with($share);
     $this->hasher->expects($this->once())->method('hash')->with('password')->willReturn('hashed');
     $this->secureRandom->method('getMediumStrengthGenerator')->will($this->returnSelf());
     $this->secureRandom->method('generate')->willReturn('token');
     $this->defaultProvider->expects($this->once())->method('create')->with($share)->will($this->returnCallback(function (Share $share) {
         return $share->setId(42);
     }));
     $hookListner = $this->getMockBuilder('Dummy')->setMethods(['pre', 'post'])->getMock();
     \OCP\Util::connectHook('OCP\\Share', 'pre_shared', $hookListner, 'pre');
     \OCP\Util::connectHook('OCP\\Share', 'post_shared', $hookListner, 'post');
     $hookListnerExpectsPre = ['itemType' => 'file', 'itemSource' => 1, 'shareType' => \OCP\Share::SHARE_TYPE_LINK, 'uidOwner' => 'sharedBy', 'permissions' => 31, 'fileSource' => 1, 'expiration' => $date, 'token' => 'token', 'run' => true, 'error' => '', 'itemTarget' => '/target', 'shareWith' => null];
     $hookListnerExpectsPost = ['itemType' => 'file', 'itemSource' => 1, 'shareType' => \OCP\Share::SHARE_TYPE_LINK, 'uidOwner' => 'sharedBy', 'permissions' => 31, 'fileSource' => 1, 'expiration' => $date, 'token' => 'token', 'id' => 42, 'itemTarget' => '/target', 'fileTarget' => '/target', 'shareWith' => null];
     $hookListner->expects($this->once())->method('pre')->with($this->equalTo($hookListnerExpectsPre));
     $hookListner->expects($this->once())->method('post')->with($this->equalTo($hookListnerExpectsPost));
     /** @var IShare $share */
     $share = $manager->createShare($share);
     $this->assertSame('shareOwner', $share->getShareOwner());
     $this->assertEquals('/target', $share->getTarget());
     $this->assertSame($date, $share->getExpirationDate());
     $this->assertEquals('token', $share->getToken());
     $this->assertEquals('hashed', $share->getPassword());
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:42,代码来源:ManagerTest.php


示例18: generateToken

 /**
  * Generate a new access token clients can authenticate with
  *
  * @PublicPage
  * @NoCSRFRequired
  *
  * @param string $user
  * @param string $password
  * @param string $name the name of the client
  * @return JSONResponse
  */
 public function generateToken($user, $password, $name = 'unknown client')
 {
     if (is_null($user) || is_null($password)) {
         $response = new JSONResponse();
         $response->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY);
         return $response;
     }
     $loginName = $user;
     $user = $this->userManager->checkPassword($loginName, $password);
     if ($user === false) {
         $response = new JSONResponse();
         $response->setStatus(Http::STATUS_UNAUTHORIZED);
         return $response;
     }
     if ($this->twoFactorAuthManager->isTwoFactorAuthenticated($user)) {
         $resp = new JSONResponse();
         $resp->setStatus(Http::STATUS_UNAUTHORIZED);
         return $resp;
     }
     $token = $this->secureRandom->generate(128);
     $this->tokenProvider->generateToken($token, $user->getUID(), $loginName, $password, $name, IToken::PERMANENT_TOKEN);
     return ['token' => $token];
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:34,代码来源:TokenController.php


示例19: testCreateShareLink

 public function testCreateShareLink()
 {
     $manager = $this->getMockBuilder('\\OC\\Share20\\Manager')->setConstructorArgs([$this->logger, $this->config, $this->defaultProvider, $this->secureRandom, $this->hasher, $this->mountManager, $this->groupManager, $this->l])->setMethods(['canShare', 'generalCreateChecks', 'linkCreateChecks', 'pathCreateChecks', 'validateExpiredate', 'verifyPassword'])->getMock();
     $sharedBy = $this->getMock('\\OCP\\IUser');
     $sharedBy->method('getUID')->willReturn('sharedBy');
     $shareOwner = $this->getMock('\\OCP\\IUser');
     $path = $this->getMock('\\OCP\\Files\\File');
     $path->method('getOwner')->willReturn($shareOwner);
     $path->method('getName')->willReturn('target');
     $path->method('getId')->willReturn(1);
     $date = new \DateTime();
     $share = $this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $path, null, $sharedBy, null, \OCP\Constants::PERMISSION_ALL, $date, 'password');
     $manager->expects($this->once())->method('canShare')->with($share)->willReturn(true);
     $manager->expects($this->once())->method('generalCreateChecks')->with($share);
     $manager->expects($this->once())->method('linkCreateChecks')->with($share);
     $manager->expects($this->once())->method('pathCreateChecks')->with($path);
     $manager->expects($this->once())->method('validateExpiredate')->with($date)->will($this->returnArgument(0));
     $manager->expects($this->once())->method('verifyPassword')->with('password');
     $this->hasher->expects($this->once())->method('hash')->with('password')->willReturn('hashed');
     $this->secureRandom->method('getMediumStrengthGenerator')->will($this->returnSelf());
     $this->secureRandom->method('generate')->willReturn('token');
     $this->defaultProvider->expects($this->once())->method('create')->with($share)->will($this->returnArgument(0));
     $share->expects($this->once())->method('setShareOwner')->with($shareOwner);
     $share->expects($this->once())->method('setTarget')->with('/target');
     $share->expects($this->once())->method('setExpirationDate')->with($date);
     $share->expects($this->once())->method('setPassword')->with('hashed');
     $share->method('getToken')->willReturn('token');
     $hookListner = $this->getMockBuilder('Dummy')->setMethods(['pre', 'post'])->getMock();
     \OCP\Util::connectHook('OCP\\Share', 'pre_shared', $hookListner, 'pre');
     \OCP\Util::connectHook('OCP\\Share', 'post_shared', $hookListner, 'post');
     $hookListnerExpectsPre = ['itemType' => 'file', 'itemSource' => 1, 'shareType' => \OCP\Share::SHARE_TYPE_LINK, 'uidOwner' => 'sharedBy', 'permissions' => 31, 'fileSource' => 1, 'expiration' => $date, 'token' => 'token', 'run' => true, 'error' => ''];
     $hookListnerExpectsPost = ['itemType' => 'file', 'itemSource' => 1, 'shareType' => \OCP\Share::SHARE_TYPE_LINK, 'uidOwner' => 'sharedBy', 'permissions' => 31, 'fileSource' => 1, 'expiration' => $date, 'token' => 'token', 'id' => 42];
     $share->method('getId')->willReturn(42);
     $hookListner->expects($this->once())->method('pre')->with($this->equalTo($hookListnerExpectsPre));
     $hookListner->expects($this->once())->method('post')->with($this->equalTo($hookListnerExpectsPost));
     $manager->createShare($share);
 }
开发者ID:gcstang,项目名称:core,代码行数:37,代码来源:managertest.php


示例20: generateToken

 /**
  * Generate a new CSRF token.
  *
  * @param int $length Length of the token in characters.
  * @return string
  */
 public function generateToken($length = 32)
 {
     return $this->random->generate($length);
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:10,代码来源:csrftokengenerator.php



注:本文中的OCP\Security\ISecureRandom类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Router\Helper类代码示例发布时间:2022-05-23
下一篇:
PHP Files\Folder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap