public void HandleTransferRequest(TransferRequestMessage request) { string[] filePaths = FileOperations.GetFilteredFilePaths(logsSourcePath, request.TimeRangeLocal, request.FullCategories); if (filePaths.Length == 0) { SendResponseMessage(ResponseCode.Error, "No files found that match request"); return; } // send response SendResponseMessage(ResponseCode.Ok); // transfer files logger.Log("Transferring files..."); for (int i = 0; i < filePaths.Length; i++) { string path = filePaths[i]; logger.Log("Transferring: " + path); string fileName = Path.GetFileName(path); byte[] fileBytes = File.ReadAllBytes(path); byte[] fileBytesCompressed = ByteCompression.GZipCompress(fileBytes); var message = new TransferOperationMessage( i + 1, filePaths.Length, fileName, fileBytesCompressed); client.Writer.Write(message); } logger.Log("Transfer operation complete"); }
public async Task <TransferReplyMessage> TransferRequestAsync(TransferInstruction instruction) { if (_transferReplyCompletionSource.Task.Status == TaskStatus.WaitingForActivation) { var transferRequest = new TransferRequestMessage( this.SessionId, _originator, new Beneficiary("", _beneficiaryVaan.Vaan), new TransferRequest( instruction.VirtualAssetTransfer.VirtualAssetType, instruction.VirtualAssetTransfer.TransferType, instruction.VirtualAssetTransfer.TransferAmount), _vaspInfo ); await _transportClient.SendAsync(new MessageEnvelope() { Topic = this.CounterPartyTopic, SigningKey = _privateSigningKey, EncryptionType = EncryptionType.Symmetric, EncryptionKey = _sharedSymKeyId }, transferRequest); } return(await _transferReplyCompletionSource.Task); }
public static ProtoTransferRequestMessage MapToProto(TransferRequestMessage message) { var proto = new ProtoTransferRequestMessage() { Comment = message.Comment, Transfer = Mapper.MapTransferToProto(message.Transfer), Beneficiary = Mapper.MapBeneficiaryToProto(message.Beneficiary), Originator = Mapper.MapOriginatorToProto(message.Originator), Message = Mapper.MapMessageToProto(message.MessageType, message.Message), VaspInfo = Mapper.MapVaspInformationToProto(message.VASP) }; return(proto); }
public void Visit(IVisitable pVisitable) { if (pVisitable is TransferRequestItem) { var item = pVisitable as TransferRequestItem; Result = new TransferRequestMessage { Amount = item.Amount, CustomerId = item.CustomerId, FromAccountNumber = item.FromAccountNumber, ToAccountNumber = item.ToAccountNumber, OrderGuid = item.OrderGuid, Topic = item.Topic }; } }
public override int GetHashCode() { int hash = 1; if (msgCase_ == MsgOneofCase.SessionRequestMessage) { hash ^= SessionRequestMessage.GetHashCode(); } if (msgCase_ == MsgOneofCase.SessionReplyMessage) { hash ^= SessionReplyMessage.GetHashCode(); } if (msgCase_ == MsgOneofCase.TransferRequestMessage) { hash ^= TransferRequestMessage.GetHashCode(); } if (msgCase_ == MsgOneofCase.TransferReplyMessage) { hash ^= TransferReplyMessage.GetHashCode(); } if (msgCase_ == MsgOneofCase.TransferDispatchMessage) { hash ^= TransferDispatchMessage.GetHashCode(); } if (msgCase_ == MsgOneofCase.TransaferConfirmationMessage) { hash ^= TransaferConfirmationMessage.GetHashCode(); } if (msgCase_ == MsgOneofCase.TerminationMessage) { hash ^= TerminationMessage.GetHashCode(); } if (msgCase_ == MsgOneofCase.ReservedField) { hash ^= ReservedField.GetHashCode(); } if (Signature.Length != 0) { hash ^= Signature.GetHashCode(); } hash ^= (int)msgCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static TransferRequestMessage MapFromProto(ProtoTransferRequestMessage message) { var messageIn = new Message( message.Message.MessageId, message.Message.SessionId, message.Message.MessageCode); var originator = Mapper.MapOriginatorFromProto(message.Originator); var beneficiary = Mapper.MapBeneficiaryFromProto(message.Beneficiary); var transfer = Mapper.MapTransferFromProto(message.Transfer); var vasp = Mapper.MapVaspInformationFromProto(message.VaspInfo); var obj = new TransferRequestMessage(messageIn, originator, beneficiary, transfer, vasp) { Comment = message.Comment, }; return(obj); }
public void FillTransactionData(Transaction transaction, TransferRequestMessage message) { if (message.Originator.PostalAddress != null) { transaction.OriginatorPostalAddress = new PostalAddress { Street = message.Originator.PostalAddress.StreetName, AddressLine = message.Originator.PostalAddress.AddressLine, Building = message.Originator.PostalAddress.BuildingNumber, Country = message.Originator.PostalAddress.Country, PostCode = message.Originator.PostalAddress.PostCode, Town = message.Originator.PostalAddress.TownName }; } if (message.Originator.PlaceOfBirth != null) { transaction.OriginatorPlaceOfBirth = new PlaceOfBirth { Country = message.Originator.PlaceOfBirth.CountryOfBirth, Date = message.Originator.PlaceOfBirth.DateOfBirth, Town = message.Originator.PlaceOfBirth.CityOfBirth }; } transaction.OriginatorJuridicalPersonIds = message.Originator.JuridicalPersonId?.Select( x => new JuridicalPersonId(x.Identifier, x.IdentificationType, x.IssuingCountry, x.NonStateIssuer)) .ToArray(); transaction.OriginatorNaturalPersonIds = message.Originator.NaturalPersonId?.Select( x => new NaturalPersonId(x.Identifier, x.IdentificationType, x.IssuingCountry, x.NonStateIssuer)) .ToArray(); transaction.OriginatorBic = message.Originator.BIC; transaction.Amount = message.Transfer.Amount; transaction.Asset = message.Transfer.VirtualAssetType; transaction.BeneficiaryVaan = message.Beneficiary.VAAN.Replace(" ", ""); transaction.OriginatorVaan = message.Originator.VAAN.Replace(" ", ""); transaction.OriginatorFullName = message.Originator.Name; transaction.BeneficiaryFullName = message.Beneficiary.Name; }
public async Task TransferRequestAsync(TransferInstruction instruction) { var transferRequest = new TransferRequestMessage( this.SessionId, _originator, new Beneficiary(instruction.BeneficiaryName ?? string.Empty, _beneficiaryVaan.Vaan), new TransferRequest( instruction.VirtualAssetTransfer.VirtualAssetType, instruction.VirtualAssetTransfer.TransferType, instruction.VirtualAssetTransfer.TransferAmount), _vaspInfo ); await _transportClient.SendAsync(new MessageEnvelope() { Topic = this.CounterPartyTopic, SigningKey = _privateSigningKey, EncryptionType = EncryptionType.Symmetric, EncryptionKey = _sharedSymKeyId }, transferRequest); }
private static void AssertTransferRequest(TransferRequestMessage response, TransferRequestMessage request) { Assert.NotNull(response); Assert.Equal(request.Comment, response.Comment); Assert.Equal(request.Message.SessionId, response.Message.SessionId); Assert.Equal(request.MessageType, response.MessageType); Assert.Equal(request.Message.MessageCode, response.Message.MessageCode); Assert.Equal(request.Message.MessageId, response.Message.MessageId); AssertPlaceOfBirth(request.VASP.PlaceOfBirth, response.VASP.PlaceOfBirth); Assert.Equal(request.VASP.BIC, response.VASP.BIC); Assert.Equal(request.VASP.Name, response.VASP.Name); Assert.Equal(request.VASP.VaspPublickKey, response.VASP.VaspPublickKey); Assert.Equal(request.VASP.VaspIdentity, response.VASP.VaspIdentity); Assert.Equal(request.VASP.PostalAddress.StreetName, response.VASP.PostalAddress.StreetName); Assert.Equal(request.VASP.PostalAddress.AddressLine, response.VASP.PostalAddress.AddressLine); Assert.Equal(request.VASP.PostalAddress.BuildingNumber, response.VASP.PostalAddress.BuildingNumber); Assert.Equal(request.VASP.PostalAddress.Country, response.VASP.PostalAddress.Country); Assert.Equal(request.VASP.PostalAddress.PostCode, response.VASP.PostalAddress.PostCode); Assert.Equal(request.VASP.JuridicalPersonIds.Count(), response.VASP.JuridicalPersonIds.Count()); AssertJuridicalPersonIds(request.VASP.JuridicalPersonIds, response.VASP.JuridicalPersonIds); Assert.Equal(request.VASP.NaturalPersonIds.Count(), response.VASP.NaturalPersonIds.Count()); AssertNaturalPersonIds(request.VASP.NaturalPersonIds, response.VASP.NaturalPersonIds); Assert.Equal(request.Transfer.TransferType, response.Transfer.TransferType); Assert.Equal(request.Transfer.VirtualAssetType, response.Transfer.VirtualAssetType); Assert.Equal(request.Transfer.Amount, response.Transfer.Amount); AssertBeneficiary(request.Beneficiary, response.Beneficiary); AssertOriginator(request.Originator, response.Originator); }
public Task TransferRequestMessageReceivedAsync(string sessionId, TransferRequestMessage message) { var transaction = new Core.Models.Transaction { Status = TransactionStatus.TransferRequested, OriginatorPostalAddress = new Core.Models.PostalAddress { Street = message.Originator.PostalAddress.StreetName, AddressLine = message.Originator.PostalAddress.AddressLine, Building = message.Originator.PostalAddress.BuildingNumber, Country = message.Originator.PostalAddress.Country, PostCode = message.Originator.PostalAddress.PostCode, Town = message.Originator.PostalAddress.TownName }, OriginatorPlaceOfBirth = new Core.Models.PlaceOfBirth { Country = message.Originator.PlaceOfBirth.CountryOfBirth, Date = message.Originator.PlaceOfBirth.DateOfBirth, Town = message.Originator.PlaceOfBirth.CityOfBirth }, Amount = decimal.Parse(message.Transfer.Amount), Asset = message.Transfer.VirtualAssetType, Id = Guid.NewGuid().ToString(), CreationDateTime = DateTime.UtcNow, BeneficiaryVaan = message.Beneficiary.VAAN.Replace(" ", ""), OriginatorVaan = message.Originator.VAAN.Replace(" ", ""), OriginatorFullName = message.Originator.Name, BeneficiaryFullName = message.Beneficiary.Name, SessionId = sessionId }; lock (_outgoingTransactions) { _incomingTransactions.Add(transaction); } return(Task.CompletedTask); }
public async Task <bool> SendAndManageTransferRequest( string localDstPath, DateTimeRange timeRange, string[] fullCategories, bool zipLocal) { if (zipLocal && !localDstPath.EndsWith(".zip")) { localDstPath += ".zip"; } // create and send request var request = new TransferRequestMessage(timeRange, fullCategories); var response = await SendRequestAwaitResponse(request); // process response if (response.ResCode == ResponseCode.Ok) { if (zipLocal && File.Exists(localDstPath)) { File.Delete(localDstPath); } else if (Directory.Exists(localDstPath)) { Directory.Delete(localDstPath); } new FileOperationProgressForm( new TransferOperationUpdateReceiver(client, localDstPath, zipLocal)) .ShowDialog(); return(true); } else if (response.ResCode == ResponseCode.Error) { MessageBox.Show("Your request was rejected by the server.\n" + "Reason: " + response.ErrorMessage, "Request Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); }
private static TransferRequestMessage GetTransferRequestMessage() { //Should be a contract var vaspKey = EthECKey.GenerateKey(); var message = new Message( Guid.NewGuid().ToByteArray().ToHex(prefix: false), Guid.NewGuid().ToByteArray().ToHex(prefix: false), "1"); var postalAddress = new PostalAddress( "TestingStreet", 61, "Test Address Line", "410000", "TownN", Country.List["DE"] ); var placeOfBirth = new PlaceOfBirth(DateTime.UtcNow, "TownN", Country.List["DE"]); var vaspInformation = new VaspInformation( "Test test", vaspKey.GetPublicAddress(), vaspKey.GetPubKey().ToHex(prefix: false), postalAddress, placeOfBirth, new NaturalPersonId[] { new NaturalPersonId("SomeId2", NaturalIdentificationType.AlienRegistrationNumber, Country.List["DE"]), }, new JuridicalPersonId[] { new JuridicalPersonId("SomeId1", JuridicalIdentificationType.BankPartyIdentification, Country.List["DE"]), }, "DEUTDEFF"); var originator = new Originator("Originator1", "VaaN", postalAddress, placeOfBirth, new NaturalPersonId[] { new NaturalPersonId("SomeId2", NaturalIdentificationType.AlienRegistrationNumber, Country.List["DE"]), }, new JuridicalPersonId[] { new JuridicalPersonId("SomeId1", JuridicalIdentificationType.BankPartyIdentification, Country.List["DE"]), }, "DEUTDEFF"); var beneficiary = new Beneficiary("Ben1", "VaaN"); var transferRequest = new TransferRequest(VirtualAssetType.ETH, TransferType.BlockchainTransfer, "10000000"); var request = new TransferRequestMessage(message, originator, beneficiary, transferRequest, vaspInformation) { Comment = "This is test message", }; return(request); }
Task <TransferReplyMessage> IVaspMessageHandler.TransferRequestHandlerAsync(TransferRequestMessage request, VaspSession vaspSession) { return(_transferRequest.Invoke(request, vaspSession)); }
public void MergeFrom(ProtoMessageWrapper other) { if (other == null) { return; } if (other.Signature.Length != 0) { Signature = other.Signature; } switch (other.MsgCase) { case MsgOneofCase.SessionRequestMessage: if (SessionRequestMessage == null) { SessionRequestMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoSessionRequestMessage(); } SessionRequestMessage.MergeFrom(other.SessionRequestMessage); break; case MsgOneofCase.SessionReplyMessage: if (SessionReplyMessage == null) { SessionReplyMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoSessionReplyMessage(); } SessionReplyMessage.MergeFrom(other.SessionReplyMessage); break; case MsgOneofCase.TransferRequestMessage: if (TransferRequestMessage == null) { TransferRequestMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTransferRequestMessage(); } TransferRequestMessage.MergeFrom(other.TransferRequestMessage); break; case MsgOneofCase.TransferReplyMessage: if (TransferReplyMessage == null) { TransferReplyMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTransferReplyMessage(); } TransferReplyMessage.MergeFrom(other.TransferReplyMessage); break; case MsgOneofCase.TransferDispatchMessage: if (TransferDispatchMessage == null) { TransferDispatchMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTransferDispatchMessage(); } TransferDispatchMessage.MergeFrom(other.TransferDispatchMessage); break; case MsgOneofCase.TransaferConfirmationMessage: if (TransaferConfirmationMessage == null) { TransaferConfirmationMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTransferConfirmationMessage(); } TransaferConfirmationMessage.MergeFrom(other.TransaferConfirmationMessage); break; case MsgOneofCase.TerminationMessage: if (TerminationMessage == null) { TerminationMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTerminationMessage(); } TerminationMessage.MergeFrom(other.TerminationMessage); break; case MsgOneofCase.ReservedField: ReservedField = other.ReservedField; break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }