You are here

public function SimpleOauthCommands::generateKeys in Simple OAuth (OAuth2) & OpenID Connect 8.4

Same name and namespace in other branches
  1. 8.3 src/Commands/SimpleOauthCommands.php \Drupal\simple_oauth\Commands\SimpleOauthCommands::generateKeys()
  2. 5.x src/Commands/SimpleOauthCommands.php \Drupal\simple_oauth\Commands\SimpleOauthCommands::generateKeys()

Generate Oauth2 Keys.

@usage simple-oauth:generate-keys /var/www/drupal-example.org/keys Creates the keys in the /var/www/drupal-example.org/keys directory.

@command simple-oauth:generate-keys @aliases so:generate-keys, sogk

@validate-module-enabled simple_oauth

Parameters

string $keypath: The full path were the key files will be saved.

File

src/Commands/SimpleOauthCommands.php, line 65

Class

SimpleOauthCommands
Drush commands for Simple OAuth.

Namespace

Drupal\simple_oauth\Commands

Code

public function generateKeys($keypath) {
  if (!$this
    ->isDirectory($keypath)) {
    $this->fileSystem
      ->mkdir($keypath);
  }
  $keys_path = $this->fileSystem
    ->realpath($keypath);
  try {
    $this->keygen
      ->generateKeys($keys_path);
    $this
      ->logger()
      ->notice('Keys successfully generated at {path}.', [
      'path' => $keypath,
    ]);
  } catch (FilesystemValidationException $e) {
    $this
      ->logger()
      ->error($e
      ->getMessage());
  } catch (ExtensionNotLoadedException $e) {
    $this
      ->logger()
      ->error($e
      ->getMessage());
  }
}