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

PHP SecurityToken类代码示例

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

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



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

示例1: deletePersonData

 /**
  * Delete PersonAppData
  *
  * @param
  *   $userId for who data is to be deleted
  * @param
  *   $groupId of the user
  * @param
  *   $appId to which all Appdata belongs to
  * @param
  *   $feilds array of Appdata needs to be deleted 
  * @param
  *   $token security token for validation
  */
 public function deletePersonData($userId, GroupId $groupId, $appId, $fields, SecurityToken $token)
 {
     if ($fields == null || $fields[0] == '*') {
         $key = "*";
         if (!ShindigIntegratorDbFetcher::get()->deleteAppData($userId, $key, $token->getAppId())) {
             throw new SocialSpiException("Internal server error", ResponseError::$INTERNAL_ERROR);
         }
         return null;
     }
     foreach ($fields as $key) {
         if (!ShindigIntegratorAppDataService::isValidKey($key)) {
             throw new SocialSpiException("The person app data key had invalid characters", ResponseError::$BAD_REQUEST);
         }
     }
     switch ($groupId->getType()) {
         case 'self':
             foreach ($fields as $key) {
                 if (!ShindigIntegratorDbFetcher::get()->deleteAppData($userId, $key, $token->getAppId())) {
                     throw new SocialSpiException("Internal server error", ResponseError::$INTERNAL_ERROR);
                 }
             }
             break;
         default:
             throw new SocialSpiException("Not Implemented", ResponseError::$NOT_IMPLEMENTED);
             break;
     }
     return null;
 }
开发者ID:jakob-stoeck,项目名称:os_poker,代码行数:42,代码来源:ShindigIntegratorAppDataService.php


示例2: getAppId

 public static function getAppId($appId, SecurityToken $token)
 {
     if ($appId == '@app') {
         return $token->getAppId();
     } else {
         return $appId;
     }
 }
开发者ID:emma5021,项目名称:toba,代码行数:8,代码来源:DataRequestHandler.php


示例3: createMessage

 public function createMessage($userId, $appId, $message, $optionalMessageId, SecurityToken $token)
 {
     try {
         $messages = ATutorDbFetcher::get()->createMessage($userId, $token->getAppId(), $message);
     } catch (SocialSpiException $e) {
         throw $e;
     } catch (Exception $e) {
         throw new SocialSpiException("Invalid create message request: " . $e->getMessage(), ResponseError::$INTERNAL_ERROR);
     }
 }
开发者ID:genaromendezl,项目名称:ATutor,代码行数:10,代码来源:ATutorMessagesService.php


示例4: getKey

 protected function getKey($userId, SecurityToken $token)
 {
     $pos = strrpos($userId, ':');
     if ($pos !== false) {
         $userId = substr($userId, $pos + 1);
     }
     if ($token->getAppId()) {
         return self::$TOKEN_PREFIX . $token->getAppId() . '_' . $userId;
     }
     return self::$TOKEN_PREFIX . $token->getAppUrl() . '_' . $userId;
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:11,代码来源:OpenPNEInvalidateService.php


示例5: createActivity

 public function createActivity($userId, $groupId, $appId, $fields, $activity, SecurityToken $token)
 {
     try {
         if ($token->getOwnerId() != $token->getViewerId()) {
             throw new SocialSpiException("unauthorized: Create activity permission denied.", ResponseError::$UNAUTHORIZED);
         }
         ATutorDbFetcher::get()->createActivity($userId->getUserId($token), $activity, $token->getAppId());
     } catch (SocialSpiException $e) {
         throw $e;
     } catch (Exception $e) {
         throw new SocialSpiException("Invalid create activity request: " . $e->getMessage(), ResponseError::$INTERNAL_ERROR);
     }
 }
开发者ID:genaromendezl,项目名称:ATutor,代码行数:13,代码来源:ATutorActivityService.php


示例6: update

 public function update(SS_HTTPRequest $request)
 {
     if (!SecurityToken::inst()->checkRequest($request)) {
         return '';
     }
     $url = $request->postVar('URL');
     if (strlen($url)) {
         $info = Oembed::get_oembed_from_url($url);
         if ($info && $info->exists()) {
             $object = EmbeddedObject::create();
             $object->Title = $info->title;
             $object->SourceURL = $url;
             $object->Width = $info->width;
             $object->Height = $info->height;
             $object->ThumbURL = $info->thumbnail_url;
             $object->Description = $info->description ? $info->description : $info->title;
             $object->Type = $info->type;
             $object->EmbedHTML = $info->forTemplate();
             $this->object = $object;
             // needed to make sure the check in FieldHolder works out
             $object->ID = -1;
             return $this->FieldHolder();
         } else {
             $this->message = _t('EmbeddedObjectField.ERROR', 'Could not look up provided URL: ' . Convert::raw2xml($url));
             return $this->FieldHolder();
         }
     } else {
         $this->object = null;
         return $this->FieldHolder();
     }
 }
开发者ID:antons-,项目名称:silverstripe-linkable,代码行数:31,代码来源:EmbeddedObjectField.php


示例7: update

 public function update(SS_HTTPRequest $request)
 {
     if (!SecurityToken::inst()->checkRequest($request)) {
         return '';
     }
     $url = $request->postVar('URL');
     if (strlen($url)) {
         $info = Oembed::get_oembed_from_url($url);
         $info = Embed\Embed::create($url);
         if ($info) {
             $object = EmbeddedObject::create();
             $object->setFromEmbed($info);
             $this->object = $object;
             // needed to make sure the check in FieldHolder works out
             $object->ID = -1;
             return $this->FieldHolder();
         } else {
             $this->message = _t('EmbeddedObjectField.ERROR', 'Could not look up provided URL: ' . Convert::raw2xml($url));
             return $this->FieldHolder();
         }
     } else {
         $this->object = null;
         return $this->FieldHolder();
     }
 }
开发者ID:jason-zz,项目名称:silverstripe-linkable,代码行数:25,代码来源:EmbeddedObjectField.php


示例8: authenticate

 public function authenticate(SS_HTTPRequest $request)
 {
     $token = $this->getToken($request);
     $user = null;
     if (!Member::currentUserID() && !$this->allowPublicAccess || $token) {
         if (!$token) {
             throw new WebServiceException(403, "Missing token parameter");
         }
         $user = $this->tokenAuthenticator->authenticate($token);
         if (!$user) {
             throw new WebServiceException(403, "Invalid user token");
         }
     } else {
         if ($this->allowSecurityId && Member::currentUserID()) {
             // we check the SecurityID parameter for the current user
             $secParam = SecurityToken::inst()->getName();
             $securityID = $request->requestVar($secParam);
             if ($securityID && $securityID != SecurityToken::inst()->getValue()) {
                 throw new WebServiceException(403, "Invalid security ID");
             }
             $user = Member::currentUser();
         }
     }
     if (!$user && !$this->allowPublicAccess) {
         throw new WebServiceException(403, "Invalid request");
     }
     // now, if we have an hmacValidator in place, use it
     if ($this->hmacValidator && $user) {
         if (!$this->hmacValidator->validateHmac($user, $request)) {
             throw new WebServiceException(403, "Invalid message");
         }
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-webservices,代码行数:34,代码来源:WebserviceAuthenticator.php


示例9: handleBatchAction

 public function handleBatchAction($request)
 {
     // This method can't be called without ajax.
     if (!$request->isAjax()) {
         $this->parentController->redirectBack();
         return;
     }
     // Protect against CSRF on destructive action
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->httpError(400);
     }
     $actions = $this->batchActions();
     $actionClass = $actions[$request->param('BatchAction')]['class'];
     $actionHandler = new $actionClass();
     // Sanitise ID list and query the database for apges
     $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs')));
     foreach ($ids as $k => $v) {
         if (!is_numeric($v)) {
             unset($ids[$k]);
         }
     }
     if ($ids) {
         if (class_exists('Translatable') && SiteTree::has_extension('Translatable')) {
             Translatable::disable_locale_filter();
         }
         $recordClass = $this->recordClass;
         $pages = DataObject::get($recordClass)->byIDs($ids);
         if (class_exists('Translatable') && SiteTree::has_extension('Translatable')) {
             Translatable::enable_locale_filter();
         }
         $record_class = $this->recordClass;
         if ($record_class::has_extension('Versioned')) {
             // If we didn't query all the pages, then find the rest on the live site
             if (!$pages || $pages->Count() < sizeof($ids)) {
                 $idsFromLive = array();
                 foreach ($ids as $id) {
                     $idsFromLive[$id] = true;
                 }
                 if ($pages) {
                     foreach ($pages as $page) {
                         unset($idsFromLive[$page->ID]);
                     }
                 }
                 $idsFromLive = array_keys($idsFromLive);
                 $livePages = Versioned::get_by_stage($this->recordClass, 'Live')->byIDs($idsFromLive);
                 if ($pages) {
                     // Can't merge into a DataList, need to condense into an actual list first
                     // (which will retrieve all records as objects, so its an expensive operation)
                     $pages = new ArrayList($pages->toArray());
                     $pages->merge($livePages);
                 } else {
                     $pages = $livePages;
                 }
             }
         }
     } else {
         $pages = new ArrayList();
     }
     return $actionHandler->run($pages);
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:60,代码来源:CMSBatchActionHandler.php


示例10: onBeforeWrite

 /**
  * Ensure we populate these fields before a save.
  */
 public function onBeforeWrite()
 {
     // Run other beforewrites first.
     parent::onBeforeWrite();
     if (!$this->isBrowser()) {
         return false;
     }
     // If this is the first save...
     if (!$this->ID) {
         // Ensure the session exists before querying it.
         if (!Session::request_contains_session_id()) {
             Session::start();
         }
         // Store the sesion and has information in the database.
         $this->SessionID = SecurityToken::getSecurityID();
         if (is_null($this->SessionID)) {
             return false;
         }
         $gen = new RandomGenerator();
         $uniqueurl = substr($gen->randomToken(), 0, 32);
         while (ShortList::get()->filter('URL', $uniqueurl)->count() > 0) {
             $uniqueurl = substr($gen->randomToken(), 0, 32);
         }
         $this->URL = $uniqueurl;
         $this->UserAgent = Controller::curr()->getRequest()->getHeader('User-Agent');
     }
 }
开发者ID:salted-herring,项目名称:silverstripe-shortlist,代码行数:30,代码来源:ShortList.php


示例11: sort

 public function sort($request)
 {
     if (!SecurityToken::inst()->checkRequest($request)) {
         $this->httpError(404);
     }
     $class = $request->postVar('class');
     $ids = $request->postVar('id');
     if ($class == 'WorkflowAction') {
         $objects = $this->Definition()->Actions();
     } elseif ($class == 'WorkflowTransition') {
         $parent = $request->postVar('parent');
         $action = $this->Definition()->Actions()->byID($parent);
         if (!$action) {
             $this->httpError(400, _t('AdvancedWorkflowAdmin.INVALIDPARENTID', 'An invalid parent ID was specified.'));
         }
         $objects = $action->Transitions();
     } else {
         $this->httpError(400, _t('AdvancedWorkflowAdmin.INVALIDCLASSTOORDER', 'An invalid class to order was specified.'));
     }
     if (array_diff($ids, $objects->column('ID'))) {
         $this->httpError(400, _t('AdvancedWorkflowAdmin.INVALIDIDLIST', 'An invalid list of IDs was provided.'));
     }
     singleton('WorkflowService')->reorder($objects, $ids);
     return new SS_HTTPResponse(null, 200, _t('AdvancedWorkflowAdmin.SORTORDERSAVED', 'The sort order has been saved.'));
 }
开发者ID:Neumes,项目名称:advancedworkflow,代码行数:25,代码来源:WorkflowField.php


示例12: createtranslation

 /**
  * Create a new translation from an existing item, switch to this language and reload the tree.
  */
 function createtranslation($data, $form)
 {
     $request = $this->owner->getRequest();
     // Protect against CSRF on destructive action
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->owner->httpError(400);
     }
     $langCode = Convert::raw2sql($request->postVar('NewTransLang'));
     $record = $this->owner->getRecord($request->postVar('ID'));
     if (!$record) {
         return $this->owner->httpError(404);
     }
     $this->owner->Locale = $langCode;
     Translatable::set_current_locale($langCode);
     // Create a new record in the database - this is different
     // to the usual "create page" pattern of storing the record
     // in-memory until a "save" is performed by the user, mainly
     // to simplify things a bit.
     // @todo Allow in-memory creation of translations that don't
     // persist in the database before the user requests it
     $translatedRecord = $record->createTranslation($langCode);
     $url = Controller::join_links($this->owner->Link('show'), $translatedRecord->ID);
     // set the X-Pjax header to Content, so that the whole admin panel will be refreshed
     $this->owner->getResponse()->addHeader('X-Pjax', 'Content');
     return $this->owner->redirect($url);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-translatable,代码行数:29,代码来源:TranslatableCMSMainExtension.php


示例13: tearDown

 public function tearDown()
 {
     SecurityToken::enable();
     $this->folder->deleteDatabaseOnly();
     Filesystem::removeFolder($this->folder->getFullPath());
     parent::tearDown();
 }
开发者ID:camfindlay,项目名称:silverstripe-versionedfiles,代码行数:7,代码来源:VersionedFileTest.php


示例14: onAuthenticationSuccess

 /**
  * This is called when an interactive authentication attempt succeeds. This
  * is called by authentication listeners inheriting from AbstractAuthenticationListener.
  * @param  Request        $request
  * @param  TokenInterface $token
  * @return Response       The response to return
  */
 public function onAuthenticationSuccess(Request $request, TokenInterface $token)
 {
     $user = $token->getUser();
     // This should actually be handle by the AuthenticationFailedHandler
     if (!$user->isAdmin()) {
         // can't go into admin
         $request->getSession()->set(SecurityContextInterface::AUTHENTICATION_ERROR, new AuthenticationException('User is not an admin.'));
         return $this->httpUtils->createRedirectResponse($request, 'admin_login');
     }
     \LoginAttempts::DeleteOldLoginAttempts();
     \LoginAttempts::ClearLoginAttemptsForIp();
     $zendAuth = \Zend_Auth::getInstance();
     $this->authAdapter->setUsername($user->getUsername())->setPassword($request->request->get('_password'))->setAdmin(true);
     $zendAuth->authenticate($this->authAdapter);
     $OAuthtoken = $this->userService->loginUser($user, 'oauth_authorize');
     $session = $request->getSession();
     $session->set('_security_oauth_authorize', serialize($OAuthtoken));
     $frontendToken = $this->userService->loginUser($user, 'frontend_area');
     $session = $request->getSession();
     $session->set('_security_frontend_area', serialize($frontendToken));
     \Article::UnlockByUser($user->getId());
     $request->setLocale($request->request->get('login_language'));
     $this->setNoCacheCookie($request);
     $user->setLastLogin(new \DateTime());
     $this->em->flush();
     if ($request->get('ajax') === 'true') {
         // close popup with login.
         return new Response("<script type=\"text/javascript\">window.parent.g_security_token = '" . \SecurityToken::GetToken() . "';window.parent.\$(window.parent.document.body).data('loginDialog').dialog('close');window.parent.setSecurityToken(window.parent.g_security_token);</script>");
     }
     return parent::onAuthenticationSuccess($request, $token);
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:38,代码来源:AuthenticationSuccessHandler.php


示例15: testCorruptedOrderItemLinks

 /**
  * Coverage for a bug where there's an error generating the link when ProductID = 0
  */
 public function testCorruptedOrderItemLinks()
 {
     SecurityToken::disable();
     $product = $this->socks;
     $item = $product->Item();
     $item->ProductID = 0;
     $this->assertEquals('', $item->removeLink());
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:11,代码来源:ProductOrderItemTest.php


示例16: getSecurityToken

 /**
  * Generate a security token.
  * */
 public static function getSecurityToken()
 {
     // Ensure the session exists before querying it.
     if (!Session::request_contains_session_id()) {
         Session::start();
     }
     return SecurityToken::inst()->getSecurityID();
 }
开发者ID:salted-herring,项目名称:silverstripe-shortlist,代码行数:11,代码来源:Utilities.php


示例17: getUserId

 public function getUserId(SecurityToken $token)
 {
     switch ($this->type) {
         case 'viewer':
             return $token->getViewerId();
             break;
         case 'owner':
             return $token->getOwnerId();
             break;
         case 'userId':
             return $this->userId;
             break;
         default:
             throw new Exception("The type field is not a valid enum: {$this->type}");
             break;
     }
 }
开发者ID:ahmedadham88,项目名称:enhanced-social-network,代码行数:17,代码来源:UserId.php


示例18: saveComplexTableField

 public function saveComplexTableField($data, $form, $params)
 {
     $child = new $data['ClassName']();
     $child->ParentID = $this->controller->ID;
     $child->write();
     $link = SecurityToken::inst()->addToUrl(Controller::join_links($this->Link(), 'item', $child->ID, 'edit'));
     Session::set('FormInfo.ComplexTableField_Popup_DetailForm.formError', array('message' => _t('MemberProfiles.SECTIONADDED', 'Profile section added, please edit it below.'), 'type' => 'good'));
     return Director::redirect($link);
 }
开发者ID:newsplash,项目名称:silverstripe-memberprofiles,代码行数:9,代码来源:MemberProfileSectionField.php


示例19: doUpload

 /**
  * @param $data
  * @param $form
  * @return mixed
  */
 public function doUpload($data, $form)
 {
     $material = PresentationSlide::create();
     $material->SlideID = $data['Slide'];
     $material->write();
     $this->presentation->Materials()->filter(['ClassName' => 'PresentationSlide'])->removeAll();
     $this->presentation->Materials()->add($material);
     $token = SecurityToken::inst()->getValue();
     return $form->controller()->redirect(Controller::join_links($form->controller()->Link(), 'success', "?key={$token}&material={$material->ID}"));
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:15,代码来源:PresentationMediaUploadForm.php


示例20: testLinks

 /**
  * Check  the links are accurate
  */
 public function testLinks()
 {
     SecurityToken::disable();
     $product = $this->socks;
     $item = $product->Item();
     $this->assertEquals("shoppingcart/add/Product/{$product->ID}", $item->addLink());
     $this->assertEquals("shoppingcart/remove/Product/{$product->ID}", $item->removeLink());
     $this->assertEquals("shoppingcart/removeall/Product/{$product->ID}", $item->removeallLink());
     $this->assertEquals("shoppingcart/setquantity/Product/{$product->ID}", $item->setquantityLink());
 }
开发者ID:8secs,项目名称:cocina,代码行数:13,代码来源:ProductOrderItemTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP SecurityUtil类代码示例发布时间:2022-05-23
下一篇:
PHP SecurityTestHelper类代码示例发布时间: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