/** * */ public function createAction() { $isPublic = (bool) ($this->params('public') ?: $this->showPrompt('public')); $description = $this->params('description') ?: $this->showPrompt('description'); $grantTypes = $this->params('grant-types') ?: $this->showPrompt('grant-types'); $redirectUri = $this->params('redirect-uri') ?: $this->showPrompt('redirect-uri'); $secret = null; $encryptedSecret = null; if (!$isPublic) { $secret = Rand::getString(32); $encryptedSecret = $this->password->create($secret); } if ($grantTypes) { $grantTypes = explode(',', $grantTypes); array_walk($grantTypes, function (&$grant) { $grant = trim($grant); }); } $client = new Client(null, $encryptedSecret, null, $grantTypes, $redirectUri, $description); $this->clientMapper->save($client); $this->getConsole()->writeLine(); $this->getConsole()->writeLine('* Client created *', Color::GREEN); if (!$isPublic) { $this->getConsole()->writeLine('The client secret was auto-generated and encrypted. Please store it safely.'); $this->getConsole()->writeLine("Don't ever disclose the client secret publicly", Color::YELLOW); $this->getConsole()->writeLine(); } $this->getConsole()->writeLine("UUID: \t\t" . $client->getUuid()); if (!$isPublic) { $this->getConsole()->writeLine("Secret: \t" . $secret); } $this->getConsole()->writeLine("Grant types: \t" . implode(', ', $client->getGrantTypes())); $this->getConsole()->writeLine("Description: \t" . $client->getDescription()); $this->getConsole()->writeLine("Redirect URI: \t" . $client->getRedirectUri()); }
/** * {@inheritdoc} */ public function hash($plain) { return $this->password->create($plain); }
/** * Hashes a password * @param string $password * @return string */ private function hashPassword($password) { return $this->adapter->create($password); }