You are here

class JwtDecodeException in JSON Web Token Authentication (JWT) 8.0

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

Class JwtDecodeException.

@package Drupal\jwt\Trancoder

Hierarchy

Expanded class hierarchy of JwtDecodeException

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

File

src/Transcoder/JwtDecodeException.php, line 14

Namespace

Drupal\jwt\Transcoder
View source
class JwtDecodeException extends \Exception {
  const DOMAIN = 1;
  const UNEXPECTED_VALUE = 2;
  const SIGNATURE_INVALID = 3;
  const BEFORE_VALID = 4;
  const EXPIRED = 5;
  const UNKNOWN = 6;

  /**
   * Construct a new decode exception from a php-jwt exception.
   *
   * @param \Exception $e
   *   The exception to decode.
   *
   * @return JwtDecodeException
   *   The decode exception.
   */
  public static function newFromException(\Exception $e) {
    switch ($e) {
      case $e instanceof SignatureInvalidException:
        return new static($e
          ->getMessage(), self::SIGNATURE_INVALID, $e);
      case $e instanceof BeforeValidException:
        return new static($e
          ->getMessage(), self::BEFORE_VALID, $e);
      case $e instanceof ExpiredException:
        return new static($e
          ->getMessage(), self::EXPIRED, $e);
      case $e instanceof \Exception:
        return new static('Internal Server Error', self::UNKNOWN, $e);
      default:
        return new static('Internal Server Error', self::UNKNOWN, $e);
    }
  }

}

Members