LTI Integration Library 4.10.3
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.
 
 hasJwt ()
 Check if a JWT is defined.
 
 isEncrypted ()
 Check if a JWT's content is encrypted.
 
 load ($jwtString, $privateKey=null)
 Load a JWT from a string.
 
 getJweHeaders ()
 Get the value of the JWE headers.
 
 hasHeader ($name)
 Check whether a JWT has a header with the specified name.
 
 getHeader ($name, $defaultValue=null)
 Get the value of the header with the specified name.
 
 getHeaders ()
 Get the value of the headers.
 
 hasClaim ($name)
 Check whether a JWT has a claim with the specified name.
 
 getClaim ($name, $defaultValue=null)
 Get the value of the claim with the specified name.
 
 getPayload ()
 Get the value of the payload.
 
 verify ($publicKey, $jku=null)
 Verify the signature of the JWT.
 
 hasJwt ()
 Check if a JWT is defined.
 
 isEncrypted ()
 Check if a JWT's content is encrypted.
 
 load ($jwtString, $privateKey=null)
 Load a JWT from a string.
 
 getJweHeaders ()
 Get the value of the JWE headers.
 
 hasHeader ($name)
 Check whether a JWT has a header with the specified name.
 
 getHeader ($name, $defaultValue=null)
 Get the value of the header with the specified name.
 
 getHeaders ()
 Get the value of the headers.
 
 hasClaim ($name)
 Check whether a JWT has a claim with the specified name.
 
 getClaim ($name, $defaultValue=null)
 Get the value of the claim with the specified name.
 
 getPayload ()
 Get the value of the payload.
 
 verify ($publicKey, $jku=null)
 Verify the signature of the JWT.
 

Static Public Member Functions

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

Data Fields

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>)

Definition at line 29 of file SpomkyLabsClient.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Class constructor.

Definition at line 75 of file SpomkyLabsClient.php.

References Util\logDebug().

Member Function Documentation

◆ generateKey()

static 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.

Definition at line 390 of file SpomkyLabsClient.php.

◆ getClaim()

getClaim (   $name,
  $defaultValue = null 
)

Get the value of the claim with the specified name.

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

Implements ClientInterface.

Definition at line 237 of file SpomkyLabsClient.php.

◆ getHeader()

getHeader (   $name,
  $defaultValue = null 
)

Get the value of the header with the specified name.

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

Implements ClientInterface.

Definition at line 181 of file SpomkyLabsClient.php.

◆ getHeaders()

getHeaders ( )

Get the value of the headers.

Returns
array The value of the headers

Implements ClientInterface.

Definition at line 197 of file SpomkyLabsClient.php.

◆ getJweHeaders()

getJweHeaders ( )

Get the value of the JWE headers.

Returns
array The value of the JWE headers

Implements ClientInterface.

Definition at line 144 of file SpomkyLabsClient.php.

References SpomkyLabsClient\isEncrypted().

◆ getJWKS()

static 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 | null$kidKey ID (optional)
Returns
array JWKS keys

Implements ClientInterface.

Definition at line 448 of file SpomkyLabsClient.php.

◆ getLastHeaders()

static 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.

Definition at line 212 of file SpomkyLabsClient.php.

◆ getLastPayload()

static 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.

Definition at line 263 of file SpomkyLabsClient.php.

◆ getPayload()

getPayload ( )

Get the value of the payload.

Returns
array The value of the payload

Implements ClientInterface.

Definition at line 253 of file SpomkyLabsClient.php.

◆ getPublicKey()

static 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.

Definition at line 424 of file SpomkyLabsClient.php.

◆ getSupportedAlgorithms()

static getSupportedAlgorithms ( )
static

Return an array of supported signature algorithms.

Returns
string[] Array of algorithm names

Implements ClientInterface.

Definition at line 86 of file SpomkyLabsClient.php.

References SpomkyLabsClient\SUPPORTED_ALGORITHMS.

◆ hasClaim()

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.

Definition at line 224 of file SpomkyLabsClient.php.

◆ hasHeader()

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.

Definition at line 162 of file SpomkyLabsClient.php.

◆ hasJwt()

hasJwt ( )

Check if a JWT is defined.

Returns
bool True if a JWT is defined

Implements ClientInterface.

Definition at line 96 of file SpomkyLabsClient.php.

◆ isEncrypted()

isEncrypted ( )

Check if a JWT's content is encrypted.

Returns
bool True if a JWT is encrypted

Implements ClientInterface.

Definition at line 106 of file SpomkyLabsClient.php.

Referenced by SpomkyLabsClient\getJweHeaders().

◆ load()

load (   $jwtString,
  $privateKey = null 
)

Load a JWT from a string.

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

Implements ClientInterface.

Definition at line 119 of file SpomkyLabsClient.php.

References Util\jsonDecode().

◆ sign()

static 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 | null$kidKey ID (optional)
string | null$jkuJSON Web Key URL (optional)
string | null$encryptionMethodEncryption method (optional)
string | null$publicKeyPublic key of recipient for content encryption (optional)
Returns
string Signed JWT
Exceptions
Exception

Implements ClientInterface.

Definition at line 338 of file SpomkyLabsClient.php.

◆ verify()

verify (   $publicKey,
  $jku = null 
)

Verify the signature of the JWT.

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

Implements ClientInterface.

Definition at line 276 of file SpomkyLabsClient.php.

Field Documentation

◆ SUPPORTED_ALGORITHMS

const SUPPORTED_ALGORITHMS = array('RS256', 'RS384', 'RS512')

Supported signature algorithms.

Definition at line 35 of file SpomkyLabsClient.php.

Referenced by SpomkyLabsClient\getSupportedAlgorithms().


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