abstract class EdgeKeyTypeBase in Apigee Edge 8
Defines a base class for Apigee Edge Key Type plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\key\Plugin\KeyPluginBase implements KeyPluginInterface
- class \Drupal\key\Plugin\KeyTypeBase implements KeyTypeInterface
- class \Drupal\apigee_edge\Plugin\EdgeKeyTypeBase implements EdgeKeyTypeInterface
- class \Drupal\key\Plugin\KeyTypeBase implements KeyTypeInterface
- class \Drupal\key\Plugin\KeyPluginBase implements KeyPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of EdgeKeyTypeBase
1 file declares its use of EdgeKeyTypeBase
- ApigeeAuthKeyType.php in src/
Plugin/ KeyType/ ApigeeAuthKeyType.php
File
- src/
Plugin/ EdgeKeyTypeBase.php, line 33
Namespace
Drupal\apigee_edge\PluginView source
abstract class EdgeKeyTypeBase extends KeyTypeBase implements EdgeKeyTypeInterface {
/**
* {@inheritdoc}
*/
public function serialize(array $array) {
return Json::encode($array);
}
/**
* {@inheritdoc}
*/
public function unserialize($value) {
return Json::decode($value);
}
/**
* {@inheritdoc}
*/
public function getAuthenticationType(KeyInterface $key) : string {
if ($this
->getInstanceType($key) === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
if ($this
->useGcpDefaultServiceAccount($key)) {
return EdgeKeyTypeInterface::EDGE_AUTH_TYPE_DEFAULT_GCE_SERVICE_ACCOUNT;
}
else {
return EdgeKeyTypeInterface::EDGE_AUTH_TYPE_JWT;
}
}
if (!isset($key
->getKeyValues()['auth_type'])) {
throw new AuthenticationKeyValueMalformedException('auth_type');
}
return $key
->getKeyValues()['auth_type'];
}
/**
* {@inheritdoc}
*/
public function getEndpoint(KeyInterface $key) : string {
if ($this
->getInstanceType($key) === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
return ClientInterface::APIGEE_ON_GCP_ENDPOINT;
}
elseif ($this
->getInstanceType($key) === EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC) {
return Client::EDGE_ENDPOINT;
}
return $key
->getKeyValues()['endpoint'];
}
/**
* {@inheritdoc}
*/
public function getEndpointType(KeyInterface $key) : string {
if ($this
->getInstanceType($key) === EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC) {
/* @phpstan-ignore-next-line */
return EdgeKeyTypeInterface::EDGE_ENDPOINT_TYPE_DEFAULT;
}
/* @phpstan-ignore-next-line */
return EdgeKeyTypeInterface::EDGE_ENDPOINT_TYPE_CUSTOM;
}
/**
* {@inheritdoc}
*/
public function getInstanceType(KeyInterface $key) : string {
$key_values = $key
->getKeyValues();
if (isset($key_values['instance_type'])) {
return $key_values['instance_type'];
}
// Backwards compatibility, before Hybrid support.
if (empty($key_values['endpoint']) || $key_values['endpoint'] === ClientInterface::EDGE_ENDPOINT) {
return EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC;
}
return EdgeKeyTypeInterface::INSTANCE_TYPE_PRIVATE;
}
/**
* {@inheritdoc}
*/
public function getOrganization(KeyInterface $key) : string {
if (!isset($key
->getKeyValues()['organization'])) {
throw new AuthenticationKeyValueMalformedException('organization');
}
return $key
->getKeyValues()['organization'];
}
/**
* {@inheritdoc}
*/
public function getUsername(KeyInterface $key) : string {
if (!isset($key
->getKeyValues()['username'])) {
throw new AuthenticationKeyValueMalformedException('username');
}
return $key
->getKeyValues()['username'];
}
/**
* {@inheritdoc}
*/
public function getPassword(KeyInterface $key) : string {
if (!isset($key
->getKeyValues()['password'])) {
throw new AuthenticationKeyValueMalformedException('password');
}
return $key
->getKeyValues()['password'];
}
/**
* {@inheritdoc}
*/
public function getAuthorizationServer(KeyInterface $key) : string {
return $key
->getKeyValues()['authorization_server'] ?? Oauth::DEFAULT_AUTHORIZATION_SERVER;
}
/**
* {@inheritdoc}
*/
public function getClientId(KeyInterface $key) : string {
return $key
->getKeyValues()['client_id'] ?? Oauth::DEFAULT_CLIENT_ID;
}
/**
* {@inheritdoc}
*/
public function getClientSecret(KeyInterface $key) : string {
return $key
->getKeyValues()['client_secret'] ?? Oauth::DEFAULT_CLIENT_SECRET;
}
/**
* {@inheritdoc}
*/
public function getAccountKey(KeyInterface $key) : array {
$value = $key
->getKeyValues()['account_json_key'] ?? '';
$json = json_decode($value, TRUE);
if (empty($json['private_key']) || empty($json['client_email'])) {
throw new AuthenticationKeyValueMalformedException('account_json_key');
}
return $json;
}
/**
* {@inheritdoc}
*/
public function useGcpDefaultServiceAccount(KeyInterface $key) : bool {
return !empty($key
->getKeyValues()['gcp_hosted']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EdgeKeyTypeBase:: |
public | function |
Return the JSON account key decoded as an array. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the authentication type. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the authorization server. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the client ID. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the client secret. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API endpoint. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API endpoint type (default or custom). Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the instance type (public, private or hybrid). Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API organization. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API password. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API username. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Serialize an array of key values into a string. Overrides KeyTypeMultivalueInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Unserialize a string of key values into an array. Overrides KeyTypeMultivalueInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Return if you should use the Default Service account. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeInterface:: |
constant | ID of the basic authentication method. | ||
EdgeKeyTypeInterface:: |
constant | |||
EdgeKeyTypeInterface:: |
constant | ID of the JWT authentication method. | ||
EdgeKeyTypeInterface:: |
constant | ID of the OAuth authentication method. | ||
EdgeKeyTypeInterface:: |
constant | The endpoint type for custom. | ||
EdgeKeyTypeInterface:: |
constant | The endpoint type for default. | ||
EdgeKeyTypeInterface:: |
public | constant | Apigee instance on hybrid cloud. | |
EdgeKeyTypeInterface:: |
public | constant | Apigee instance on private cloud. | |
EdgeKeyTypeInterface:: |
public | constant | Apigee instance on public cloud. | |
KeyPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
KeyPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
KeyPluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
8 |
KeyPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
KeyPluginBase:: |
public | function |
Returns the type of plugin. Overrides KeyPluginInterface:: |
|
KeyPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
KeyPluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
KeyTypeAuthenticationMethodInterface:: |
public | function | Gets the authentication method object. | 1 |
KeyTypeInterface:: |
public static | function | Generate a key value of this type using the submitted configuration. | 4 |
KeyTypeInterface:: |
public | function | Allows the Key Type plugin to validate the key value. | 4 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |