コード例 #1
0
 public DataRequest(IEnumerable<GrantedContext> careContexts,
     DateRange dateRange,
     string dataPushUrl,
     IEnumerable<HiType> hiType,
     string transactionId,
     KeyMaterial keyMaterial,
     string gatewayId,
     string consentId,
     string cmSuffix)
 {
     CareContexts = careContexts;
     DateRange = dateRange;
     DataPushUrl = dataPushUrl;
     HiType = hiType;
     TransactionId = transactionId;
     KeyMaterial = keyMaterial;
     GatewayId = gatewayId;
     ConsentId = consentId;
     CmSuffix = cmSuffix;
 }
コード例 #2
0
        public virtual Option <EncryptedEntries> Process(Entries entries,
                                                         HipLibrary.Patient.Model.KeyMaterial dataRequestKeyMaterial, string transactionId)
        {
            var keyPair = EncryptorHelper.GenerateKeyPair(dataRequestKeyMaterial.Curve,
                                                          dataRequestKeyMaterial.CryptoAlg);
            var randomKey = EncryptorHelper.GenerateRandomKey();

            var processedEntries = new List <Entry>();
            var careBundles      = entries.CareBundles;

            foreach (var careBundle in careBundles)
            {
                var encryptData =
                    encryptor.EncryptData(dataRequestKeyMaterial,
                                          keyPair,
                                          Serializer.SerializeToString(careBundle.BundleForThisCcr), randomKey);
                if (!encryptData.HasValue)
                {
                    return(Option.None <EncryptedEntries>());
                }

                encryptData.MatchSome(content =>
                {
                    var entry = IsLinkable(content)
                        ? StoreComponentAndGetLink(ComponentEntry(content, careBundle.CareContextReference),
                                                   careBundle.CareContextReference)
                        : ComponentEntry(content, careBundle.CareContextReference);
                    processedEntries.Add(entry);
                });
            }

            var keyStructure = new KeyStructure(DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"),
                                                dataRequestKeyMaterial.DhPublicKey.Parameters, EncryptorHelper.GetPublicKey(keyPair));
            var keyMaterial = new KeyMaterial(dataRequestKeyMaterial.CryptoAlg,
                                              dataRequestKeyMaterial.Curve,
                                              keyStructure, randomKey);

            return(Option.Some(new EncryptedEntries(processedEntries.AsEnumerable(), keyMaterial)));
        }
コード例 #3
0
 public EncryptedEntries(IEnumerable <Entry> entries, KeyMaterial keyMaterial)
 {
     Entries     = entries;
     KeyMaterial = keyMaterial;
 }
コード例 #4
0
 public DataResponse(string transactionId, IEnumerable <Entry> entries, KeyMaterial keyMaterial)
 {
     TransactionId = transactionId;
     Entries       = entries;
     KeyMaterial   = keyMaterial;
 }