jwt : pass the not needed method to private
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5284 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -17,7 +17,8 @@ class test_jwt extends PHPUnit_Framework_TestCase
|
|||||||
public function test_sign_1 ()
|
public function test_sign_1 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new jwt ();
|
||||||
$res = $jwt->sign ("TEXT TO SIGN", "KEY TO USE", "HS384");
|
$res = $this->invokeMethod ($jwt, "sign", "TEXT TO SIGN", "KEY TO USE",
|
||||||
|
"HS384");
|
||||||
$this->assertSame (
|
$this->assertSame (
|
||||||
"cQB+yNVvIER+Nw53MZfU/PGPAJlkKUnjMikmXAwVB9tcaINQH5a88LCDi0PmI5mZ",
|
"cQB+yNVvIER+Nw53MZfU/PGPAJlkKUnjMikmXAwVB9tcaINQH5a88LCDi0PmI5mZ",
|
||||||
base64_encode ($res));
|
base64_encode ($res));
|
||||||
@@ -26,7 +27,8 @@ class test_jwt extends PHPUnit_Framework_TestCase
|
|||||||
public function test_sign_2 ()
|
public function test_sign_2 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new jwt ();
|
||||||
$res = $jwt->sign ("text to sign", "KEY TO USE", "HS384");
|
$res = $this->invokeMethod ($jwt, "sign", "text to sign", "KEY TO USE",
|
||||||
|
"HS384");
|
||||||
$this->assertSame (
|
$this->assertSame (
|
||||||
"FLSkslsUGIpkP3xsJx5ephnCtH7K4jZSNxRxxCn3m7fsPK/MMfEIVr+h3heap80x",
|
"FLSkslsUGIpkP3xsJx5ephnCtH7K4jZSNxRxxCn3m7fsPK/MMfEIVr+h3heap80x",
|
||||||
base64_encode ($res));
|
base64_encode ($res));
|
||||||
@@ -35,7 +37,8 @@ class test_jwt extends PHPUnit_Framework_TestCase
|
|||||||
public function test_sign_3 ()
|
public function test_sign_3 ()
|
||||||
{
|
{
|
||||||
$jwt = new jwt ();
|
$jwt = new jwt ();
|
||||||
$res = $jwt->sign ("text to sign", "key to use", "HS384");
|
$res = $this->invokeMethod ($jwt, "sign", "text to sign", "key to use",
|
||||||
|
"HS384");
|
||||||
$this->assertSame (
|
$this->assertSame (
|
||||||
"lBLlXb5Xo3z9zoEuO0obZdhqGNUKr8DaEsL991TpSPWIdB2067ckR+AJ1FW6in2B",
|
"lBLlXb5Xo3z9zoEuO0obZdhqGNUKr8DaEsL991TpSPWIdB2067ckR+AJ1FW6in2B",
|
||||||
base64_encode ($res));
|
base64_encode ($res));
|
||||||
|
|||||||
4
jwt.php
4
jwt.php
@@ -104,7 +104,7 @@ class jwt
|
|||||||
* @param string $alg The algorithm to use to sign the input
|
* @param string $alg The algorithm to use to sign the input
|
||||||
* @return boolean Return true if the input signed is valid
|
* @return boolean Return true if the input signed is valid
|
||||||
*/
|
*/
|
||||||
public function verify ($input, $sign, $key, $alg)
|
private function verify ($input, $sign, $key, $alg)
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
$signature = $this->sign ($input, $key, $alg);
|
$signature = $this->sign ($input, $key, $alg);
|
||||||
@@ -137,7 +137,7 @@ class jwt
|
|||||||
* @param string $alg The algorithm to use to sign
|
* @param string $alg The algorithm to use to sign
|
||||||
* @return string The signed string in binary
|
* @return string The signed string in binary
|
||||||
*/
|
*/
|
||||||
public function sign ($input, $key, $alg)
|
private function sign ($input, $key, $alg)
|
||||||
// {{{
|
// {{{
|
||||||
{
|
{
|
||||||
if (! key_exists ($alg, $this->supportedAlgs))
|
if (! key_exists ($alg, $this->supportedAlgs))
|
||||||
|
|||||||
Reference in New Issue
Block a user