diff options
-rw-r--r-- | Authentication/JWT.php | 2 | ||||
-rw-r--r-- | Exceptions/BeforeValidException.php | 6 | ||||
-rw-r--r-- | Exceptions/ExpiredException.php | 2 | ||||
-rw-r--r-- | Exceptions/SignatureInvalidException.php | 2 | ||||
-rw-r--r-- | Exceptions/TooEarlyException.php | 6 | ||||
-rw-r--r-- | tests/JWTTest.php | 6 |
6 files changed, 12 insertions, 12 deletions
diff --git a/Authentication/JWT.php b/Authentication/JWT.php index 78fe7d2..76c33bb 100644 --- a/Authentication/JWT.php +++ b/Authentication/JWT.php @@ -74,7 +74,7 @@ class JWT // Check if the nbf if it is defined. if (isset($payload->nbf) && $payload->nbf > time()) { - throw new TooEarlyException( + throw new BeforeValidException( 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf) ); } diff --git a/Exceptions/BeforeValidException.php b/Exceptions/BeforeValidException.php new file mode 100644 index 0000000..5a84975 --- /dev/null +++ b/Exceptions/BeforeValidException.php @@ -0,0 +1,6 @@ +<?php + +class BeforeValidException extends UnexpectedValueException +{ + +} diff --git a/Exceptions/ExpiredException.php b/Exceptions/ExpiredException.php index 74b0d57..bd80468 100644 --- a/Exceptions/ExpiredException.php +++ b/Exceptions/ExpiredException.php @@ -3,4 +3,4 @@ class ExpiredException extends UnexpectedValueException { -}
\ No newline at end of file +} diff --git a/Exceptions/SignatureInvalidException.php b/Exceptions/SignatureInvalidException.php index 640bb49..d122232 100644 --- a/Exceptions/SignatureInvalidException.php +++ b/Exceptions/SignatureInvalidException.php @@ -3,4 +3,4 @@ class SignatureInvalidException extends UnexpectedValueException { -}
\ No newline at end of file +} diff --git a/Exceptions/TooEarlyException.php b/Exceptions/TooEarlyException.php deleted file mode 100644 index 989a416..0000000 --- a/Exceptions/TooEarlyException.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -class TooEarlyException extends UnexpectedValueException -{ - -}
\ No newline at end of file diff --git a/tests/JWTTest.php b/tests/JWTTest.php index d9abe4e..5a76ed4 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -45,12 +45,12 @@ class JWTTest extends PHPUnit_Framework_TestCase JWT::decode($encoded, 'my_key'); } - public function testTooEarlyToken() + public function testBeforeValidToken() { - $this->setExpectedException('TooEarlyException'); + $this->setExpectedException('BeforeValidException'); $payload = array( "message" => "abc", - "nbf" => time() + 20); // time in the past + "nbf" => time() + 20); // time in the future $encoded = JWT::encode($payload, 'my_key'); JWT::decode($encoded, 'my_key'); } |