Esempio n. 1
0
 private void SetValues(AsymmetricEncryptionMetaDataBase rec)
 {
     this.KeyId              = rec.KeyId;
     this.Key2Id             = rec.Key2Id;
     this.Reference          = rec.Reference;
     this.AsymmetricStrategy = rec.AsymmetricStrategy;
     this.PublicMetadata     = rec.PublicMetadata;
 }
Esempio n. 2
0
        public override void LoadFromByteArray(byte[] input)
        {
            AsymmetricEncryptionMetaDataBase rec = null;

            try
            {
                var json = (string)Serializer.DeserializeFromByteArray(input);
                rec = (AsymmetricEncryptionMetaDataBase)Serializer.DeserializeFromJson(json, typeof(AsymmetricallyEncryptedObject));
                this.SetValues(rec);
            }
            catch (Exception ex)
            {
                bool success = false;
                if (ex.Message.Contains("cast"))
                {
                    // this may have been a direct serialization
                    try
                    {
                        var deserObj = Serializer.DeserializeFromByteArray(input);
                        if (deserObj is AsymmetricEncryptionMetaDataBase)
                        {
                            rec = (AsymmetricEncryptionMetaDataBase)deserObj;
                        }
                        if (rec != null)
                        {
                            this.SetValues((AsymmetricEncryptionMetaDataBase)rec);
                            success = true;
                        }
                    }
                    catch (Exception)
                    {
                        // continue with normal error
                    }
                }

                if (!success)
                {
                    throw new System.Runtime.Serialization.SerializationException("input was not a validly serialized AsymmetricallyEncryptedObject", ex);
                }
            }
        }
 private void SetValues(AsymmetricEncryptionMetaDataBase rec)
 {
     this.KeyId = rec.KeyId;
     this.Key2Id = rec.Key2Id;
     this.Reference = rec.Reference;
     this.AsymmetricStrategy = rec.AsymmetricStrategy;
     this.PublicMetadata = rec.PublicMetadata;
 }