HumHub Documentation (unofficial)

JWSBuilder
in package

Table of Contents

Properties

$isPayloadDetached  : bool
$isPayloadEncoded  : null|bool
$payload  : null|string
$signatures  : array<string|int, mixed>
$signatureAlgorithmManager  : AlgorithmManager

Methods

__construct()  : mixed
addSignature()  : JWSBuilder
Adds the information needed to compute the signature.
build()  : JWS
Computes all signatures and return the expected JWS object.
create()  : JWSBuilder
Reset the current data.
getSignatureAlgorithmManager()  : AlgorithmManager
Returns the algorithm manager associated to the builder.
withPayload()  : JWSBuilder
Set the payload.
checkB64AndCriticalHeader()  : void
checkDuplicatedHeaderParameters()  : void
checkIfPayloadIsEncoded()  : bool
findSignatureAlgorithm()  : MacAlgorithm|SignatureAlgorithm

Properties

$isPayloadDetached

protected bool $isPayloadDetached

$isPayloadEncoded

protected null|bool $isPayloadEncoded

$signatures

protected array<string|int, mixed> $signatures = []

Methods

addSignature()

Adds the information needed to compute the signature.

public addSignature(JWK $signatureKey, array<string|int, mixed> $protectedHeader[, array<string|int, mixed> $header = [] ]) : JWSBuilder

This method will return a new JWSBuilder object.

Parameters
$signatureKey : JWK
$protectedHeader : array<string|int, mixed>
$header : array<string|int, mixed> = []
Tags
throws
InvalidArgumentException

if the payload encoding is inconsistent

Return values
JWSBuilder

build()

Computes all signatures and return the expected JWS object.

public build() : JWS
Tags
throws
RuntimeException

if the payload is not set

throws
RuntimeException

if no signature is defined

Return values
JWS

withPayload()

Set the payload.

public withPayload(string $payload[, bool $isPayloadDetached = false ]) : JWSBuilder

This method will return a new JWSBuilder object.

Parameters
$payload : string
$isPayloadDetached : bool = false
Tags
throws
InvalidArgumentException

if the payload is not UTF-8 encoded

Return values
JWSBuilder

checkB64AndCriticalHeader()

private checkB64AndCriticalHeader(array<string|int, mixed> $protectedHeader) : void
Parameters
$protectedHeader : array<string|int, mixed>
Tags
throws
LogicException

if the header parameter "crit" is missing, invalid or does not contain "b64" when "b64" is set

checkDuplicatedHeaderParameters()

private checkDuplicatedHeaderParameters(array<string|int, mixed> $header1, array<string|int, mixed> $header2) : void
Parameters
$header1 : array<string|int, mixed>
$header2 : array<string|int, mixed>
Tags
throws
InvalidArgumentException

if the header contains duplicated entries

checkIfPayloadIsEncoded()

private checkIfPayloadIsEncoded(array<string|int, mixed> $protectedHeader) : bool
Parameters
$protectedHeader : array<string|int, mixed>
Return values
bool

findSignatureAlgorithm()

private findSignatureAlgorithm(JWK $key, array<string|int, mixed> $protectedHeader, array<string|int, mixed> $header) : MacAlgorithm|SignatureAlgorithm
Parameters
$key : JWK
$protectedHeader : array<string|int, mixed>
$header : array<string|int, mixed>
Tags
throws
InvalidArgumentException

if the header parameter "alg" is missing or the algorithm is not allowed/not supported

Return values
MacAlgorithm|SignatureAlgorithm

        
On this page

Search results