acl = $acl; switch ($type) { case self::TYPE_NORMAL: return $this->getPasswordClear($account); break; case self::TYPE_FULL: $this->setTemplateVars($account); break; } } /** * Returns account's password * * @param AccountPassData $accountData * @return string * @throws HelperException * @throws \Defuse\Crypto\Exception\BadFormatException * @throws \Defuse\Crypto\Exception\CryptoException * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException */ protected function getPasswordClear(AccountPassData $accountData) { if (!$this->acl->checkUserAccess(ActionsInterface::ACCOUNT_VIEW_PASS) || $accountData->getAccountId() === 0 ) { throw new HelperException(__u('No tiene permisos para acceder a esta cuenta')); } if (!UserPass::checkUserUpdateMPass($this->session->getUserData()->getUserId())) { throw new HelperException(__('Clave maestra actualizada') . '
' . __('Reinicie la sesión para cambiarla')); } $key = CryptSession::getSessionKey(); $securedKey = Crypt::unlockSecuredKey($accountData->getAccountKey(), $key); return trim(Crypt::decrypt($accountData->getAccountPass(), $securedKey, $key)); } /** * @param AccountPassData $accountData * @throws HelperException * @throws \Defuse\Crypto\Exception\BadFormatException * @throws \Defuse\Crypto\Exception\CryptoException * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException * @throws \Psr\Container\ContainerExceptionInterface * @throws \SP\Core\Exceptions\SPException */ protected function setTemplateVars(AccountPassData $accountData) { $this->view->addTemplate('viewpass'); $this->view->assign('header', __('Clave de Cuenta')); $this->view->assign('login', $accountData->getAccountLogin()); $pass = $this->getPasswordClear($accountData); if ($this->configData->isAccountPassToImage()) { $this->view->assign('pass', ImageUtil::convertText($pass)); $this->view->assign('isImage', 1); } else { $this->view->assign('pass', htmlentities($pass)); $this->view->assign('isImage', 0); } $this->view->assign('isLinked', $accountData->account_parentId > 0); $this->view->assign('sk', SessionUtil::getSessionKey(true)); } }