Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
616 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: php | ||
|
||
php: | ||
- "7.2" | ||
- "7.1" | ||
- "7.0" | ||
- "5.6" | ||
|
||
install: | ||
- composer install | ||
|
||
script: | ||
- vendor/bin/phpunit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
To change this license header, choose License Headers in Project Properties. | ||
To change this template file, choose Tools | Templates | ||
and open the template in the editor. | ||
--> | ||
|
||
<!-- see http://www.phpunit.de/wiki/Documentation --> | ||
<phpunit bootstrap="./vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false"> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>./src</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace ByJG\Util; | ||
|
||
interface JwtKeyInterface | ||
{ | ||
public function getPublicKey(); | ||
public function getPrivateKey(); | ||
public function getAlghoritm(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace ByJG\Util; | ||
|
||
class JwtKeySecret implements JwtKeyInterface | ||
{ | ||
|
||
protected $key; | ||
|
||
/** | ||
* JwtKeySecret constructor. | ||
* @param $key | ||
* @param bool $decode | ||
*/ | ||
public function __construct($key, $decode = true) | ||
{ | ||
$this->key = ($decode ? base64_decode($key) : $key); | ||
} | ||
|
||
/** | ||
* @param $key | ||
* @param bool $decode | ||
* @return JwtKeySecret | ||
*/ | ||
public static function getInstance($key, $decode = true) | ||
{ | ||
return new JwtKeySecret($key, $decode); | ||
} | ||
|
||
public function getPublicKey() | ||
{ | ||
return $this->key; | ||
} | ||
|
||
public function getPrivateKey() | ||
{ | ||
return $this->key; | ||
} | ||
|
||
public function getAlghoritm() | ||
{ | ||
return 'HS512'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace ByJG\Util; | ||
|
||
class JwtRsaKey implements JwtKeyInterface | ||
{ | ||
protected $private; | ||
protected $public; | ||
|
||
/** | ||
* JwtRsaKey constructor. | ||
* @param $private | ||
* @param $public | ||
*/ | ||
public function __construct($private, $public) | ||
{ | ||
$this->private = $private; | ||
$this->public = $public; | ||
} | ||
|
||
/** | ||
* @param $private | ||
* @param $public | ||
* @return JwtRsaKey | ||
*/ | ||
public static function getInstance($private, $public) | ||
{ | ||
return new JwtRsaKey($private, $public); | ||
} | ||
|
||
public function getPublicKey() | ||
{ | ||
return $this->public; | ||
} | ||
|
||
public function getPrivateKey() | ||
{ | ||
return $this->private; | ||
} | ||
|
||
public function getAlghoritm() | ||
{ | ||
return 'RS512'; | ||
} | ||
} |
Oops, something went wrong.