You are here

interface JwtTranscoderInterface in JSON Web Token Authentication (JWT) 8.0

Same name and namespace in other branches
  1. 8 src/Transcoder/JwtTranscoderInterface.php \Drupal\jwt\Transcoder\JwtTranscoderInterface

Interface JwtTranscoderInterface.

@package Drupal\jwt

Hierarchy

Expanded class hierarchy of JwtTranscoderInterface

All classes that implement JwtTranscoderInterface

1 file declares its use of JwtTranscoderInterface
JwtAuth.php in src/Authentication/Provider/JwtAuth.php

File

src/Transcoder/JwtTranscoderInterface.php, line 12

Namespace

Drupal\jwt\Transcoder
View source
interface JwtTranscoderInterface {

  /**
   * Gets a validated JsonWebToken from an encoded JWT.
   *
   * @param string $jwt
   *   The encoded JWT.
   *
   * @return \Drupal\jwt\JsonWebToken\JsonWebTokenInterface
   *   Validated JWT.
   */
  public function decode($jwt);

  /**
   * Encodes a JsonWebToken.
   *
   * @param \Drupal\jwt\JsonWebToken\JsonWebTokenInterface $jwt
   *   A JWT.
   *
   * @return string
   *   The encoded JWT.
   */
  public function encode(JsonWebTokenInterface $jwt);

  /**
   * Sets the secret that is used for a symmetric algorithm signature.
   *
   * The secret is only used when a symmetric algorithm is selected. Currently
   * the symmetric algorithms supported are:
   *   * HS256
   *   * HS384
   *   * HS512
   * The secret is used for both signature creation and verification.
   *
   * @param string $secret
   *   The secret for the JWT.
   */
  public function setSecret($secret);

  /**
   * Sets the algorithm to be used for the JWT.
   *
   * @param string $algorithm
   *   This can be any of the array keys returned by the getAlgorithmOptions
   *   function.
   *
   * @see getAlgorithmOptions()
   */
  public function setAlgorithm($algorithm);

  /**
   * Sets the private key used to create signatures for an asymmetric algorithm.
   *
   * This key is only used when an asymmetric algorithm is selected. Currently
   * supported asymmetric algorithms are:
   *   * RS256
   *
   * @param string $private_key
   *   A PEM encoded private key.
   * @param bool $derive_public_key
   *   (Optional) Derive the public key from the private key. Defaults to true.
   *
   * @return bool
   *   Function does some validation of the key. Returns TRUE on success.
   */
  public function setPrivateKey($private_key, $derive_public_key = TRUE);

  /**
   * Sets the public key used to verify signatures for an asymmetric algorithm.
   *
   * This key is only used when an asymmetric algorithm is selected. Currently
   * supported asymmetric algorithms are:
   *   * RS256
   *
   * @param string $public_key
   *   A PEM encoded public key.
   *
   * @return mixed
   *   Function does some validation of the key. Returns TRUE on success.
   */
  public function setPublicKey($public_key);

  /**
   * Return the type of algorithm selected.
   *
   * @param string $algorithm
   *   The algorithm.
   *
   * @return string
   *   The algorithm type. Returns NULL if algorithm not found.
   */
  public static function getAlgorithmType($algorithm);

  /**
   * Gets a list of algorithms supported by this transcoder.
   *
   * @return array
   *   An array of options formatted for a select list.
   */
  public static function getAlgorithmOptions();

}

Members

Namesort descending Modifiers Type Description Overrides
JwtTranscoderInterface::decode public function Gets a validated JsonWebToken from an encoded JWT. 1
JwtTranscoderInterface::encode public function Encodes a JsonWebToken. 1
JwtTranscoderInterface::getAlgorithmOptions public static function Gets a list of algorithms supported by this transcoder. 1
JwtTranscoderInterface::getAlgorithmType public static function Return the type of algorithm selected. 1
JwtTranscoderInterface::setAlgorithm public function Sets the algorithm to be used for the JWT. 1
JwtTranscoderInterface::setPrivateKey public function Sets the private key used to create signatures for an asymmetric algorithm. 1
JwtTranscoderInterface::setPublicKey public function Sets the public key used to verify signatures for an asymmetric algorithm. 1
JwtTranscoderInterface::setSecret public function Sets the secret that is used for a symmetric algorithm signature. 1