-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
363 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\OpenID\Claims; | ||
|
||
class GenericClaim | ||
{ | ||
public function __construct( | ||
protected readonly string $name, | ||
protected readonly mixed $value, | ||
) { | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function getValue(): mixed | ||
{ | ||
return $this->value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\OpenID\Exceptions; | ||
|
||
class TrustMarkDelegationException extends JwsException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\OpenID\Factories; | ||
|
||
use SimpleSAML\OpenID\Claims\GenericClaim; | ||
use SimpleSAML\OpenID\Helpers; | ||
|
||
class ClaimFactory | ||
{ | ||
public function __construct( | ||
protected readonly Helpers $helpers, | ||
) { | ||
} | ||
|
||
/** | ||
* @throws \SimpleSAML\OpenID\Exceptions\InvalidValueException | ||
*/ | ||
public function buildGeneric(mixed $key, mixed $value): GenericClaim | ||
{ | ||
return new GenericClaim( | ||
$this->helpers->type()->ensureString($key, 'ClaimKey'), | ||
$value, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\OpenID\Federation\EntityStatement; | ||
|
||
class TrustMarkOwnerBag | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\OpenID\Federation\EntityStatement; | ||
|
||
class TrustMarkOwnerClaim | ||
{ | ||
public function __construct( | ||
protected readonly string $subject, | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\OpenID\Federation\Factories; | ||
|
||
use SimpleSAML\OpenID\Federation\TrustMarkDelegation; | ||
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory; | ||
|
||
class TrustMarkDelegationFactory extends ParsedJwsFactory | ||
{ | ||
public function fromToken(string $token): TrustMarkDelegation | ||
{ | ||
return new TrustMarkDelegation( | ||
$this->jwsParser->parse($token), | ||
$this->jwsVerifierDecorator, | ||
$this->jwksFactory, | ||
$this->jwsSerializerManagerDecorator, | ||
$this->timestampValidationLeeway, | ||
$this->helpers, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimpleSAML\OpenID\Federation; | ||
|
||
use SimpleSAML\OpenID\Codebooks\ClaimsEnum; | ||
use SimpleSAML\OpenID\Codebooks\JwtTypesEnum; | ||
use SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException; | ||
use SimpleSAML\OpenID\Jws\ParsedJws; | ||
|
||
class TrustMarkDelegation extends ParsedJws | ||
{ | ||
/** | ||
* @return non-empty-string | ||
* @throws \SimpleSAML\OpenID\Exceptions\JwsException | ||
* @throws \SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException | ||
*/ | ||
public function getIssuer(): string | ||
{ | ||
return parent::getIssuer() ?? throw new TrustMarkDelegationException('No Issuer claim found.'); | ||
} | ||
|
||
/** | ||
* @return non-empty-string | ||
* @throws \SimpleSAML\OpenID\Exceptions\JwsException | ||
* @throws \SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException | ||
*/ | ||
public function getSubject(): string | ||
{ | ||
return parent::getSubject() ?? throw new TrustMarkDelegationException('No Subject claim found.'); | ||
} | ||
|
||
/** | ||
* @return non-empty-string | ||
* @throws \SimpleSAML\OpenID\Exceptions\JwsException | ||
* @throws \SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException | ||
*/ | ||
public function getIdentifier(): string | ||
{ | ||
return parent::getIdentifier() ?? throw new TrustMarkDelegationException('No Identifier claim found.'); | ||
} | ||
|
||
/** | ||
* @throws \SimpleSAML\OpenID\Exceptions\JwsException | ||
* @throws \SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException | ||
*/ | ||
public function getIssuedAt(): int | ||
{ | ||
return parent::getIssuedAt() ?? throw new TrustMarkDelegationException('No Issued At claim found.'); | ||
} | ||
|
||
/** | ||
* @return ?non-empty-string | ||
* @throws \SimpleSAML\OpenID\Exceptions\JwsException | ||
* @throws \SimpleSAML\OpenID\Exceptions\InvalidValueException | ||
*/ | ||
public function getReference(): ?string | ||
{ | ||
$ref = $this->getPayloadClaim(ClaimsEnum::Ref->value); | ||
|
||
return is_null($ref) ? | ||
null : | ||
$this->helpers->type()->ensureNonEmptyString($ref, ClaimsEnum::Ref->value); | ||
} | ||
|
||
/** | ||
* @return non-empty-string | ||
* @throws \SimpleSAML\OpenID\Exceptions\JwsException | ||
* @throws \SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException | ||
*/ | ||
public function getKeyId(): string | ||
{ | ||
return parent::getKeyId() ?? throw new TrustMarkDelegationException('No KeyId header claim found.'); | ||
} | ||
|
||
/** | ||
* @throws \SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException | ||
* @throws \SimpleSAML\OpenID\Exceptions\JwsException | ||
* @return non-empty-string | ||
*/ | ||
public function getType(): string | ||
{ | ||
$typ = parent::getType() ?? throw new TrustMarkDelegationException('No Type header claim found.'); | ||
|
||
if ($typ !== JwtTypesEnum::TrustMarkJwt->value) { | ||
throw new TrustMarkDelegationException('Invalid Type header claim.'); | ||
} | ||
|
||
return $typ; | ||
} | ||
|
||
/** | ||
* @throws \SimpleSAML\OpenID\Exceptions\JwsException | ||
* @throws \SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException | ||
*/ | ||
public function validate(): void | ||
{ | ||
$this->validateByCallbacks( | ||
$this->getIssuer(...), | ||
$this->getSubject(...), | ||
$this->getIdentifier(...), | ||
$this->getIssuedAt(...), | ||
$this->getExpirationTime(...), | ||
$this->getReference(...), | ||
$this->getKeyId(...), | ||
$this->getType(...), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.