LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
FirebaseClient Class Reference

Class to implement the JWT interface using the Firebase JWT library from https://github.com/firebase/php-jwt. More...

Inheritance diagram for FirebaseClient:
ClientInterface

Public Member Functions

 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 ($pemKey, $signatureMethod, $kid=null)
 Get the public JWKS from a key in PEM 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 Firebase JWT library from https://github.com/firebase/php-jwt.

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 18 of file FirebaseClient.php.

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 323 of file FirebaseClient.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 202 of file FirebaseClient.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 151 of file FirebaseClient.php.

◆ getHeaders()

getHeaders ( )

Get the value of the headers.

Returns
array The value of the headers

Implements ClientInterface.

Definition at line 167 of file FirebaseClient.php.

◆ getJweHeaders()

getJweHeaders ( )

Get the value of the JWE headers.

Returns
array The value of the JWE headers

Implements ClientInterface.

Definition at line 126 of file FirebaseClient.php.

◆ getJWKS()

static getJWKS (   $pemKey,
  $signatureMethod,
  $kid = null 
)
static

Get the public JWKS from a key in PEM format.

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

Implements ClientInterface.

Definition at line 380 of file FirebaseClient.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 177 of file FirebaseClient.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 228 of file FirebaseClient.php.

◆ getPayload()

getPayload ( )

Get the value of the payload.

Returns
array The value of the payload

Implements ClientInterface.

Definition at line 218 of file FirebaseClient.php.

◆ getPublicKey()

static getPublicKey (   $privateKey)
static

Get the public key for a private key.

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

Implements ClientInterface.

Definition at line 359 of file FirebaseClient.php.

◆ getSupportedAlgorithms()

static getSupportedAlgorithms ( )
static

Return an array of supported signature algorithms.

Returns
string[] Array of algorithm names

Implements ClientInterface.

Definition at line 66 of file FirebaseClient.php.

References FirebaseClient\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 189 of file FirebaseClient.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 138 of file FirebaseClient.php.

◆ hasJwt()

hasJwt ( )

Check if a JWT is defined.

Returns
bool True if a JWT is defined

Implements ClientInterface.

Definition at line 76 of file FirebaseClient.php.

◆ isEncrypted()

isEncrypted ( )

Check if a JWT's content is encrypted.

Returns
bool True if a JWT is encrypted

Implements ClientInterface.

Definition at line 86 of file FirebaseClient.php.

◆ 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 99 of file FirebaseClient.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 300 of file FirebaseClient.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 241 of file FirebaseClient.php.

Field Documentation

◆ SUPPORTED_ALGORITHMS

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

Supported signature algorithms.

Definition at line 24 of file FirebaseClient.php.

Referenced by FirebaseClient\getSupportedAlgorithms().


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