Skip to content

Commit 37c62c7

Browse files
committed
Propagate fromData JWS factory method
1 parent 803bacc commit 37c62c7

10 files changed

Lines changed: 278 additions & 7 deletions

File tree

src/Core/Factories/ClientAssertionFactory.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace SimpleSAML\OpenID\Core\Factories;
66

7+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
78
use SimpleSAML\OpenID\Core\ClientAssertion;
9+
use SimpleSAML\OpenID\Jwk\JwkDecorator;
810
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
911

1012
class ClientAssertionFactory extends ParsedJwsFactory
@@ -21,4 +23,31 @@ public function fromToken(string $token): ClientAssertion
2123
$this->claimFactory,
2224
);
2325
}
26+
27+
/**
28+
* @param array<non-empty-string,mixed> $payload
29+
* @param array<non-empty-string,mixed> $header
30+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
31+
*/
32+
public function fromData(
33+
JwkDecorator $signingKey,
34+
SignatureAlgorithmEnum $signatureAlgorithm,
35+
array $payload,
36+
array $header,
37+
): ClientAssertion {
38+
return new ClientAssertion(
39+
$this->jwsDecoratorBuilder->fromData(
40+
$signingKey,
41+
$signatureAlgorithm,
42+
$payload,
43+
$header,
44+
),
45+
$this->jwsVerifierDecorator,
46+
$this->jwksDecoratorFactory,
47+
$this->jwsSerializerManagerDecorator,
48+
$this->timestampValidationLeeway,
49+
$this->helpers,
50+
$this->claimFactory,
51+
);
52+
}
2453
}

src/Core/Factories/RequestObjectFactory.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace SimpleSAML\OpenID\Core\Factories;
66

7+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
78
use SimpleSAML\OpenID\Core\RequestObject;
9+
use SimpleSAML\OpenID\Jwk\JwkDecorator;
810
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
911

1012
class RequestObjectFactory extends ParsedJwsFactory
@@ -21,4 +23,31 @@ public function fromToken(string $token): RequestObject
2123
$this->claimFactory,
2224
);
2325
}
26+
27+
/**
28+
* @param array<non-empty-string,mixed> $payload
29+
* @param array<non-empty-string,mixed> $header
30+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
31+
*/
32+
public function fromData(
33+
JwkDecorator $signingKey,
34+
SignatureAlgorithmEnum $signatureAlgorithm,
35+
array $payload,
36+
array $header,
37+
): RequestObject {
38+
return new RequestObject(
39+
$this->jwsDecoratorBuilder->fromData(
40+
$signingKey,
41+
$signatureAlgorithm,
42+
$payload,
43+
$header,
44+
),
45+
$this->jwsVerifierDecorator,
46+
$this->jwksDecoratorFactory,
47+
$this->jwsSerializerManagerDecorator,
48+
$this->timestampValidationLeeway,
49+
$this->helpers,
50+
$this->claimFactory,
51+
);
52+
}
2453
}

src/Federation/Factories/EntityStatementFactory.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace SimpleSAML\OpenID\Federation\Factories;
66

7+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
78
use SimpleSAML\OpenID\Federation\EntityStatement;
9+
use SimpleSAML\OpenID\Jwk\JwkDecorator;
810
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
911

1012
class EntityStatementFactory extends ParsedJwsFactory
@@ -25,4 +27,31 @@ public function fromToken(string $token): EntityStatement
2527
$this->claimFactory,
2628
);
2729
}
30+
31+
/**
32+
* @param array<non-empty-string,mixed> $payload
33+
* @param array<non-empty-string,mixed> $header
34+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
35+
*/
36+
public function fromData(
37+
JwkDecorator $signingKey,
38+
SignatureAlgorithmEnum $signatureAlgorithm,
39+
array $payload,
40+
array $header,
41+
): EntityStatement {
42+
return new EntityStatement(
43+
$this->jwsDecoratorBuilder->fromData(
44+
$signingKey,
45+
$signatureAlgorithm,
46+
$payload,
47+
$header,
48+
),
49+
$this->jwsVerifierDecorator,
50+
$this->jwksDecoratorFactory,
51+
$this->jwsSerializerManagerDecorator,
52+
$this->timestampValidationLeeway,
53+
$this->helpers,
54+
$this->claimFactory,
55+
);
56+
}
2857
}

src/Federation/Factories/RequestObjectFactory.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace SimpleSAML\OpenID\Federation\Factories;
66

7+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
78
use SimpleSAML\OpenID\Federation\RequestObject;
9+
use SimpleSAML\OpenID\Jwk\JwkDecorator;
810
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
911

1012
class RequestObjectFactory extends ParsedJwsFactory
@@ -25,4 +27,31 @@ public function fromToken(string $token): RequestObject
2527
$this->claimFactory,
2628
);
2729
}
30+
31+
/**
32+
* @param array<non-empty-string,mixed> $payload
33+
* @param array<non-empty-string,mixed> $header
34+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
35+
*/
36+
public function fromData(
37+
JwkDecorator $signingKey,
38+
SignatureAlgorithmEnum $signatureAlgorithm,
39+
array $payload,
40+
array $header,
41+
): RequestObject {
42+
return new RequestObject(
43+
$this->jwsDecoratorBuilder->fromData(
44+
$signingKey,
45+
$signatureAlgorithm,
46+
$payload,
47+
$header,
48+
),
49+
$this->jwsVerifierDecorator,
50+
$this->jwksDecoratorFactory,
51+
$this->jwsSerializerManagerDecorator,
52+
$this->timestampValidationLeeway,
53+
$this->helpers,
54+
$this->claimFactory,
55+
);
56+
}
2857
}

src/Federation/Factories/TrustMarkDelegationFactory.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace SimpleSAML\OpenID\Federation\Factories;
66

7+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
78
use SimpleSAML\OpenID\Federation\TrustMarkDelegation;
9+
use SimpleSAML\OpenID\Jwk\JwkDecorator;
810
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
911

1012
class TrustMarkDelegationFactory extends ParsedJwsFactory
@@ -21,4 +23,31 @@ public function fromToken(string $token): TrustMarkDelegation
2123
$this->claimFactory,
2224
);
2325
}
26+
27+
/**
28+
* @param array<non-empty-string,mixed> $payload
29+
* @param array<non-empty-string,mixed> $header
30+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
31+
*/
32+
public function fromData(
33+
JwkDecorator $signingKey,
34+
SignatureAlgorithmEnum $signatureAlgorithm,
35+
array $payload,
36+
array $header,
37+
): TrustMarkDelegation {
38+
return new TrustMarkDelegation(
39+
$this->jwsDecoratorBuilder->fromData(
40+
$signingKey,
41+
$signatureAlgorithm,
42+
$payload,
43+
$header,
44+
),
45+
$this->jwsVerifierDecorator,
46+
$this->jwksDecoratorFactory,
47+
$this->jwsSerializerManagerDecorator,
48+
$this->timestampValidationLeeway,
49+
$this->helpers,
50+
$this->claimFactory,
51+
);
52+
}
2453
}

src/Federation/Factories/TrustMarkFactory.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace SimpleSAML\OpenID\Federation\Factories;
66

7+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
78
use SimpleSAML\OpenID\Codebooks\JwtTypesEnum;
89
use SimpleSAML\OpenID\Federation\TrustMark;
10+
use SimpleSAML\OpenID\Jwk\JwkDecorator;
911
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
1012

1113
class TrustMarkFactory extends ParsedJwsFactory
@@ -25,4 +27,33 @@ public function fromToken(
2527
$expectedJwtType,
2628
);
2729
}
30+
31+
/**
32+
* @param array<non-empty-string,mixed> $payload
33+
* @param array<non-empty-string,mixed> $header
34+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
35+
*/
36+
public function fromData(
37+
JwkDecorator $signingKey,
38+
SignatureAlgorithmEnum $signatureAlgorithm,
39+
array $payload,
40+
array $header,
41+
JwtTypesEnum $expectedJwtType = JwtTypesEnum::TrustMarkJwt,
42+
): TrustMark {
43+
return new TrustMark(
44+
$this->jwsDecoratorBuilder->fromData(
45+
$signingKey,
46+
$signatureAlgorithm,
47+
$payload,
48+
$header,
49+
),
50+
$this->jwsVerifierDecorator,
51+
$this->jwksDecoratorFactory,
52+
$this->jwsSerializerManagerDecorator,
53+
$this->timestampValidationLeeway,
54+
$this->helpers,
55+
$this->claimFactory,
56+
$expectedJwtType,
57+
);
58+
}
2859
}

src/Jwks/Factories/SignedJwksFactory.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace SimpleSAML\OpenID\Jwks\Factories;
66

7+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
8+
use SimpleSAML\OpenID\Jwk\JwkDecorator;
79
use SimpleSAML\OpenID\Jwks\SignedJwks;
810
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
911

@@ -24,4 +26,31 @@ public function fromToken(string $token): SignedJwks
2426
$this->claimFactory,
2527
);
2628
}
29+
30+
/**
31+
* @param array<non-empty-string,mixed> $payload
32+
* @param array<non-empty-string,mixed> $header
33+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
34+
*/
35+
public function fromData(
36+
JwkDecorator $signingKey,
37+
SignatureAlgorithmEnum $signatureAlgorithm,
38+
array $payload,
39+
array $header,
40+
): SignedJwks {
41+
return new SignedJwks(
42+
$this->jwsDecoratorBuilder->fromData(
43+
$signingKey,
44+
$signatureAlgorithm,
45+
$payload,
46+
$header,
47+
),
48+
$this->jwsVerifierDecorator,
49+
$this->jwksDecoratorFactory,
50+
$this->jwsSerializerManagerDecorator,
51+
$this->timestampValidationLeeway,
52+
$this->helpers,
53+
$this->claimFactory,
54+
);
55+
}
2756
}

src/Jws/Factories/ParsedJwsFactory.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
namespace SimpleSAML\OpenID\Jws\Factories;
66

7+
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
78
use SimpleSAML\OpenID\Decorators\DateIntervalDecorator;
89
use SimpleSAML\OpenID\Factories\ClaimFactory;
910
use SimpleSAML\OpenID\Helpers;
11+
use SimpleSAML\OpenID\Jwk\JwkDecorator;
1012
use SimpleSAML\OpenID\Jwks\Factories\JwksDecoratorFactory;
1113
use SimpleSAML\OpenID\Jws\JwsDecoratorBuilder;
1214
use SimpleSAML\OpenID\Jws\JwsVerifierDecorator;
@@ -41,4 +43,31 @@ public function fromToken(string $token): ParsedJws
4143
$this->claimFactory,
4244
);
4345
}
46+
47+
/**
48+
* @param array<non-empty-string,mixed> $payload
49+
* @param array<non-empty-string,mixed> $header
50+
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
51+
*/
52+
public function fromData(
53+
JwkDecorator $signingKey,
54+
SignatureAlgorithmEnum $signatureAlgorithm,
55+
array $payload,
56+
array $header,
57+
): ParsedJws {
58+
return new ParsedJws(
59+
$this->jwsDecoratorBuilder->fromData(
60+
$signingKey,
61+
$signatureAlgorithm,
62+
$payload,
63+
$header,
64+
),
65+
$this->jwsVerifierDecorator,
66+
$this->jwksDecoratorFactory,
67+
$this->jwsSerializerManagerDecorator,
68+
$this->timestampValidationLeeway,
69+
$this->helpers,
70+
$this->claimFactory,
71+
);
72+
}
4473
}

src/Jws/JwsDecoratorBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function fromToken(string $token): JwsDecorator
4040
* @throws \SimpleSAML\OpenID\Exceptions\JwsException
4141
*/
4242
public function fromData(
43-
JwkDecorator $signatureJwkDecorator,
43+
JwkDecorator $signingKey,
4444
SignatureAlgorithmEnum $signatureAlgorithm,
4545
array $payload,
4646
array $header,
@@ -55,7 +55,7 @@ public function fromData(
5555
$this->jwsBuilder->create()->withPayload(
5656
$this->helpers->json()->encode($payload),
5757
)->addSignature(
58-
$signatureJwkDecorator->jwk(),
58+
$signingKey->jwk(),
5959
$header,
6060
)->build(),
6161
);

0 commit comments

Comments
 (0)