HumHub Documentation (unofficial)

JWKSet
in package
implements Countable, IteratorAggregate, JsonSerializable

Table of Contents

Interfaces

Countable
IteratorAggregate
JsonSerializable

Properties

$keys  : array<string|int, mixed>

Methods

__construct()  : mixed
all()  : array<string|int, JWK>
Returns an array of keys stored in the key set.
count()  : int
Returns the number of keys in the key set.
createFromJson()  : JWKSet
Creates a JWKSet object using the given Json string.
createFromKeyData()  : JWKSet
Creates a JWKSet object using the given values.
get()  : JWK
Returns the key with the given index. Throws an exception if the index is not present in the key store.
has()  : bool
Returns true if the key set contains a key with the given index.
jsonSerialize()  : array<string|int, mixed>
Returns the values to be serialized.
selectKey()  : JWK|null
Try to find a key that fits on the selected requirements.
with()  : JWKSet
Add key to store in the key set.
without()  : JWKSet
Remove key from the key set.
canKeyBeUsedFor()  : bool|int
canKeyBeUsedWithAlgorithm()  : bool|int
convertKeyOpsToKeyUse()  : string
doesKeySatisfyRestrictions()  : bool

Properties

$keys

private array<string|int, mixed> $keys = []

Methods

__construct()

public __construct(array<string|int, JWK$keys) : mixed
Parameters
$keys : array<string|int, JWK>
Tags
throws
InvalidArgumentException

if the list is invalid

all()

Returns an array of keys stored in the key set.

public all() : array<string|int, JWK>
Return values
array<string|int, JWK>

count()

Returns the number of keys in the key set.

public count([int $mode = COUNT_NORMAL ]) : int
Parameters
$mode : int = COUNT_NORMAL
Return values
int

createFromJson()

Creates a JWKSet object using the given Json string.

public static createFromJson(string $json) : JWKSet
Parameters
$json : string
Tags
throws
InvalidArgumentException

if the data is not valid

Return values
JWKSet

createFromKeyData()

Creates a JWKSet object using the given values.

public static createFromKeyData(array<string|int, mixed> $data) : JWKSet
Parameters
$data : array<string|int, mixed>
Tags
throws
InvalidArgumentException

if the keyset is not valid

Return values
JWKSet

get()

Returns the key with the given index. Throws an exception if the index is not present in the key store.

public get(int|string $index) : JWK
Parameters
$index : int|string
Tags
throws
InvalidArgumentException

if the index is not defined

Return values
JWK

has()

Returns true if the key set contains a key with the given index.

public has(int|string $index) : bool
Parameters
$index : int|string
Return values
bool

jsonSerialize()

Returns the values to be serialized.

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

selectKey()

Try to find a key that fits on the selected requirements.

public selectKey(string $type[, null|Algorithm $algorithm = null ][, array<string|int, mixed> $restrictions = [] ]) : JWK|null

Returns null if not found.

Parameters
$type : string

Must be 'sig' (signature) or 'enc' (encryption)

$algorithm : null|Algorithm = null

Specifies the algorithm to be used

$restrictions : array<string|int, mixed> = []

More restrictions such as 'kid' or 'kty'

Tags
throws
InvalidArgumentException

if the key type is not valid (must be "sig" or "enc")

Return values
JWK|null

with()

Add key to store in the key set.

public with(JWK $jwk) : JWKSet

This method is immutable and will return a new object.

Parameters
$jwk : JWK
Return values
JWKSet

without()

Remove key from the key set.

public without(int|string $key) : JWKSet

This method is immutable and will return a new object.

Parameters
$key : int|string

Key to remove from the key set

Return values
JWKSet

canKeyBeUsedFor()

private canKeyBeUsedFor(string $type, JWK $key) : bool|int
Parameters
$type : string
$key : JWK
Tags
throws
InvalidArgumentException

if the key does not fulfill with the "key_ops" constraint

Return values
bool|int

canKeyBeUsedWithAlgorithm()

private canKeyBeUsedWithAlgorithm(Algorithm|null $algorithm, JWK $key) : bool|int
Parameters
$algorithm : Algorithm|null
$key : JWK
Return values
bool|int

convertKeyOpsToKeyUse()

private static convertKeyOpsToKeyUse(array<string|int, mixed> $key_ops) : string
Parameters
$key_ops : array<string|int, mixed>
Tags
throws
InvalidArgumentException

if the key operation is not supported

Return values
string

doesKeySatisfyRestrictions()

private doesKeySatisfyRestrictions(array<string|int, mixed> $restrictions, JWK $key) : bool
Parameters
$restrictions : array<string|int, mixed>
$key : JWK
Return values
bool

        
On this page

Search results