Ejemplo n.º 1
0
        private void ValidateSignatureOrFail(FilesPackage filesPackage, string apiKey)
        {
            if (!_packageOptions.Value.ValidateSignature)
            {
                return;
            }

            if (_packageValidator.IsValid(filesPackage.Package.Bytes, filesPackage.Signature.Bytes, apiKey))
            {
                return;
            }

            throw new InvalidOperationException("Invalid package signature.");
        }
Ejemplo n.º 2
0
        private static async Task <FilesPackage> GetFilesPackageAsync(IReadOnlyCollection <IFormFile> files,
                                                                      string signatureExtension)
        {
            var filesPackage = new FilesPackage();

            foreach (var file in files)
            {
                var bytes = await GetBytesAsync(file);

                if (IsSignature(file.FileName, signatureExtension))
                {
                    filesPackage.Signature = new File(file.FileName, bytes);
                }
                else
                {
                    filesPackage.Package = new File(file.FileName, bytes);
                }
            }

            return(filesPackage);
        }