當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Encryption\EncryptorInterface類代碼示例

本文整理匯總了PHP中Magento\Framework\Encryption\EncryptorInterface的典型用法代碼示例。如果您正苦於以下問題:PHP EncryptorInterface類的具體用法?PHP EncryptorInterface怎麽用?PHP EncryptorInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EncryptorInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct(ClientInterface $client, OpenpayExceptionMapper $exceptionMapper, OpenpayFeeValidator $validator, OpenpayTransactionMapper $transactionMapper, EncryptorInterface $encryptor, ScopeConfigInterface $config)
 {
     $paymentOpenpayConfig = $config->getValue('payment/openpay');
     $paymentOpenpayConfig['merchantId'] = $encryptor->decrypt($paymentOpenpayConfig['merchantId']);
     $paymentOpenpayConfig['apiKey'] = $encryptor->decrypt($paymentOpenpayConfig['apiKey']);
     $paymentOpenpayConfig['publicKey'] = $encryptor->decrypt($paymentOpenpayConfig['publicKey']);
     parent::__construct($client, $exceptionMapper, $validator, $transactionMapper, $paymentOpenpayConfig);
 }
開發者ID:degaray,項目名稱:openpay-magento2-module,代碼行數:8,代碼來源:OpenpayFeeAdapter.php

示例2: install

 /**
  * {@inheritdoc}
  */
 public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
 {
     /** @var State[] $stateIndexers */
     $stateIndexers = [];
     $states = $this->statesFactory->create();
     foreach ($states->getItems() as $state) {
         /** @var State $state */
         $stateIndexers[$state->getIndexerId()] = $state;
     }
     foreach ($this->config->getIndexers() as $indexerId => $indexerConfig) {
         $expectedHashConfig = $this->encryptor->hash($this->encoder->encode($indexerConfig), Encryptor::HASH_VERSION_MD5);
         if (isset($stateIndexers[$indexerId])) {
             if ($stateIndexers[$indexerId]->getHashConfig() != $expectedHashConfig) {
                 $stateIndexers[$indexerId]->setStatus(StateInterface::STATUS_INVALID);
                 $stateIndexers[$indexerId]->setHashConfig($expectedHashConfig);
                 $stateIndexers[$indexerId]->save();
             }
         } else {
             /** @var State $state */
             $state = $this->stateFactory->create();
             $state->loadByIndexer($indexerId);
             $state->setHashConfig($expectedHashConfig);
             $state->setStatus(StateInterface::STATUS_INVALID);
             $state->save();
         }
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:30,代碼來源:Recurring.php

示例3: generatePublicHash

 /**
  * Generate vault payment public hash
  *
  * @param PaymentTokenInterface $paymentToken
  * @return string
  */
 protected function generatePublicHash(PaymentTokenInterface $paymentToken)
 {
     $hashKey = $paymentToken->getGatewayToken();
     if ($paymentToken->getCustomerId()) {
         $hashKey = $paymentToken->getCustomerId();
     }
     $hashKey .= $paymentToken->getPaymentMethodCode() . $paymentToken->getType() . $paymentToken->getTokenDetails();
     return $this->encryptor->getHash($hashKey);
 }
開發者ID:koliaGI,項目名稱:magento2,代碼行數:15,代碼來源:AfterPaymentSaveObserver.php

示例4: get

 /**
  * {@inheritdoc}
  */
 public function get($storeId = null)
 {
     /** @var CredentialsInterface $credentials */
     $credentials = $this->credentialsFactory->create();
     $configValues = $this->scopeConfig->getValue(self::PAYMENT_OPENPAY_PATH, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     $merchantId = $this->encryptor->decrypt($configValues['merchantId']);
     $publicKey = $this->encryptor->decrypt($configValues['publicKey']);
     $credentials->setMerchantId($merchantId)->setPublicKey($publicKey)->setIsSandboxMode($configValues['sandbox']);
     return $credentials;
 }
開發者ID:degaray,項目名稱:openpay-magento2-module,代碼行數:13,代碼來源:CredentialsRepository.php

示例5: execute

 /**
  * Upgrade customer password hash when customer has logged in
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $password = $observer->getEvent()->getData('password');
     /** @var \Magento\Customer\Model\Customer $model */
     $model = $observer->getEvent()->getData('model');
     $customer = $this->customerRepository->getById($model->getId());
     $customerSecure = $this->customerRegistry->retrieveSecureData($model->getId());
     if (!$this->encryptor->validateHashVersion($customerSecure->getPasswordHash(), true)) {
         $customerSecure->setPasswordHash($this->encryptor->getHash($password, true));
         $this->customerRepository->save($customer);
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:18,代碼來源:UpgradeCustomerPasswordObserver.php

示例6: testExecuteNonRandomAndWithCryptKey

 public function testExecuteNonRandomAndWithCryptKey()
 {
     $expectedMessage = 'The encryption key has been changed.';
     $key = 1;
     $newKey = 'RSASHA9000VERYSECURESUPERMANKEY';
     $this->requestMock->expects($this->at(0))->method('getPost')->with($this->equalTo('generate_random'))->willReturn(0);
     $this->requestMock->expects($this->at(1))->method('getPost')->with($this->equalTo('crypt_key'))->willReturn($key);
     $this->encryptMock->expects($this->once())->method('validateKey');
     $this->changeMock->expects($this->once())->method('changeEncryptionKey')->willReturn($newKey);
     $this->managerMock->expects($this->once())->method('addSuccessMessage')->with($expectedMessage);
     $this->cacheMock->expects($this->once())->method('clean');
     $this->responseMock->expects($this->once())->method('setRedirect');
     $this->model->execute();
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:14,代碼來源:SaveTest.php

示例7: execute

 /**
  * Save current admin password to prevent its usage when changed in the future.
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     /* @var $user \Magento\User\Model\User */
     $user = $observer->getEvent()->getObject();
     if ($user->getId()) {
         $password = $user->getCurrentPassword();
         $passwordLifetime = $this->observerConfig->getAdminPasswordLifetime();
         if ($passwordLifetime && $password && !$user->getForceNewPassword()) {
             $passwordHash = $this->encryptor->getHash($password, false);
             $this->userResource->trackPassword($user, $passwordHash, $passwordLifetime);
             $this->messageManager->getMessages()->deleteMessageByIdentifier('magento_user_password_expired');
             $this->authSession->unsPciAdminUserIsPasswordExpired();
         }
     }
 }
開發者ID:vv-team,項目名稱:foodo,代碼行數:21,代碼來源:TrackAdminNewPasswordObserver.php

示例8: execute

 /**
  * Admin locking and password hashing upgrade logic implementation
  *
  * @param EventObserver $observer
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function execute(EventObserver $observer)
 {
     $password = $observer->getEvent()->getPassword();
     /** @var User $user */
     $user = $observer->getEvent()->getUser();
     $authResult = $observer->getEvent()->getResult();
     if (!$authResult && $user->getId()) {
         // update locking information regardless whether user locked or not
         $this->_updateLockingInformation($user);
     }
     // check whether user is locked
     $lockExpires = $user->getLockExpires();
     if ($lockExpires) {
         $lockExpires = new \DateTime($lockExpires);
         if ($lockExpires > new \DateTime()) {
             throw new UserLockedException(__('You did not sign in correctly or your account is temporarily disabled.'));
         }
     }
     if (!$authResult) {
         return;
     }
     $this->userResource->unlock($user->getId());
     $latestPassword = $this->userResource->getLatestPassword($user->getId());
     $this->_checkExpiredPassword($latestPassword);
     if (!$this->encryptor->validateHashVersion($user->getPassword(), true)) {
         $user->setPassword($password)->setData('force_new_password', true)->save();
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:35,代碼來源:AuthObserver.php

示例9: testAdminAuthenticate

 public function testAdminAuthenticate()
 {
     $password = "myP@sw0rd";
     $uid = 123;
     $authResult = true;
     $lockExpires = false;
     $userPassword = ['expires' => 1];
     /** @var Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
     $eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var Event|\PHPUnit_Framework_MockObject_MockObject */
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getPassword', 'getUser', 'getResult'])->getMock();
     /** @var ModelUser|\PHPUnit_Framework_MockObject_MockObject $userMock */
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['getId', 'getLockExpires', 'getPassword', 'save'])->getMock();
     $eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
     $eventMock->expects($this->once())->method('getPassword')->willReturn($password);
     $eventMock->expects($this->once())->method('getUser')->willReturn($userMock);
     $eventMock->expects($this->once())->method('getResult')->willReturn($authResult);
     $userMock->expects($this->atLeastOnce())->method('getId')->willReturn($uid);
     $userMock->expects($this->once())->method('getLockExpires')->willReturn($lockExpires);
     $this->userMock->expects($this->once())->method('unlock');
     $this->userMock->expects($this->once())->method('getLatestPassword')->willReturn($userPassword);
     $this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
     /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
     $collectionMock = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->managerInterfaceMock->expects($this->once())->method('getMessages')->willReturn($collectionMock);
     $collectionMock->expects($this->once())->method('getLastAddedMessage')->willReturn($this->messageInterfaceMock);
     $this->messageInterfaceMock->expects($this->once())->method('setIdentifier')->willReturnSelf();
     $this->authSessionMock->expects($this->once())->method('setPciAdminUserIsPasswordExpired');
     $this->encryptorMock->expects($this->once())->method('validateHashVersion')->willReturn(false);
     $this->model->execute($eventObserverMock);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:31,代碼來源:AuthObserverTest.php

示例10: authenticate

 /**
  * {@inheritdoc}
  */
 public function authenticate($username, $password)
 {
     try {
         switch ($this->advancedLoginConfigProvider->getLoginMode()) {
             case LoginMode::LOGIN_TYPE_ONLY_ATTRIBUTE:
                 $customer = $this->loginViaCustomerAttributeOnly($username);
                 break;
             case LoginMode::LOGIN_TYPE_BOTH:
                 $customer = $this->loginViaCustomerAttributeOrEmail($username);
                 break;
             default:
                 $customer = $this->loginViaEmailOnly($username);
                 break;
         }
     } catch (NoSuchEntityException $e) {
         throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
     }
     $this->checkPasswordStrength($password);
     $hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
     if (!$this->encryptor->validateHash($password, $hash)) {
         throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
     }
     if ($customer->getConfirmation() && $this->isConfirmationRequired($customer)) {
         throw new EmailNotConfirmedException(__('This account is not confirmed.'));
     }
     $customerModel = $this->customerFactory->create()->updateData($customer);
     $this->eventManager->dispatch('customer_customer_authenticated', ['model' => $customerModel, 'password' => $password]);
     $this->eventManager->dispatch('customer_data_object_login', ['customer' => $customer]);
     return $customer;
 }
開發者ID:semaio,項目名稱:magento2-advancedlogin,代碼行數:33,代碼來源:AccountManagement.php

示例11: _createCertFile

 /**
  * Create physical certificate file based on DB data
  *
  * @param string $file
  * @return void
  */
 protected function _createCertFile($file)
 {
     if ($this->varDirectory->isDirectory(self::BASEPATH_PAYPAL_CERT)) {
         $this->_removeOutdatedCertFile();
     }
     $this->varDirectory->writeFile($file, $this->encryptor->decrypt($this->getContent()));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:13,代碼來源:Cert.php

示例12: getSecretKey

 /**
  * Generate secret key for controller and action based on form key
  *
  * @param string $routeName
  * @param string $controller Controller name
  * @param string $action Action name
  * @return string
  */
 public function getSecretKey($routeName = null, $controller = null, $action = null)
 {
     $salt = $this->formKey->getFormKey();
     $request = $this->_getRequest();
     if (!$routeName) {
         if ($request->getBeforeForwardInfo('route_name') !== null) {
             $routeName = $request->getBeforeForwardInfo('route_name');
         } else {
             $routeName = $request->getRouteName();
         }
     }
     if (!$controller) {
         if ($request->getBeforeForwardInfo('controller_name') !== null) {
             $controller = $request->getBeforeForwardInfo('controller_name');
         } else {
             $controller = $request->getControllerName();
         }
     }
     if (!$action) {
         if ($request->getBeforeForwardInfo('action_name') !== null) {
             $action = $request->getBeforeForwardInfo('action_name');
         } else {
             $action = $request->getActionName();
         }
     }
     $secret = $routeName . $controller . $action . $salt;
     return $this->_encryptor->getHash($secret);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:36,代碼來源:Url.php

示例13: testDecrypt

 public function testDecrypt()
 {
     $data = 'data';
     $encryptedData = 'd1a2t3a4';
     $this->encryptorInterfaceMock->expects($this->once())->method('decrypt')->with($encryptedData)->will($this->returnValue($data));
     $this->assertEquals($data, $this->info->decrypt($encryptedData));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:7,代碼來源:InfoTest.php

示例14: testSaveTokenWithPaymentLinkWithDuplicateTokenNotVisible

 /**
  * Run test for saveTokenWithPaymentLink method
  */
 public function testSaveTokenWithPaymentLinkWithDuplicateTokenNotVisible()
 {
     /** @var OrderPaymentInterface|\PHPUnit_Framework_MockObject_MockObject $paymentMock */
     $paymentMock = $this->getMock(OrderPaymentInterface::class);
     /** @var PaymentTokenInterface|\PHPUnit_Framework_MockObject_MockObject $tokenMock */
     $tokenMock = $this->getMock(PaymentTokenInterface::class);
     /** @var PaymentTokenInterface|\PHPUnit_Framework_MockObject_MockObject $duplicateToken */
     $duplicateToken = $this->getMock(PaymentTokenInterface::class);
     $entityId = 1;
     $newEntityId = 1;
     $paymentId = 1;
     $customerId = 1;
     $gatewayToken = 'xs4vf3';
     $publicHash = 'existing-token';
     $duplicateTokenData = ['entity_id' => $entityId];
     $newHash = 'new-token2';
     $tokenMock->expects(static::atLeastOnce())->method('getPublicHash')->willReturn($publicHash);
     $tokenMock->expects(static::atLeastOnce())->method('getCustomerId')->willReturn($customerId);
     $this->paymentTokenResourceModelMock->expects(self::once())->method('getByPublicHash')->with($publicHash, $customerId)->willReturn($duplicateTokenData);
     $this->paymentTokenFactoryMock->expects(self::once())->method('create')->with(['data' => $duplicateTokenData])->willReturn($duplicateToken);
     $tokenMock->expects(static::atLeastOnce())->method('getIsVisible')->willReturn(false);
     $tokenMock->expects(static::atLeastOnce())->method('getCustomerId')->willReturn($customerId);
     $tokenMock->expects(static::atLeastOnce())->method('getGatewayToken')->willReturn($gatewayToken);
     $this->encryptorMock->expects(static::once())->method('getHash')->with($publicHash . $gatewayToken)->willReturn($newHash);
     $tokenMock->expects(static::once())->method('setPublicHash')->with($newHash);
     $this->paymentTokenRepositoryMock->expects(self::once())->method('save')->with($tokenMock);
     $tokenMock->expects(static::atLeastOnce())->method('getEntityId')->willReturn($newEntityId);
     $paymentMock->expects(self::atLeastOnce())->method('getEntityId')->willReturn($paymentId);
     $this->paymentTokenResourceModelMock->expects(static::once())->method('addLinkToOrderPayment')->with($newEntityId, $paymentId);
     $this->paymentTokenManagement->saveTokenWithPaymentLink($tokenMock, $paymentMock);
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:34,代碼來源:PaymentTokenManagementTest.php

示例15: testVerifyIdentityNoAssignedRoles

 public function testVerifyIdentityNoAssignedRoles()
 {
     $password = 'password';
     $this->_encryptorMock->expects($this->once())->method('validateHash')->with($password, $this->_model->getPassword())->will($this->returnValue(true));
     $this->_model->setIsActive(true);
     $this->_resourceMock->expects($this->once())->method('hasAssigned2Role')->will($this->returnValue(false));
     $this->setExpectedException('Magento\\Framework\\Exception\\AuthenticationException', 'Access denied.');
     $this->_model->verifyIdentity($password);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:9,代碼來源:UserTest.php


注:本文中的Magento\Framework\Encryption\EncryptorInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。