You are here

public function EdgeKeyTypeBase::getAuthenticationType in Apigee Edge 8

Gets the authentication type.

Parameters

\Drupal\key\KeyInterface $key: The key entity.

Return value

string The Authentication type.

Overrides EdgeKeyTypeInterface::getAuthenticationType

File

src/Plugin/EdgeKeyTypeBase.php, line 52

Class

EdgeKeyTypeBase
Defines a base class for Apigee Edge Key Type plugins.

Namespace

Drupal\apigee_edge\Plugin

Code

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'];
}