44
55namespace SimpleSAML \OpenID \VerifiableCredentials \VcDataModel \Factories ;
66
7+ use DateTimeImmutable ;
78use SimpleSAML \OpenID \Codebooks \ClaimsEnum ;
89use SimpleSAML \OpenID \Exceptions \VcDataModelException ;
910use SimpleSAML \OpenID \Factories \ClaimFactory ;
1011use SimpleSAML \OpenID \Helpers ;
1112use SimpleSAML \OpenID \VerifiableCredentials \VcDataModel \Claims \VcAtContextClaimValue ;
1213use SimpleSAML \OpenID \VerifiableCredentials \VcDataModel \Claims \VcClaimValue ;
14+ use SimpleSAML \OpenID \VerifiableCredentials \VcDataModel \Claims \VcCredentialStatusClaimValue ;
1315use SimpleSAML \OpenID \VerifiableCredentials \VcDataModel \Claims \VcCredentialSubjectClaimBag ;
1416use SimpleSAML \OpenID \VerifiableCredentials \VcDataModel \Claims \VcCredentialSubjectClaimValue ;
1517use SimpleSAML \OpenID \VerifiableCredentials \VcDataModel \Claims \VcIssuerClaimValue ;
18+ use SimpleSAML \OpenID \VerifiableCredentials \VcDataModel \Claims \VcProofClaimValue ;
1619
1720class VcDataModelClaimFactory
1821{
@@ -32,13 +35,21 @@ public function buildVcClaimValue(
3235 array $ vcType ,
3336 VcCredentialSubjectClaimBag $ vcCredentialSubjectClaimBag ,
3437 VcIssuerClaimValue $ vcIssuerClaimValue ,
38+ DateTimeImmutable $ vcIssuanceDate ,
39+ ?VcProofClaimValue $ vcProofClaimValue ,
40+ ?DateTimeImmutable $ vcExpirationDate ,
41+ ?VcCredentialStatusClaimValue $ vcCredentialStatusClaimValue ,
3542 ): VcClaimValue {
3643 return new VcClaimValue (
3744 $ vcAtContextClaimValue ,
3845 $ vcId ,
3946 $ vcType ,
4047 $ vcCredentialSubjectClaimBag ,
4148 $ vcIssuerClaimValue ,
49+ $ vcIssuanceDate ,
50+ $ vcProofClaimValue ,
51+ $ vcExpirationDate ,
52+ $ vcCredentialStatusClaimValue ,
4253 );
4354 }
4455
@@ -94,4 +105,40 @@ public function buildVcIssuerClaimValue(array $data): VcIssuerClaimValue
94105
95106 return new VcIssuerClaimValue ($ id , $ data );
96107 }
108+
109+ /**
110+ * @param non-empty-array<mixed> $data
111+ * @throws \SimpleSAML\OpenID\Exceptions\VcDataModelException
112+ * @throws \SimpleSAML\OpenID\Exceptions\InvalidValueException
113+ */
114+ public function buildVcProofClaimValue (array $ data ): VcProofClaimValue
115+ {
116+ $ type = $ data [ClaimsEnum::Type->value ] ?? throw new VcDataModelException (
117+ 'No Type claim value available. ' ,
118+ );
119+
120+ $ type = $ this ->helpers ->type ()->ensureNonEmptyString ($ type );
121+
122+ return new VcProofClaimValue ($ type , $ data );
123+ }
124+
125+ /**
126+ * @param non-empty-array<mixed> $data
127+ * @throws \SimpleSAML\OpenID\Exceptions\InvalidValueException
128+ * @throws \SimpleSAML\OpenID\Exceptions\VcDataModelException
129+ */
130+ public function buildVcCredentialStatusClaimValue (array $ data ): VcCredentialStatusClaimValue
131+ {
132+ $ id = $ data [ClaimsEnum::Id->value ] ?? throw new VcDataModelException (
133+ 'No Issuer ID claim value available. ' ,
134+ );
135+ $ id = $ this ->helpers ->type ()->enforceUri ($ id );
136+
137+ $ type = $ data [ClaimsEnum::Type->value ] ?? throw new VcDataModelException (
138+ 'No Type claim value available. ' ,
139+ );
140+ $ type = $ this ->helpers ->type ()->ensureNonEmptyString ($ type );
141+
142+ return new VcCredentialStatusClaimValue ($ id , $ type , $ data );
143+ }
97144}
0 commit comments