2222
2323## Nuget Packages in this repository
2424
25- ## [ SmartHealthCard.Token] ( https://www.nuget.org/packages/SmartHealthCard.Token/0.1.0-alpha.1 ) : Encode, Decode & Verifiy SMART Health Card JWS tokens
25+ ## [ SmartHealthCard.Token] ( https://www.nuget.org/packages/SmartHealthCard.Token/0.1.0-alpha.4 ) : Encode, Decode & Verifiy SMART Health Card JWS tokens
2626```
27- Install-Package SmartHealthCard.QRCode -Version 0.1.0-alpha.3
27+ Install-Package SmartHealthCard.QRCode -Version 0.1.0-alpha.4
2828```
2929
3030
@@ -43,6 +43,7 @@ Install-Package SmartHealthCard.QRCode -Version 0.1.0-alpha.2
4343using SmartHealthCard .QRCode ;
4444using SmartHealthCard .Token ;
4545using SmartHealthCard .Token .Certificates ;
46+ using SmartHealthCard .Token .Exceptions ;
4647using SmartHealthCard .Token .Model .Shc ;
4748using System ;
4849using System .Collections .Generic ;
@@ -84,13 +85,17 @@ namespace SHC.EncoderDemo
8485 string FhirBundleJson = " [A Smart Health Card FHIR Bundle in JSON format]" ;
8586
8687 // Set the base of the URL where any validator will retrieve the public keys from (e.g : [Issuer]/.well-known/jwks.json)
87- Uri Issuer = new Uri (" https://sonichealthcare .com/something " );
88+ Uri Issuer = new Uri (" https://acmecare .com/shc " );
8889
8990 // Set when the Smart Health Card becomes valid, (e.g the from date).
9091 DateTimeOffset IssuanceDateTimeOffset = DateTimeOffset .Now .AddMinutes (- 1 );
9192
9293 // Set the appropriate VerifiableCredentialsType enum list, for more info see: see: https://smarthealth.cards/vocabulary/
93- var VerifiableCredentialTypeList = new List <VerifiableCredentialType >() { VerifiableCredentialType .Covid19 };
94+ List < VerifiableCredentialType > VerifiableCredentialTypeList = new List <VerifiableCredentialType >()
95+ {
96+ VerifiableCredentialType .HealthCard ,
97+ VerifiableCredentialType .Covid19
98+ };
9499
95100 // Instantiate and populate the Smart Health Card Model with the properties we just setup
96101 SmartHealthCardModel SmartHealthCard = new SmartHealthCardModel (Issuer , IssuanceDateTimeOffset ,
@@ -100,8 +105,22 @@ namespace SHC.EncoderDemo
100105 // Instantiate the Smart Health Card Encoder
101106 SmartHealthCardEncoder SmartHealthCardEncoder = new SmartHealthCardEncoder ();
102107
103- // Get the Smart Health Card JWS Token
104- string SmartHealthCardJwsToken = await SmartHealthCardEncoder .GetTokenAsync (Certificate , SmartHealthCard );
108+ string SmartHealthCardJwsToken = string .Empty ;
109+ try
110+ {
111+ // Get the Smart Health Card JWS Token
112+ SmartHealthCardJwsToken = await SmartHealthCardEncoder .GetTokenAsync (Certificate , SmartHealthCard );
113+ }
114+ catch (SmartHealthCardEncoderException EncoderException )
115+ {
116+ Console .WriteLine (" The SMART Health Card Encoder has found an error, please see message below:" );
117+ Console .WriteLine (EncoderException .Message );
118+ }
119+ catch (Exception Exception )
120+ {
121+ Console .WriteLine (" Oops, there is an unexpected development exception" );
122+ Console .WriteLine (Exception .Message );
123+ }
105124
106125 // Instantiate the Smart Health Card QR Code Factory
107126 SmartHealthCardQRCodeEncoder SmartHealthCardQRCodeEncoder = new SmartHealthCardQRCodeEncoder ();
@@ -158,24 +177,6 @@ namespace SHC.DecoderDemo
158177 // Instantiate the SmartHealthCard Decoder
159178 SmartHealthCardDecoder Decoder = new SmartHealthCardDecoder ();
160179
161- // Useful while in development!!
162- // Optionally for development, you can provide an implementation of the IJwksProvider interface
163- // which allows you to pass a JSON Web Key Set (JKWS) that contain the public key used to verify you
164- // token's signatures.
165-
166- // If you don't do this the default implementation will use the Issuer (iss) value from Smart Health Card
167- // token payload to make a HTTP call to obtain the JWKS file, which in a production system it the behavior you want.
168-
169- // Yet in development this means you must have a public endpoint to provide the JWKS.
170-
171- // By providing this simple interface implementation (see MyJwksProvider class below) you can successfully
172- // validate signatures in development with out the need for a public endpoint.
173- // Of course you would not do this is production.
174-
175- // Here is how you pass that interface implementation to the SmartHealthCardDecoder constructor.
176- // SmartHealthCard.Token.Providers.IJwksProvider MyJwksProvider = new MyJwksProvider(Certificate);
177- // SmartHealthCardDecoder Decoder = new SmartHealthCardDecoder(MyJwksProvider);
178-
179180 try
180181 {
181182 // Decode and verify, returning an object model of the Smart Health Card, throws exceptions if not valid
@@ -195,7 +196,27 @@ namespace SHC.DecoderDemo
195196 }
196197 }
197198
198- // Example implementation of the IJwksProvider interface
199+
200+ // When in development!
201+ // For development, you can provide an implementation of the IJwksProvider interface
202+ // which will allow you to pass to the decoder a JSON Web Key Set (JKWS) that contain the public key
203+ // used to verify the token's signatures.
204+
205+ // If you don't do this the default implementation will use the Issuer (iss) value from Smart Health Card
206+ // token payload to make a HTTP call to obtain the JWKS file, which in a production system it the behavior
207+ // you want.
208+
209+ // For development this would means you must have a public endpoint to provide the JWKS.
210+
211+ // By providing this simple interface implementation (see MyJwksProvider class below) you can successfully
212+ // validate signatures in development with out the need for a public endpoint. Of course you would not do
213+ // this is production.
214+
215+ // Here is how you pass that interface implementation to the SmartHealthCardDecoder constructor.
216+ // SmartHealthCard.Token.Providers.IJwksProvider MyJwksProvider = new MyJwksProvider(Certificate);
217+ // SmartHealthCardDecoder Decoder = new SmartHealthCardDecoder(MyJwksProvider);
218+
219+ // Here is an xxample implementation of the IJwksProvider interface
199220 public class MyJwksProvider : SmartHealthCard .Token .Providers .IJwksProvider
200221 {
201222 private readonly X509Certificate2 Certificate ;
0 commit comments