Documentation

JWT
in package

Provides functions to create and parse JWS and JWE

Table of Contents

decryptJWE()  : object
descrypts the token and return the embedded JWS
getCertificateJWK()  : object
get a public cert JWK object from a public cert PEM file
getJWKFromJSON()  : object
get a JWK object from JSON string
getJWKSFromValues()  : object
get a public cert JWK object from an object
getJWSPayload()  : object
get the payload of the JWS token
getKeyJWK()  : object
get a private key JWK object from a private key PEM file
isSignatureVerified()  : bool
verify the signature of the JWS token
isValid()  : bool
verify if token is not expired and other stuff.
makeJWS()  : string
create a signed JWT (JWS) from given values
getAlgManager()  : object
getAlgManager
getContentEncAlgClassMap()  : object
getContentEncAlgClassMap
getContentEncAlgManager()  : object
getContentEncAlgManager
getKeyEncAlgClassMap()  : object
getKeyEncAlgClassMap
getKeyEncAlgManager()  : object
getKeyEncAlgManager
getSigAlgClassMap()  : object
getSigAlgClassMap
getSigAlgManager()  : object
getSigAlgManager

Methods

decryptJWE()

descrypts the token and return the embedded JWS

public static decryptJWE(string $token, string $file) : object
Parameters
$token : string

the JWE token to be decrypted

$file : string

path to PEM file of the private key to wich decrypt the JWE

Tags
throws
Exception
Return values
object

the decrypted JWS object inside the JWE

getCertificateJWK()

get a public cert JWK object from a public cert PEM file

public static getCertificateJWK(string $file[, string $use = 'sig' ]) : object
Parameters
$file : string

path of the public cert PEM file

$use : string = 'sig'

the use of certificate [sig|enc]

Tags
throws
Exception
Return values
object

JWK object

getJWKFromJSON()

get a JWK object from JSON string

public static getJWKFromJSON(string $json) : object
Parameters
$json : string

JSON string of the JWK

Tags
throws
Exception
Return values
object

JWK object

getJWKSFromValues()

get a public cert JWK object from an object

public static getJWKSFromValues(object $values) : object
Parameters
$values : object
Tags
throws
Exception
Return values
object

JWK object

getJWSPayload()

get the payload of the JWS token

public static getJWSPayload(string $token) : object
Parameters
$token : string

JWS token

Tags
throws
Exception
Return values
object

payload string of the JWS token

getKeyJWK()

get a private key JWK object from a private key PEM file

public static getKeyJWK(string $file) : object
Parameters
$file : string

path of the private key PEM file

Tags
throws
Exception
Return values
object

JWK object

isSignatureVerified()

verify the signature of the JWS token

public static isSignatureVerified(string $token, object $jwks_obj) : bool
Parameters
$token : string

JWS token

$jwks_obj : object
Tags
throws
Exception
Return values
bool

true if the signature is verified

isValid()

verify if token is not expired and other stuff.

public static isValid(string $token) : bool

..

Parameters
$token : string

JWS token

Tags
throws
Exception
Return values
bool

true if the the token is valid

makeJWS()

create a signed JWT (JWS) from given values

public static makeJWS(array<string|int, mixed> $header, array<string|int, mixed> $payload, object $jwk) : string
Parameters
$header : array<string|int, mixed>

associative array for header

$payload : array<string|int, mixed>

associative array for payload

$jwk : object

JWK object to use for signing JWS

Tags
throws
Exception
Return values
string

of the JWS token

getAlgManager()

getAlgManager

private static getAlgManager(object $algClassMap[, string $alg = null ]) : object

if $alg is set to an algorithm string, return manager for that, else $alg is null, return manager for all supported algorithms

Parameters
$algClassMap : object

class map of available algorithms

$alg : string = null

algorithm to use or null

Tags
throws
Exception
Return values
object

getContentEncAlgClassMap()

getContentEncAlgClassMap

private static getContentEncAlgClassMap() : object
Tags
throws
Exception
Return values
object

getContentEncAlgManager()

getContentEncAlgManager

private static getContentEncAlgManager([string $alg = null ]) : object
Parameters
$alg : string = null

algorithm to use or null

Tags
throws
Exception
Return values
object

getKeyEncAlgClassMap()

getKeyEncAlgClassMap

private static getKeyEncAlgClassMap() : object
Tags
throws
Exception
Return values
object

getKeyEncAlgManager()

getKeyEncAlgManager

private static getKeyEncAlgManager([string $alg = null ]) : object
Parameters
$alg : string = null

algorithm to use or null

Tags
throws
Exception
Return values
object

getSigAlgClassMap()

getSigAlgClassMap

private static getSigAlgClassMap() : object
Tags
throws
Exception
Return values
object

getSigAlgManager()

getSigAlgManager

private static getSigAlgManager([string $alg = null ]) : object
Parameters
$alg : string = null

algorithm to use or null

Tags
throws
Exception
Return values
object

Search results