static void Main(string[] args) { //An instance of ContractNoteInfo is created. ContractNoteInfo noteInfo = new ContractNoteInfo("MSFT", 100, 24); //ContractNoteInfo is decorated with Serializable attribute, //so the entire object graph with help of BinaryFormatter is //flattened into raw bytes and this task is achieved by //with help of SerializeContractNote method byte[] data = SerializeContractNote(noteInfo); //Generate public and private key for demonstration purpose GenerateKey(); //Security Framework is initialized and a new instance of DataSecurity //is created and this instance returned by DataSecurityManager //is exclusively meant for instances of ContractNoteInfo. This //behavior is similar to XmlSerializer where there exists strong //coupling between an object instance and the type associated with it. DataSecurityManager secMgr = new DataSecurityManager(); DataSecurity dataSec = secMgr.Secure(typeof(ContractNoteInfo)); //The serialized byte array of ContractNoteInfo is then passed to //Create method of DataSecurity that is then handed internally to //NonRepudiationProvider which creates digital signature and //associates it with SecureEnvelope. Also, secure envelope itself //is marked serializable so its entire object graph itself can now //be serialized and transmitted over wire. SecureEnvelope secureEnvelope = dataSec.Create(data); Console.WriteLine("Secure Envelope successfully created.."); Console.ReadLine(); }
public DataSecurity(DataSecurityManager mgr, Type type) { objType = type; securityMgr = mgr; ExtractAttributes(); }