Beispiel #1
0
        public void Decrypt(FileInfo fileToDecrypt, ICryptographyExecutionService cryptoCmdService)
        {
            CryptographyResponse response;

            try
            {
                response = cryptoCmdService.Execute(new DecryptionRequest(fileToDecrypt, this.PublicKey, this.PassPhrase));
                if (response == null || response.Files.Count() != 1)
                {
                    throw new Exception();
                }
            }
            catch (Exception e) { throw; }

            DomainEvents.Publish(new FileDecryptedEvent(this.Id, response.Files.First()));
        }
Beispiel #2
0
        public static KeyPair Create(ICryptographyExecutionService cryptoCmdService)
        {
            //should be in application service layer??
            //maybe not as theres domainSpecific validation going on here (count != 3)
            CryptographyResponse response;

            try
            {
                response = cryptoCmdService.Execute(new GenerateKeyPairRequest());
                if (response == null || response.Files.Count() != 3)
                {
                    throw new Exception("Unable to generate keypair");
                }
            }
            catch (Exception) { throw; }

            var keyPairFiles = response.Files.ToList();
            var privateKey   = new FileInfo(keyPairFiles[0].FileName, keyPairFiles[0].Content);
            var publicKey    = new FileInfo(keyPairFiles[1].FileName, keyPairFiles[1].Content);
            var passPhrase   = new FileInfo(keyPairFiles[2].FileName, keyPairFiles[2].Content);

            return(new KeyPair(privateKey, publicKey, passPhrase));
        }
 public CreateKeyCommandHandler(IRepository arRepo, ICryptographyExecutionService cryptoSvc)
 {
     this.repo      = arRepo;
     this.cryptoSvc = cryptoSvc;
 }
Beispiel #4
0
 public DecrypeFileCommandHandler(IRepository repo, ICryptographyExecutionService cryptoSvc)
 {
     this.arRepo    = repo;
     this.cryptoSvc = cryptoSvc;
 }