LTI Integration Library 5.0.0-rc2
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
SpomkyLabsClient Class Reference

Class to implement the JWT interface using the Spomky-Labs JWT library from https://github.com/Spomky-Labs/jose. More...

Inheritance diagram for SpomkyLabsClient:
ClientInterface

Public Member Functions

 __construct ()
 Class constructor.
 
bool hasJwt ()
 Check if a JWT is defined.
 
bool isEncrypted ()
 Check if a JWT's content is encrypted.
 
bool load ($jwtString, $privateKey=null)
 Load a JWT from a string.
 
array getJweHeaders ()
 Get the value of the JWE headers.
 
bool hasHeader ($name)
 Check whether a JWT has a header with the specified name.
 
string getHeader ($name, $defaultValue=null)
 Get the value of the header with the specified name.
 
array getHeaders ()
 Get the value of the headers.
 
bool hasClaim ($name)
 Check whether a JWT has a claim with the specified name.
 
string array object getClaim ($name, $defaultValue=null)
 Get the value of the claim with the specified name.
 
array getPayload ()
 Get the value of the payload.
 
bool verify ($publicKey, $jku=null)
 Verify the signature of the JWT.
 
bool hasJwt ()
 Check if a JWT is defined.
 
bool isEncrypted ()
 Check if a JWT's content is encrypted.
 
bool load ($jwtString, $privateKey=null)
 Load a JWT from a string.
 
array getJweHeaders ()
 Get the value of the JWE headers.
 
bool hasHeader ($name)
 Check whether a JWT has a header with the specified name.
 
string getHeader ($name, $defaultValue=null)
 Get the value of the header with the specified name.
 
array getHeaders ()
 Get the value of the headers.
 
bool hasClaim ($name)
 Check whether a JWT has a claim with the specified name.
 
string array object getClaim ($name, $defaultValue=null)
 Get the value of the claim with the specified name.
 
array getPayload ()
 Get the value of the payload.
 
bool verify ($publicKey, $jku=null)
 Verify the signature of the JWT.
 

Static Public Member Functions

static string[] getSupportedAlgorithms ()
 Return an array of supported signature algorithms.
 
static array getLastHeaders ()
 Get the value of the headers for the last signed JWT (before any encryption).
 
static array getLastPayload ()
 Get the value of the payload for the last signed JWT (before any encryption).
 
static string sign ($payload, $signatureMethod, $privateKey, $kid=null, $jku=null, $encryptionMethod=null, $publicKey=null)
 Sign the JWT.
 
static string null generateKey ($signatureMethod='RS256')
 Generate a new private key in PEM format.
 
static string getPublicKey ($privateKey)
 Get the public key for a private key.
 
static array getJWKS ($key, $signatureMethod, $kid)
 Get the public JWKS from a key in PEM or JWK format.
 
static string[] getSupportedAlgorithms ()
 Return an array of supported signature algorithms.
 
static array getLastHeaders ()
 Get the value of the headers for the last signed JWT (before any encryption).
 
static array getLastPayload ()
 Get the value of the payload for the last signed JWT (before any encryption).
 
static string sign ($payload, $signatureMethod, $privateKey, $kid=null, $jku=null, $encryptionMethod=null, $publicKey=null)
 Sign the JWT.
 
static string null generateKey ($signatureMethod='RS256')
 Generate a new private key in PEM format.
 
static string getPublicKey ($privateKey)
 Get the public key for a private key.
 
static array getJWKS ($pemKey, $signatureMethod, $kid)
 Get the public JWKS from a key in PEM format.
 

Public Attributes

const SUPPORTED_ALGORITHMS = array('RS256', 'RS384', 'RS512')
 Supported signature algorithms.
 

Detailed Description

Class to implement the JWT interface using the Spomky-Labs JWT library from https://github.com/Spomky-Labs/jose.

Deprecated:
Use WebTokenClient instead
See also
WebTokenClient
Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
Licence: GNU Lesser General Public License, version 3 (<http://www.gnu.org/licenses/lgpl.html>)

Member Function Documentation

◆ generateKey()

static string null generateKey (   $signatureMethod = 'RS256')
static

Generate a new private key in PEM format.

Parameters
string$signatureMethodSignature method
Returns
string|null Key in PEM format

Implements ClientInterface.

◆ getClaim()

string array object getClaim (   $name,
  $defaultValue = null 
)

Get the value of the claim with the specified name.

Parameters
string$nameClaim name
string$defaultValueDefault value
Returns
string|array|object The value of the claim with the specified name, or the default value if it does not exist

Implements ClientInterface.

◆ getHeader()

string getHeader (   $name,
  $defaultValue = null 
)

Get the value of the header with the specified name.

Parameters
string$nameHeader name
string$defaultValueDefault value
Returns
string The value of the header with the specified name, or the default value if it does not exist

Implements ClientInterface.

◆ getHeaders()

array getHeaders ( )

Get the value of the headers.

Returns
array The value of the headers

Implements ClientInterface.

◆ getJweHeaders()

array getJweHeaders ( )

Get the value of the JWE headers.

Returns
array The value of the JWE headers

Implements ClientInterface.

References SpomkyLabsClient\isEncrypted().

◆ getJWKS()

static array getJWKS (   $key,
  $signatureMethod,
  $kid 
)
static

Get the public JWKS from a key in PEM or JWK format.

Parameters
string$keyPrivate or public key in PEM or JWK format
string$signatureMethodSignature method
string$kidKey ID (optional)
Returns
array JWKS keys

Implements ClientInterface.

◆ getLastHeaders()

static array getLastHeaders ( )
static

Get the value of the headers for the last signed JWT (before any encryption).

Returns
array The value of the headers

Implements ClientInterface.

◆ getLastPayload()

static array getLastPayload ( )
static

Get the value of the payload for the last signed JWT (before any encryption).

Returns
array The value of the payload

Implements ClientInterface.

◆ getPayload()

array getPayload ( )

Get the value of the payload.

Returns
array The value of the payload

Implements ClientInterface.

◆ getPublicKey()

static string getPublicKey (   $privateKey)
static

Get the public key for a private key.

Parameters
string$privateKeyPrivate key in PEM format
Returns
string Public key in PEM format

Implements ClientInterface.

◆ getSupportedAlgorithms()

static string[] getSupportedAlgorithms ( )
static

Return an array of supported signature algorithms.

Returns
string[] Array of algorithm names

Implements ClientInterface.

References SpomkyLabsClient\SUPPORTED_ALGORITHMS.

◆ hasClaim()

bool hasClaim (   $name)

Check whether a JWT has a claim with the specified name.

Parameters
string$nameClaim name
Returns
bool True if the JWT has a claim of the specified name

Implements ClientInterface.

◆ hasHeader()

bool hasHeader (   $name)

Check whether a JWT has a header with the specified name.

Parameters
string$nameHeader name
Returns
bool True if the JWT has a header of the specified name

Implements ClientInterface.

◆ hasJwt()

bool hasJwt ( )

Check if a JWT is defined.

Returns
bool True if a JWT is defined

Implements ClientInterface.

◆ isEncrypted()

bool isEncrypted ( )

Check if a JWT's content is encrypted.

Returns
bool True if a JWT is encrypted

Implements ClientInterface.

Referenced by SpomkyLabsClient\getJweHeaders().

◆ load()

bool load (   $jwtString,
  $privateKey = null 
)

Load a JWT from a string.

Parameters
string$jwtStringJWT string
string$privateKeyPrivate key in PEM format for decrypting encrypted tokens (optional)
Returns
bool True if the JWT was successfully loaded

Implements ClientInterface.

◆ sign()

static string sign (   $payload,
  $signatureMethod,
  $privateKey,
  $kid = null,
  $jku = null,
  $encryptionMethod = null,
  $publicKey = null 
)
static

Sign the JWT.

Parameters
array$payloadPayload
string$signatureMethodSignature method
string$privateKeyPrivate key in PEM format
string$kidKey ID (optional)
string$jkuJSON Web Key URL (optional)
string$encryptionMethodEncryption method (optional)
string$publicKeyPublic key of recipient for content encryption (optional)
Returns
string Signed JWT

Implements ClientInterface.

◆ verify()

bool verify (   $publicKey,
  $jku = null 
)

Verify the signature of the JWT.

Parameters
string$publicKeyPublic key of issuer
string$jkuJSON Web Key URL of issuer (optional)
Returns
bool True if the JWT has a valid signature

Implements ClientInterface.


The documentation for this class was generated from the following file: