File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,4 +148,6 @@ enum ClaimsEnum: string
148148 case Use = 'use ' ;
149149 case UserAuthentication = 'user_authentication ' ;
150150 case UserinfoEndpoint = 'userinfo_endpoint ' ;
151+ // VerifiableCredential
152+ case Vc = 'vc ' ;
151153}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace SimpleSAML \OpenID \Exceptions ;
6+
7+ class JwtVcJsonException extends JwsException
8+ {
9+ }
Original file line number Diff line number Diff line change 44
55namespace SimpleSAML \OpenID \VerifiableCredentials ;
66
7+ use SimpleSAML \OpenID \Codebooks \ClaimsEnum ;
78use SimpleSAML \OpenID \Codebooks \CredentialFormatIdentifiersEnum ;
9+ use SimpleSAML \OpenID \Exceptions \JwtVcJsonException ;
810use SimpleSAML \OpenID \Jws \ParsedJws ;
911
1012class JwtVcJson extends ParsedJws implements VerifiableCredentialInterface
@@ -13,4 +15,32 @@ public function getCredentialFormatIdentifier(): CredentialFormatIdentifiersEnum
1315 {
1416 return CredentialFormatIdentifiersEnum::JwtVcJson;
1517 }
18+
19+ /**
20+ * @throws \SimpleSAML\OpenID\Exceptions\JwsException
21+ * @throws \SimpleSAML\OpenID\Exceptions\JwtVcJsonException
22+ * @return mixed[]
23+ */
24+ public function getVc (): array
25+ {
26+ $ claimKey = ClaimsEnum::Vc->value ;
27+
28+ $ vc = $ this ->getPayloadClaim ($ claimKey ) ?? throw new JwtVcJsonException ('No vc claim found. ' );
29+
30+ if (is_array ($ vc )) {
31+ return $ vc ;
32+ }
33+
34+ throw new JwtVcJsonException ('Invalid vc claim. ' );
35+ }
36+
37+ /**
38+ * @throws \SimpleSAML\OpenID\Exceptions\JwsException
39+ */
40+ protected function validate (): void
41+ {
42+ $ this ->validateByCallbacks (
43+ $ this ->getVc (...),
44+ );
45+ }
1646}
You can’t perform that action at this time.
0 commit comments