Example #1
0
        private static async Task <SendingProcessingMode> AssembleSendingPMode(EncodeMessageInfo encodeInfo)
        {
            var pmode = await Deserializer.ToSendingPMode(encodeInfo.SendingPMode);

            if (pmode == null)
            {
                return(null);
            }

            if (pmode.Security?.Signing?.IsEnabled ?? false)
            {
                pmode.Security.Signing.SigningCertificateInformation = new PrivateKeyCertificate
                {
                    Certificate = Convert.ToBase64String(encodeInfo.SigningCertificate ?? new byte[] { }),
                    Password    = encodeInfo.SigningCertificatePassword
                };
            }

            if (pmode.Security?.Encryption?.IsEnabled ?? false)
            {
                pmode.Security.Encryption.EncryptionCertificateInformation = new PublicKeyCertificate
                {
                    Certificate = Convert.ToBase64String(encodeInfo.EncryptionPublicKeyCertificate ?? new byte[] { })
                };
            }

            return(pmode);
        }
        public async Task <IHttpActionResult> Post([FromBody] EncodeMessageInfo encodeInformation)
        {
            if (encodeInformation == null)
            {
                return(BadRequest());
            }

            if (encodeInformation.SendingPMode == null)
            {
                return(BadRequest());
            }

            encodeInformation.SigningCertificatePassword = CertificateInfoRetriever.RetrieveCertificatePassword(this.Request).SigningPassword;

            var service = new EncodeService();

            var result = await service.CreateAS4Message(encodeInformation);

            if (result == null)
            {
                return(BadRequest());
            }

            if (result.Exception != null)
            {
                return(InternalServerError(result.Exception));
            }

            return(Ok(CreateEncodeResultFromContext(result)));
        }
Example #3
0
        internal async Task <MessagingContext> CreateAS4Message(EncodeMessageInfo encodeInfo)
        {
            var pmode = await AssembleSendingPMode(encodeInfo);

            if (pmode == null)
            {
                return(null);
            }

            var as4Message = await AssembleAS4MessageAsync(pmode, encodeInfo.Payloads);

            var context = SetupMessagingContext(as4Message, pmode);

            return(await StepProcessor.ExecuteStepsAsync(context, StepRegistry.GetOutboundProcessingStepConfiguration()));
        }