当前位置: 首页>>代码示例>>PHP>>正文


PHP UserInterface::getPassword方法代码示例

本文整理汇总了PHP中Symfony\Component\Security\Core\User\UserInterface::getPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::getPassword方法的具体用法?PHP UserInterface::getPassword怎么用?PHP UserInterface::getPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Security\Core\User\UserInterface的用法示例。


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

示例1: checkCredentials

 /**
  * {@inheritdoc}
  */
 public function checkCredentials($credentials, UserInterface $user)
 {
     if ($user->getPassword() === $credentials['password']) {
         return true;
     }
     throw new CustomUserMessageAuthenticationException($this->failMessage);
 }
开发者ID:upchuk,项目名称:symfony3,代码行数:10,代码来源:FormAuthenticator.php

示例2: checkAuthentication

 /**
  * {@inheritdoc}
  */
 protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $currentUser = $token->getUser();
     if ($currentUser instanceof UserInterface) {
         if ($currentUser->getPassword() !== $user->getPassword()) {
             throw new BadCredentialsException('The credentials were changed from another session.');
         }
     } else {
         if (!($presentedPassword = $token->getCredentials())) {
             throw new BadCredentialsException('The presented password cannot be empty.');
         }
         if ($user instanceof User) {
             $encoder = $this->encoderFactory->getEncoder($user);
             if (!$encoder->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
                 throw new BadCredentialsException('The presented password is invalid.');
             }
         } else {
             $ldap = new Ldap($this->params['host'], $this->params['port'], $this->params['version']);
             $bind = $ldap->bind($user->getUsername(), $presentedPassword);
             $this->logger->debug(sprintf('LDAP bind with username "%s" and password "%s" yielded: %s', $user->getUsername(), $presentedPassword, print_r($bind, true)));
             if (!$bind) {
                 throw new BadCredentialsException('The presented password is invalid.');
             }
             // There's likely more data in the LDAP result now after a successful bind
             $this->userProvider->refreshUser($user);
         }
     }
 }
开发者ID:mapbender,项目名称:fom,代码行数:31,代码来源:LdapAuthenticationProvider.php

示例3: checkAuthentication

 /**
  * {@inheritdoc}
  */
 protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $currentUser = $token->getUser();
     if ($currentUser instanceof UserInterface) {
         if ($currentUser->getPassword() !== $user->getPassword()) {
             throw new BadCredentialsException('The credentials were changed from another session.');
         }
     } else {
         if (!($presentedPassword = $token->getCredentials())) {
             throw new BadCredentialsException('The presented password cannot be empty.');
         }
         $client = $this->clientFactory->build('en');
         $request = CustomerLoginRequest::ofEmailAndPassword($token->getUser(), $presentedPassword);
         $response = $request->executeWithClient($client);
         if ($response->isError()) {
             throw new BadCredentialsException('The presented password is invalid.');
         }
         $result = $request->mapResponse($response);
         $customer = $result->getCustomer();
         if ($currentUser !== $customer->getEmail()) {
             throw new BadCredentialsException('The presented password is invalid.');
         }
         $this->session->set('customer.id', $customer->getId());
     }
 }
开发者ID:sphereio,项目名称:commercetools-sunrise-php,代码行数:28,代码来源:CTPAuthenticationProvider.php

示例4: checkCredentials

 public function checkCredentials($credentials, UserInterface $user)
 {
     if ($user->getPassword() === $this->passwordEncoder->encodePassword($user, $credentials['password'])) {
         return true;
     }
     throw new CustomUserMessageAuthenticationException("Password is incorrect.");
 }
开发者ID:jayrulez,项目名称:sf3,代码行数:7,代码来源:FormAuthenticator.php

示例5: isEqualTo

 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof CorredorUser || $this->password !== $user->getPassword() || $this->salt !== $user->getSalt() || $this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
开发者ID:eduardobenito10,项目名称:CorredoresRioja,代码行数:7,代码来源:CorredorUser.php

示例6: validateDigest

 /**
  * {@InheritDoc}
  *
  * @throws NonceExpiredException
  */
 public function validateDigest(WsseUserToken $wsseToken, UserInterface $user)
 {
     $created = $wsseToken->created;
     $nonce = $wsseToken->nonce;
     $digest = $wsseToken->digest;
     $secret = $user->getPassword();
     // Check created time is not too far in the future (leaves 5 minutes margin)
     if (strtotime($created) > time() + 300) {
         throw new WsseAuthenticationException(sprintf('Token created date cannot be in future (%d seconds in the future).', time() - strtotime($created)));
     }
     // Expire timestamp after 5 minutes
     if (strtotime($created) < time() - 300) {
         throw new WsseAuthenticationException(sprintf('Token created date has expired its 300 seconds of validity (%d seconds).', strtotime($created) - time()));
     }
     // Validate that the nonce is *not* used in the last 10 minutes
     // if it has, this could be a replay attack
     if (file_exists($this->cacheDir . '/' . $nonce) && file_get_contents($this->cacheDir . '/' . $nonce) + 600 > time()) {
         throw new NonceExpiredException('Previously used nonce detected.');
     }
     // If cache directory does not exist we create it
     if (!is_dir($this->cacheDir)) {
         mkdir($this->cacheDir, 0777, true);
     }
     file_put_contents($this->cacheDir . '/' . $nonce, time());
     // Validate Secret
     $expected = base64_encode(sha1(base64_decode($nonce) . $created . $secret, true));
     if (!StringUtils::equals($expected, $digest)) {
         throw new WsseAuthenticationException('Token digest is not valid.');
     }
     return true;
 }
开发者ID:alcalyn,项目名称:symfony-wsse,代码行数:36,代码来源:PasswordDigestValidator.php

示例7: createLoggedInCookie

 /**
  * Create WordPress logged in cookie
  *
  * @param UserInterface $user
  * @param int $lifetime
  * @return Cookie
  */
 public function createLoggedInCookie(UserInterface $user, $lifetime = 31536000)
 {
     $username = $user->getUsername();
     $password = $user->getPassword();
     $expiration = time() + $lifetime;
     $hmac = $this->generateHmac($username, $expiration, $password);
     return new Cookie($this->getLoggedInCookieName(), $this->encodeCookie(array($username, $expiration, $hmac)), $expiration, $this->configuration->getCookiePath(), $this->configuration->getCookieDomain());
 }
开发者ID:ninodafonte,项目名称:KayueWordpressBundle,代码行数:15,代码来源:AuthenticationCookieManager.php

示例8: isEqualTo

 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof LdapUser) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
开发者ID:kuzomedia,项目名称:LdapBundle,代码行数:13,代码来源:LdapUser.php

示例9: checkAuthentication

 /**
  * {@inheritdoc}
  */
 protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $currentUser = $token->getUser();
     if ($currentUser instanceof UserInterface) {
         if ($currentUser->getPassword() !== $user->getPassword()) {
             throw new BadCredentialsException('The credentials were changed from another session.');
         }
     } else {
         if (!($presentedPassword = $token->getCredentials())) {
             throw new BadCredentialsException('The presented password cannot be empty.');
         }
         if ($user->getPassword()) {
             $encoder = $this->encoderFactory->getEncoder($user);
             $encodedPassword = $encoder->encodePassword($presentedPassword, $user->getSalt());
             if ($encodedPassword != $user->getPassword()) {
                 throw new BadCredentialsException('The presented password is invalid.');
             }
         } elseif (!$this->galittProvider->checkAccount($user->getUsername(), $presentedPassword)) {
             throw new BadCredentialsException('The presented password is invalid.');
         }
     }
 }
开发者ID:blab2015,项目名称:seh,代码行数:25,代码来源:AuthenticationProvider.php

示例10: isEqualTo

 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof UsuariosService) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->salt !== $user->getSalt()) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
开发者ID:ArtesanIO,项目名称:ACLBundle,代码行数:16,代码来源:UsuariosService.php

示例11: equals

 public function equals(UserInterface $user)
 {
     if (!$user instanceof self) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->getSalt() !== $user->getSalt()) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
开发者ID:gitter-badger,项目名称:OAuth2ServerBundle,代码行数:16,代码来源:EndUser.php

示例12: isEqualTo

 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof RedisUser) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->salt !== $user->getSalt()) {
         return false;
     }
     if ($this->email !== $user->getUsername()) {
         return false;
     }
     return true;
 }
开发者ID:volodyawork,项目名称:twitter,代码行数:16,代码来源:RedisUser.php

示例13: checkAuthentication

 /**
  * {@inheritdoc}
  */
 protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $currentUser = $token->getUser();
     if ($currentUser instanceof UserInterface) {
         if ($currentUser->getPassword() !== $user->getPassword()) {
             throw new BadCredentialsException('The credentials were changed from another session.');
         }
     } else {
         if (!($presentedPassword = $token->getCredentials())) {
             throw new BadCredentialsException('Bad credentials');
         }
         if (!$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
             throw new BadCredentialsException('Bad credentials');
         }
     }
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:19,代码来源:DaoAuthenticationProvider.php

示例14: checkAuthentication

 /**
  * {@inheritdoc}
  */
 protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $currentUser = $token->getUser();
     if ($currentUser instanceof UserInterface) {
         if ($currentUser->getPassword() !== $user->getPassword()) {
             throw new BadCredentialsException('The credentials were changed from another session.');
         }
     } else {
         if (!($presentedPassword = $token->getCredentials())) {
             throw new BadCredentialsException('The presented password cannot be empty.');
         }
         if (!$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
             $this->userProvider->handleWrongPassword($user);
             throw new BadCredentialsException('The presented password is invalid.');
         } else {
             $this->userProvider->handleGoodPassword($user);
         }
         if (!$user->isAccountNonLocked()) {
             throw new LockedException(strtr('User account is locked%until%.', array('%until%' => $user->getLockedUntil() ? sprintf(' until %s', $user->getLockedUntil()->format('Y-m-d H:i:s')) : '')), $user);
         }
     }
 }
开发者ID:rodgermd,项目名称:CodeSamples,代码行数:25,代码来源:AuthenticationProvider.php

示例15: isEqualTo

 /**
  *{@inheritdoc}
  */
 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof User) {
         // @codeCoverageIgnoreStart
         return false;
         // @codeCoverageIgnoreEnd
     }
     if ($this->password !== $user->getPassword()) {
         // @codeCoverageIgnoreStart
         return false;
         // @codeCoverageIgnoreEnd
     }
     if ($this->salt !== $user->getSalt()) {
         // @codeCoverageIgnoreStart
         return false;
         // @codeCoverageIgnoreEnd
     }
     if ($this->username !== $user->getUsername()) {
         // @codeCoverageIgnoreStart
         return false;
         // @codeCoverageIgnoreEnd
     }
     return true;
 }
开发者ID:redkite-labs,项目名称:redkitecms-framework,代码行数:27,代码来源:User.php


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