- md5
- ca51b1c6ee4707a56e328c02a4c7fb52
- sha1
- 03b4098fa1386ca51050e6ac969f55279332b3fd
- sha256
- ff07a1c0c7e87a9b1c67ec807026d430bac52e233c3d17993bd1097669eb4264
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
<?php
namespace Lcobucci\JWT;
use Closure;
use Lcobucci\JWT\Parsing\Decoder;
use Lcobucci\JWT\Parsing\Encoder;
use Lcobucci\JWT\Signer\Key;
use Lcobucci\JWT\Signer\Key\InMemory;
use Lcobucci\JWT\Signer\None;
use Lcobucci\JWT\Validation\Constraint;
/**
* Configuration container for the JWT Builder and Parser
*
* Serves like a small DI container to simplify the creation and usage
* of the objects.
*/
final class Configuration
{
/** @var Parser */
private $parser;
/** @var Signer */
private $signer;
/** @var Key */
private $signingKey;
/** @var Key */
private $verificationKey;
/** @var Validator */
private $validator;
/** @var Closure(): Builder */
private $builderFactory;
/** @var Constraint[] */
private $validationConstraints = [];
private function __construct(
Signer $signer,
Key $signingKey,
Key $verificationKey,
Encoder $encoder = null,
Decoder $decoder = null
) {
$this->signer = $signer;
$this->signingKey = $signingKey;
$this->verificationKey = $verificationKey;
$this->parser = new Parser($decoder ?: new Decoder());
$this->validator = new Validation\Validator();
$this->builderFactory = static function () use ($encoder) {
return new Builder($encoder ?: new Encoder());
};
}
/** @return self */
public static function forAsymmetricSigner(
Signer $signer,
Key $signingKey,
Key $verificationKey,
Encoder $encoder = null,
Decoder $decoder = null
) {
return new self(
$signer,
$signingKey,
$verificationKey,
$encoder,
$decoder
);
}
/** @return self */
public static function forSymmetricSigner(
Signer $signer,
Key $key,
Encoder $encoder = null,
Decoder $decoder = null
) {
return new self(
$signer,
$key,
$key,
$encoder,
$decoder
);
}
/** @return self */
public static function forUnsecuredSigner(
Encoder $encoder = null,
Decoder $decoder = null
) {
$key = InMemory::plainText('');
return new self(
new None(),
$key,
$key,
$encoder,
$decoder
);
}
/** @param callable(): Builder $builderFactory */
public function setBuilderFactory(callable $builderFactory)
{
if (! $builderFactory instanceof Closure) {
$builderFactory = static function() use ($builderFactory) {
return $builderFactory();
};
}
$this->builderFactory = $builderFactory;
}
/** @return Builder */
public function builder()
{
$factory = $this->builderFactory;
return $factory();
}
/** @return Parser */
public function parser()
{
return $this->parser;
}
public function setParser(Parser $parser)
{
$this->parser = $parser;
}
/** @return Signer */
public function signer()
{
return $this->signer;
}
/** @return Key */
public function signingKey()
{
return $this->signingKey;
}
/** @return Key */
public function verificationKey()
{
return $this->verificationKey;
}
/** @return Validator */
public function validator()
{
return $this->validator;
}
public function setValidator(Validator $validator)
{
$this->validator = $validator;
}
/** @return Constraint[] */
public function validationConstraints()
{
return $this->validationConstraints;
}
public function setValidationConstraints(Constraint ...$validationConstraints)
{
$this->validationConstraints = $validationConstraints;
}
}
The same content is in 75 releases, Joomla 4.2.0-beta3 to 4.4.14. See them all, or every version of this file.