本文整理汇总了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);
}
示例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);
}
}
}
示例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());
}
}
示例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.");
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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.');
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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');
}
}
}
示例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);
}
}
}
示例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;
}