diff options
author | Aaron Hedges <aaron@vimeo.com> | 2015-07-01 13:18:06 -0400 |
---|---|---|
committer | Aaron Hedges <aaron@vimeo.com> | 2015-07-01 13:18:06 -0400 |
commit | 3a48a27693c0de928d3adfffc651368d431a573f (patch) | |
tree | b62d0a4a41cb0fbc4f9fc6fe9eefb283f981bd40 | |
parent | e0a75bfb6413f22092c99b70f310ccb2cca3efa5 (diff) | |
download | php-jwt-3a48a27693c0de928d3adfffc651368d431a573f.zip php-jwt-3a48a27693c0de928d3adfffc651368d431a573f.tar.gz php-jwt-3a48a27693c0de928d3adfffc651368d431a573f.tar.bz2 |
Add firespace\jwt namespace
-rw-r--r-- | Exceptions/BeforeValidException.php | 6 | ||||
-rw-r--r-- | Exceptions/ExpiredException.php | 6 | ||||
-rw-r--r-- | Exceptions/SignatureInvalidException.php | 6 | ||||
-rw-r--r-- | composer.json | 6 | ||||
-rw-r--r-- | src/BeforeValidException.php | 7 | ||||
-rw-r--r-- | src/ExpiredException.php | 7 | ||||
-rw-r--r-- | src/JWT.php (renamed from Authentication/JWT.php) | 4 | ||||
-rw-r--r-- | src/SignatureInvalidException.php | 7 | ||||
-rw-r--r-- | tests/JWTTest.php | 15 |
9 files changed, 37 insertions, 27 deletions
diff --git a/Exceptions/BeforeValidException.php b/Exceptions/BeforeValidException.php deleted file mode 100644 index 5a84975..0000000 --- a/Exceptions/BeforeValidException.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -class BeforeValidException extends UnexpectedValueException -{ - -} diff --git a/Exceptions/ExpiredException.php b/Exceptions/ExpiredException.php deleted file mode 100644 index bd80468..0000000 --- a/Exceptions/ExpiredException.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -class ExpiredException extends UnexpectedValueException -{ - -} diff --git a/Exceptions/SignatureInvalidException.php b/Exceptions/SignatureInvalidException.php deleted file mode 100644 index d122232..0000000 --- a/Exceptions/SignatureInvalidException.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -class SignatureInvalidException extends UnexpectedValueException -{ - -} diff --git a/composer.json b/composer.json index 95560af..1a5e93b 100644 --- a/composer.json +++ b/composer.json @@ -16,10 +16,12 @@ ], "license": "BSD-3-Clause", "require": { - "php": ">=5.2.0" + "php": ">=5.3.0" }, "autoload": { - "classmap": ["Authentication/", "Exceptions/"] + "psr-4": { + "Firebase\\JWT\\": "src" + } }, "minimum-stability": "dev" } diff --git a/src/BeforeValidException.php b/src/BeforeValidException.php new file mode 100644 index 0000000..a6ee2f7 --- /dev/null +++ b/src/BeforeValidException.php @@ -0,0 +1,7 @@ +<?php +namespace Firebase\JWT; + +class BeforeValidException extends \UnexpectedValueException +{ + +} diff --git a/src/ExpiredException.php b/src/ExpiredException.php new file mode 100644 index 0000000..3597370 --- /dev/null +++ b/src/ExpiredException.php @@ -0,0 +1,7 @@ +<?php +namespace Firebase\JWT; + +class ExpiredException extends \UnexpectedValueException +{ + +} diff --git a/Authentication/JWT.php b/src/JWT.php index 161424b..855b742 100644 --- a/Authentication/JWT.php +++ b/src/JWT.php @@ -1,5 +1,9 @@ <?php +namespace Firebase\JWT; +use \DomainException; +use \DateTime; + /** * JSON Web Token implementation, based on this spec: * http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06 diff --git a/src/SignatureInvalidException.php b/src/SignatureInvalidException.php new file mode 100644 index 0000000..27332b2 --- /dev/null +++ b/src/SignatureInvalidException.php @@ -0,0 +1,7 @@ +<?php +namespace Firebase\JWT; + +class SignatureInvalidException extends \UnexpectedValueException +{ + +} diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 2aeb201..6c996b2 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -1,4 +1,5 @@ <?php +use \Firebase\JWT\JWT; class JWTTest extends PHPUnit_Framework_TestCase { @@ -37,7 +38,7 @@ class JWTTest extends PHPUnit_Framework_TestCase public function testExpiredToken() { - $this->setExpectedException('ExpiredException'); + $this->setExpectedException('Firebase\JWT\ExpiredException'); $payload = array( "message" => "abc", "exp" => time() - 20); // time in the past @@ -47,7 +48,7 @@ class JWTTest extends PHPUnit_Framework_TestCase public function testBeforeValidTokenWithNbf() { - $this->setExpectedException('BeforeValidException'); + $this->setExpectedException('Firebase\JWT\BeforeValidException'); $payload = array( "message" => "abc", "nbf" => time() + 20); // time in the future @@ -57,7 +58,7 @@ class JWTTest extends PHPUnit_Framework_TestCase public function testBeforeValidTokenWithIat() { - $this->setExpectedException('BeforeValidException'); + $this->setExpectedException('Firebase\JWT\BeforeValidException'); $payload = array( "message" => "abc", "iat" => time() + 20); // time in the future @@ -93,7 +94,7 @@ class JWTTest extends PHPUnit_Framework_TestCase $payload = array( "message" => "abc", "exp" => time() - 70); // time far in the past - $this->setExpectedException('ExpiredException'); + $this->setExpectedException('Firebase\JWT\ExpiredException'); $encoded = JWT::encode($payload, 'my_key'); $decoded = JWT::decode($encoded, 'my_key', array('HS256')); $this->assertEquals($decoded->message, 'abc'); @@ -141,7 +142,7 @@ class JWTTest extends PHPUnit_Framework_TestCase "message" => "abc", "nbf" => time() + 65); // not before too far in future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('BeforeValidException'); + $this->setExpectedException('Firebase\JWT\BeforeValidException'); $decoded = JWT::decode($encoded, 'my_key', array('HS256')); JWT::$leeway = 0; } @@ -165,7 +166,7 @@ class JWTTest extends PHPUnit_Framework_TestCase "message" => "abc", "iat" => time() + 65); // issued too far in future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('BeforeValidException'); + $this->setExpectedException('Firebase\JWT\BeforeValidException'); $decoded = JWT::decode($encoded, 'my_key', array('HS256')); JWT::$leeway = 0; } @@ -176,7 +177,7 @@ class JWTTest extends PHPUnit_Framework_TestCase "message" => "abc", "exp" => time() + 20); // time in the future $encoded = JWT::encode($payload, 'my_key'); - $this->setExpectedException('SignatureInvalidException'); + $this->setExpectedException('Firebase\JWT\SignatureInvalidException'); $decoded = JWT::decode($encoded, 'my_key2', array('HS256')); } |