/** * * @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; }