public function afterAddObject($class) { if ($this->getObject(Schemas\SambaSamAccount::class) !== null && $this->getObject(Schemas\CloudService::class) !== null) { $attr = $this->getAttributes()->get('sambalmpassword'); if ($attr->get() !== null) { $this->password = call_user_func($this->encoder . '::parsePassword', $attr); if ($this->isMasterPasswordEnabled()) { $this->password->setMasterPassword(true); } } /*$this->passwords = []; foreach ($this->getObject(Schemas\ShadowAccount::class)->getUserPasswords() as $password) { $password = $this->encoder->parsePassword($password); $this->passwords[$password->getId()] = $password; }*/ } }
/** * (non-PHPdoc) * @see \Cloud\LdapBundle\Security\PasswordEncoderInterface::parsePassword() */ public function parsePassword($password_hash) { $password = new Password(); $password->setHash($password_hash); $matches = null; preg_match('#^{crypt}\\$\\d\\$(rounds=\\d+\\$)?([0-9a-zA-Z_-]+)?(=|\\+)?[0-9a-zA-Z_-]+\\$[^\\$]*$#', $password_hash, $matches); if ($matches != null) { $password->setId(substr($matches[2], 0, -1)); $password->setMasterPassword($matches[3] === '+'); } return $password; }
/** * (non-PHPdoc) * @see \Cloud\LdapBundle\Security\PasswordEncoderInterface::parsePassword() */ public static function parsePassword(Attribute $password_hash) { $password = new Password(); $password->setAttribute($password_hash); $matches = null; $found = preg_match('#^{crypt}\\$\\d\\$(rounds=\\d+\\$)?([0-9a-zA-Z_-]+)?(=|\\+)[0-9a-zA-Z_-]+\\$[^\\$]*$#', $password_hash->get(), $matches); if ($found === 1) { $password->setId($matches[2]); $password->setMasterPassword($matches[3] === '+'); } else { return null; } $password->setEncoder(CryptEncoder::class); return $password; }