/** * (non-PHPdoc) * @see \Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::isPasswordValid() */ public static function isPasswordValid(Password $password) { $hash = $password->getHash(); if (self::NTLMHash($password->getPasswordPlain()) === $hash) { return true; } return false; }
/** * (non-PHPdoc) * @see \Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::isPasswordValid() */ public static function isPasswordValid(Password $password) { if (substr($password->getHash(), 0, 7) != '{crypt}') { return false; } $hash = substr($password->getHash(), 7); if (crypt($password->getPasswordPlain(), $hash) === $hash) { return true; } return false; }
/** * * @param Password $password * @return \Cloud\LdapBundle\Entity\Service */ public function addPassword(Password $password) { //@TODO update to new schema if ($password->getEncoder() === $this->getEncoder()) { $attr = $this->getAttributes()->get('sambalmpassword'); $attr->set($password->getAttribute()->get()); $password->setAttribute($attr); $this->password = $password; return $this; } if ($password->getPasswordPlain() === null) { throw new \InvalidArgumentException("can't store false encoded password"); } $password->setAttribute($this->getAttributes()->get('sambalmpassword')); call_user_func($this->getEncoder() . '::encodePassword', $password); return $this; }
/** * * @param Password $password * @return \Cloud\LdapBundle\Entity\Service */ public function addPassword(Password $password) { // reject password if no plaintext password is set and incompatible hash if ($password->getPasswordPlain() === null && $password->getEncoder() !== $this->getEncoder()) { throw new \InvalidArgumentException(); } if (isset($this->passwords[$password->getId()])) { $this->removePassword($this->passwords[$password->getId()]); } $this->passwords[$password->getId()] = $password; $this->getAttributes()->get('userpassword')->add($password->getAttribute()); if ($password->getService() !== $this) { $password->setService($this); } return $this; }