@@ -39,6 +39,7 @@ public function isValidationCachedFor(
3939 string $ trustAnchorId ,
4040 ): bool {
4141 if (is_null ($ this ->cacheDecorator )) {
42+ $ this ->logger ?->debug('Cache not available, skipping. ' );
4243 return false ;
4344 }
4445
@@ -90,7 +91,7 @@ public function isValidationCachedFor(
9091 * @throws \SimpleSAML\OpenID\Exceptions\TrustMarkException
9192 * @throws \Psr\SimpleCache\InvalidArgumentException
9293 */
93- public function forTrustMarkId (
94+ public function fromCacheOrDoForTrustMarkId (
9495 string $ trustMarkId ,
9596 EntityStatement $ leafEntityConfiguration ,
9697 EntityStatement $ trustAnchorEntityConfiguration ,
@@ -105,6 +106,21 @@ public function forTrustMarkId(
105106 return ;
106107 }
107108
109+ $ this ->doForTrustMarkId ($ trustMarkId , $ leafEntityConfiguration , $ trustAnchorEntityConfiguration );
110+ }
111+
112+ /**
113+ * @param non-empty-string $trustMarkId
114+ * @throws \SimpleSAML\OpenID\Exceptions\EntityStatementException
115+ * @throws \SimpleSAML\OpenID\Exceptions\InvalidValueException
116+ * @throws \SimpleSAML\OpenID\Exceptions\JwsException
117+ * @throws \SimpleSAML\OpenID\Exceptions\TrustMarkException
118+ */
119+ public function doForTrustMarkId (
120+ string $ trustMarkId ,
121+ EntityStatement $ leafEntityConfiguration ,
122+ EntityStatement $ trustAnchorEntityConfiguration ,
123+ ): void {
108124 $ this ->logger ?->debug(
109125 sprintf (
110126 'Validating Trust Mark %s for leaf entity %s under Trust Anchor %s. ' ,
@@ -201,12 +217,14 @@ public function forTrustMarkId(
201217 }
202218 }
203219
204- throw new TrustMarkException (sprintf (
205- 'Could not validate Trust Mark %s for leaf entity %s under Trust Anchor %s. ' ,
206- $ trustMarkId ,
207- $ leafEntityConfiguration ->getIssuer (),
208- $ trustAnchorEntityConfiguration ->getIssuer (),
209- ));
220+ throw new TrustMarkException (
221+ sprintf (
222+ 'Could not validate Trust Mark %s for leaf entity %s under Trust Anchor %s. ' ,
223+ $ trustMarkId ,
224+ $ leafEntityConfiguration ->getIssuer (),
225+ $ trustAnchorEntityConfiguration ->getIssuer (),
226+ ),
227+ );
210228 }
211229
212230 /**
@@ -218,7 +236,7 @@ public function forTrustMarkId(
218236 * @throws \SimpleSAML\OpenID\Exceptions\TrustMarkException
219237 * @throws \Psr\SimpleCache\InvalidArgumentException
220238 */
221- public function forTrustMarksClaimValue (
239+ public function fromCacheOrDoForTrustMarksClaimValue (
222240 TrustMarksClaimValue $ trustMarksClaimValue ,
223241 EntityStatement $ leafEntityConfiguration ,
224242 EntityStatement $ trustAnchorEntityConfiguration ,
@@ -249,7 +267,7 @@ public function forTrustMarksClaimValue(
249267 * @throws \SimpleSAML\OpenID\Exceptions\TrustMarkDelegationException
250268 * @throws \SimpleSAML\OpenID\Exceptions\TrustMarkException
251269 */
252- protected function doForTrustMarksClaimValue (
270+ public function doForTrustMarksClaimValue (
253271 TrustMarksClaimValue $ trustMarksClaimValue ,
254272 EntityStatement $ leafEntityConfiguration ,
255273 EntityStatement $ trustAnchorEntityConfiguration ,
@@ -332,7 +350,7 @@ public function validateTrustMarksClaimValue(
332350 * @throws \SimpleSAML\OpenID\Exceptions\JwksException
333351 * @throws \Psr\SimpleCache\InvalidArgumentException
334352 */
335- public function forTrustMark (
353+ public function fromCacheOrDoForTrustMark (
336354 TrustMark $ trustMark ,
337355 EntityStatement $ leafEntityConfiguration ,
338356 EntityStatement $ trustAnchorEntityConfiguration ,
@@ -363,7 +381,7 @@ public function forTrustMark(
363381 * @throws \SimpleSAML\OpenID\Exceptions\TrustMarkException
364382 * @throws \SimpleSAML\OpenID\Exceptions\JwksException
365383 */
366- protected function doForTrustMark (
384+ public function doForTrustMark (
367385 TrustMark $ trustMark ,
368386 EntityStatement $ leafEntityConfiguration ,
369387 EntityStatement $ trustAnchorEntityConfiguration ,
@@ -384,9 +402,9 @@ protected function doForTrustMark(
384402 $ trustAnchorEntityConfiguration ,
385403 );
386404
387- $ trustMarkIssuerEntityStatement = $ trustMarkIssuerTrustChain ->getResolvedLeaf ();
405+ $ trustMarkIssuerEntityConfiguration = $ trustMarkIssuerTrustChain ->getResolvedLeaf ();
388406
389- $ this ->validateTrustMarkSignature ($ trustMark , $ trustMarkIssuerEntityStatement );
407+ $ this ->validateTrustMarkSignature ($ trustMark , $ trustMarkIssuerEntityConfiguration );
390408
391409 $ this ->validateTrustMarkDelegation ($ trustMark , $ trustAnchorEntityConfiguration );
392410
@@ -425,7 +443,7 @@ protected function doForTrustMark(
425443 $ trustAnchorEntityConfiguration ->getIssuer (),
426444 );
427445 } catch (Throwable $ exception ) {
428- $ this ->logger ?->debug (sprintf (
446+ $ this ->logger ?->error (sprintf (
429447 'Error caching Trust Mark %s validation for leaf entity %s under Trust Anchor %s with TTL ' .
430448 ' %s. Error wa: %s. ' ,
431449 $ trustMark ->getIdentifier (),
@@ -525,19 +543,19 @@ public function validateTrustChainForTrustMarkIssuer(
525543 */
526544 public function validateTrustMarkSignature (
527545 TrustMark $ trustMark ,
528- EntityStatement $ trustMarkIssuerEntityStatement ,
546+ EntityStatement $ trustMarkIssuerEntityConfiguration ,
529547 ): void {
530548 $ this ->logger ?->debug('Validating Trust Mark signature. ' );
531549 try {
532- $ trustMark ->verifyWithKeySet ($ trustMarkIssuerEntityStatement ->getJwks ()->getValue ());
550+ $ trustMark ->verifyWithKeySet ($ trustMarkIssuerEntityConfiguration ->getJwks ()->getValue ());
533551 } catch (Throwable $ exception ) {
534552 $ error = sprintf (
535553 'Trust Mark signature validation failed with error: %s ' ,
536554 $ exception ->getMessage (),
537555 );
538556 $ this ->logger ?->error(
539557 $ error ,
540- ['trustMarkIssuerJwks ' => $ trustMarkIssuerEntityStatement ->getJwks ()],
558+ ['trustMarkIssuerJwks ' => $ trustMarkIssuerEntityConfiguration ->getJwks ()],
541559 );
542560 throw new TrustMarkException ($ error );
543561 }
@@ -563,7 +581,7 @@ public function validateTrustMarkDelegation(
563581 if (is_null ($ trustMarkOwnersBag )) {
564582 $ this ->logger ?->debug(
565583 sprintf (
566- 'Trust Anchor %s does not define Trust Mark Owners, skipping delegation validation. ' ,
584+ 'Trust Anchor %s does not define Trust Mark Owners. Skipping delegation validation. ' ,
567585 $ trustAnchorEntityConfiguration ->getIssuer (),
568586 ),
569587 );
0 commit comments