Пример #1
0
        public IActionResult Signature([FromBody] SignatureModel model)
        {
            if (!ModelState.IsValid)
            {
                ApiData.code = 1005;
                ApiData.msg  = ModelState.GetErrMsg();
                return(Ok(ApiData));
            }
            var settings = _settingService.GetMasterSettings();

            if (String.IsNullOrEmpty(settings.OSSAccessKeyId) || String.IsNullOrEmpty(settings.OSSAccessKeyId))
            {
                ApiData.code = 2001;
                ApiData.msg  = "暂未开放上传操作";
                return(Ok(ApiData));
            }
            if (!settings.OSSAccessKeyId.Equals(model.AccessKeyId, StringComparison.InvariantCultureIgnoreCase))
            {
                ApiData.code = 2001;
                ApiData.msg  = "AccessKeyId错误";
                return(Ok(ApiData));
            }
            var signatureString = EncryptorHelper.HmacSha1(settings.OSSAccessKeySecret, $"{model.VERB}{model.ContentMD5}");

            ApiData.code = 0;
            ApiData.msg  = "获取成功";
            ApiData.data = new { Signature = signatureString };
            return(Ok(ApiData));
        }
Пример #2
0
        /// <summary>
        /// PackingCygests the post signature.
        /// </summary>
        /// <param name="signature">The signature.</param>
        /// <returns></returns>
        public async Task <bool> PackingCygestPostSignature(SignatureModel signature)
        {
            bool retval = false;

            try
            {
                using (var client = new RestClient(new Uri("https://api-tray.intragest.info/api/")))
                {
                    client.Authenticator = new HttpBasicAuthenticator("astek.tracker", "3B]U/2Z8w7fDce=(");
                    var request = new RestRequest("PackingPostSignature", Method.POST);
                    request.AddJsonBody(signature);

                    var result = await client.Execute <bool>(request);

                    if (result != null)
                    {
                        retval = result.IsSuccess;
                    }
                }
            }
            catch (Exception e)
            {
                var da = new DatabaseAccessAsync();
                da.InsertException(new PackingCygestExceptionModel
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    TimeSpan   = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture),
                    MethodName = e.Source
                });
            }

            return(retval);
        }
        public async Task <ActionResult> Index(SignatureModel model)
        {
            // Get an instance of the XmlSignatureFinisher class, responsible for completing the signature
            // process.
            var signatureFinisher = new XmlSignatureFinisher(Util.GetRestPkiClient())
            {
                // Set the token for this signature (rendered in a hidden input field, see the view).
                Token = model.Token
            };

            // Call the Finish() method, which finalizes the signature process and returns the signed PDF.
            var signedXml = await signatureFinisher.FinishAsync();

            // Get information about the signer's certificate used. This method must only be called after
            // calling the Finish() method.
            var signerCert = signatureFinisher.GetCertificateInfo();

            // At this point, you'd typically store the signed XML on your database. For demonstration
            // purposes, we'll store the PDF on our mock Storage class.
            var fileId = StorageMock.Store(signedXml, ".xml");

            // Render the signature information page.
            return(View("SignatureInfo", new SignatureInfoModel()
            {
                File = fileId,
                SignerCertificate = signerCert
            }));
        }
Пример #4
0
        public virtual ActionResult IndexCreationSignatures(SignatureModel signature, MessageNotificationCodes messageStatus = MessageNotificationCodes.VoidMessage)
        {
            if (messageStatus != MessageNotificationCodes.VoidMessage)
            {
                MessageConfiguration message = MessageHandler.setMessage(messageStatus, true, 5);
                ViewData["message"] = message;
            }

            return(View());
        }
Пример #5
0
        /// <summary>
        /// The signature information IP and Signature date are signed
        /// </summary>
        /// <param name="signature"></param>
        /// <returns></returns>
        private List <KeyValuePair <string, string> > GetSignature(SignatureModel signature)
        {
            var kvps = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(MappingEnums.IP.ToString().ToUpper(), signature?.IpAddress ?? "N/A"),
                //Format - Wednesday, April 03, 2019 11:58:52 PM
                new KeyValuePair <string, string>(MappingEnums.SignatureDate.ToString().ToUpper(), signature?.CreatedOn.ToString("dddd, MMMM dd, yyyy hh:mm:ss tt") ?? "N/A")
            };

            return(kvps);
        }
Пример #6
0
        public async Task <IActionResult> VerifySign([FromBody] SignatureModel signature)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var rsaParameters = _context.PrivateData.Where(x => x.UserId == signature.UserId).FirstOrDefault().RsaParameters;
            var isValid       = RsaCenter.Verify(signature.Hash, signature.Sign, rsaParameters);

            return(Ok(isValid));
        }
Пример #7
0
        public JsonResult Post([FromBody] object content)
        {
            int    totalRows = 0;
            string exception = "Ok";
            bool   rezult    = true;
            object rows      = new { };

            //UserModel user = new UserModel();

            try
            {
                string vs      = content.ToString();
                var    options = new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                    WriteIndented        = true
                };
                SignatureModel task = JsonSerializer.Deserialize <SignatureModel>(vs, options);
                rows = dbSetSignature(task, ref totalRows);
            }
            catch (TokenExpiredException ex)
            {
                rezult    = false;
                exception = ex.Message;
                GIxUtils.Log(ex);
            }
            catch (SignatureVerificationException ex)
            {
                rezult    = false;
                exception = ex.Message;
                GIxUtils.Log(ex);
            }
            catch (Exception ex)
            {
                rezult    = false;
                exception = ex.Message;
                Console.WriteLine(ex.Message);
                rows = new
                {
                    message = exception
                };
                GIxUtils.Log(ex);
            }

            return(new JsonResult(new
            {
                success = rezult,
                message = exception,
                code = 0,
                total = 0,
                data = rows
            }));
        }
Пример #8
0
        public static void MapFromModel(this Signature entity, SignatureModel model)
        {
            entity.SignatureId = model.SignatureId;
            entity.IpAddress   = model.IpAddress;
            entity.Type        = model.Type;
            entity.CreatedOn   = model.CreatedOn;
            entity.ModifiedOn  = model.ModifiedOn;

            var base64Data     = Regex.Match(model.Content, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value;
            var signatureBytes = Convert.FromBase64String(base64Data);

            entity.Content = signatureBytes;
        }
Пример #9
0
        public virtual ActionResult IndexUpdateSignaturesUser(SignatureModel signature, HttpPostedFileBase file)
        {
            var messageStatus = MessageNotificationCodes.SaveDataSucessfully;

            bool updated = false;

            var    filename    = Path.GetFileName(file.FileName);
            var    criteria    = DoccumentObject.Criteria(DoccumentObject.SIGNATURE, filename, string.Empty, string.Empty, string.Empty);
            string trusteeList = DoccumentObject.TrusteeList(DoccumentObject.SIGNATURE);

            byte[] fileStream = new byte[file.ContentLength];
            file.InputStream.Read(fileStream, 0, fileStream.Length);

            try
            {
                var request = new UploadDocumentRequest
                {
                    AccessInformation = AccessInformationCategoryEnum.CONFIDENTIAL,
                    FileName          = file.FileName,
                    FileStream        = fileStream,
                    OperationNumber   = IDBContext.Current.Operation,
                    BusinessAreaCode  = BusinessAreaCodeEnum.BA_SIGNATURES,
                    TrusteeList       = trusteeList
                };

                var createDocument = _documentManagementService.Upload(request);
                if (createDocument.IsValid)
                {
                    signature.DocumentReference = createDocument.DocumentNumber;
                    updated = Signatures.UpdateSignatureByUserSignatureId(signature);

                    if (!updated)
                    {
                        messageStatus = MessageNotificationCodes.SaveDataFail;
                    }
                }
                else
                {
                    messageStatus = MessageNotificationCodes.SaveDataFail;
                }

                return(RedirectToAction("IndexSignatures", new { messageStatus = messageStatus }));
            }
            catch (Exception)
            {
                messageStatus = MessageNotificationCodes.SaveDataFail;
            }

            return(RedirectToAction("IndexSignatures", new { messageStatus = messageStatus }));
        }
Пример #10
0
        public ActionResult Get(SignatureModel signatureModel)
        {
            signatureModel.Token = _options.Get("WXOptions").Token;
            string rtnStr;

            if (SignatureHelper.Check(signatureModel))
            {
                rtnStr = signatureModel.Echostr;
            }
            else
            {
                rtnStr = signatureModel.Signature + signatureModel.Timestamp + signatureModel.Nonce + signatureModel.Echostr;
            }
            return(Content(rtnStr));
        }
        public async Task <IHttpActionResult> Get()
        {
            try
            {
                IQueryable <Signature> signatures = await Task.FromResult(_signatureRepository.GetAll());

                return(new HttpJsonApiResult <IEnumerable <SignatureModel> >(
                           SignatureModel.GetAll(signatures), Request, HttpStatusCode.OK));
            }
            catch (Exception)
            {
                return(new HttpJsonApiResult <string>(
                           "Internal Server Error", Request, HttpStatusCode.InternalServerError));
            }
        }
Пример #12
0
        public static SignatureModel GetJsSignMap(string jsapiTicket, string url)
        {
            var ticks     = (DateTime.Now.Ticks - new DateTime(1970, 1, 1).Ticks) / 10000000;
            var map       = new SignatureModel();
            var nonceStr  = Guid.NewGuid().ToString().Replace("-", "");
            var timestamp = ticks.ToString();
            var sign      = "jsapi_ticket=" + jsapiTicket + "&noncestr=" + nonceStr + "&timestamp=" + timestamp + "&url=" + url;
            var signature = CommonHelper.Md5Hash(sign);

            map.url          = url;
            map.jsapi_ticket = jsapiTicket;
            map.nonceStr     = nonceStr;
            map.timestamp    = timestamp;
            map.signature    = signature;
            return(map);
        }
Пример #13
0
        public ActionResult Post(int intakeFormId, [FromBody] SignatureModel signature)
        {
            try
            {
                // set the client ip address
                signature.IpAddress = _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString();

                var signatureId = _business.Create(intakeFormId, signature);

                return(CreatedAtAction("Post", new { signatureId }));
            }
            catch (Exception ex)
            {
                _logging.Log(LogSeverity.Error, ex.ToString());
                throw;
            }
        }
Пример #14
0
        public async Task <List <SignatureModel> > GetForSignature(CurrentUser user)
        {
            IRepository <User> userRepository = _storage.GetRepository <User>();
            List <Signature>   signatures     = await _signatureRepository.GetList(x => x.UserSignatures.Any(z => z.UserId == user.Id && z.SignatureHash == null));

            ConcurrentQueue <SignatureModel> result = new ConcurrentQueue <SignatureModel>();

            Parallel.ForEach(signatures, s =>
            {
                SignatureModel signViewModel = _mapper.Map <Signature, SignatureModel>(s);
                User current = userRepository.Get(z => z.Id == s.AuthorId).GetAwaiter().GetResult();
                signViewModel.AuthorEmail    = current.Email;
                signViewModel.AuthorFullName = current.FullName;
                signViewModel.ImageId        = current.ImageId;
                signViewModel.FileName       = _filesRepository.GetName(signViewModel.FileId).GetAwaiter().GetResult();
                result.Enqueue(signViewModel);
            });
            return(result.ToList());
        }
Пример #15
0
        protected static Signature CreateSignature(bool firstSignature = true)
        {
            var signatureModel = new SignatureModel
            {
                IpAddress = "123.123.32.192",
                CreatedOn = DateTime.Now,
                Content   = firstSignature
                    ? "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2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L3GX9TJ4eCqqtxuLVvhN/ej38wNCCrxOds8p7lOTp3EfioVOEk+vxLQAAAAAAAAAARMlkbbF2kri6nuxXBJc5PsS62B9yN/b42znc3M92EeS65PqS7ymwVrXyV283kY6SktLWl1U4dvizhZY662gvIZLLxdO1g9be16tO1/rj4GpS0Wi5AfTI7T1K2J2hssxCi50FT6Oe6uvjzfg+Hga48yjGcXGUVKL5prVMDG3e2le7fs+HsqnSy+GclvS/0rX6nvFbITuJq8zlWdSrJ7zo72v+p/gjW0qFKitKVKFNdkYpHQDlQt6NtSVOhShSguUYR0R6qU4VYOFSEZxfNSWqPYArIbP4qneQuqdnCFaD1i4NpJ+C4FmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUW0uItLmzq3rg6d1Rjvxq03uy4dvaQti81eZLpre7mqioxTjNr3n4vrAA1QAAAAAAAImTuJ2mNuLimk506cpLe5apGY2YpLaG5rZHKN16tCSjTg9NyOvH4QANifQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//Z",
                ModifiedOn = DateTime.Now,
                Type       = firstSignature
                ? Constants.Enums.SignatureType.PrescriptionDocument
                : Constants.Enums.SignatureType.IntakeDocument
            };
            var signature = new Signature();

            //Testing the mapper to ensure the data:image/jpeg;base64, gets stripped before being stored
            signature.MapFromModel(signatureModel);
            return(signature);
        }
Пример #16
0
        public int Create(int intakeFormId, SignatureModel signatureModel)
        {
            IntakeForm intakeForm = _context.IntakeForm
                                    .Include(i => i.Signatures)
                                    .First(u => u.IntakeFormId == intakeFormId);

            var sig = new Signature();

            sig.MapFromModel(signatureModel);

            if (intakeForm.Signatures == null)
            {
                intakeForm.Signatures = new List <Signature>();
            }

            intakeForm.Signatures.Add(sig);

            _context.SaveChanges();

            return(sig.SignatureId);
        }
        public async Task <ActionResult> Index(SignatureModel model)
        {
            // Get an instance of the PadesSignatureFinisher2 class, responsible for completing the
            // signature process.
            var signatureFinisher = new PadesSignatureFinisher2(Util.GetRestPkiClient())
            {
                // Set the token for this signature. (rendered in a hidden input field, see the view)
                Token = model.Token
            };

            // Call the Finish() method, which finalizes the signature process and returns a
            // SignatureResult object.
            var result = await signatureFinisher.FinishAsync();

            // The "Certificate" property of the SignatureResult object contains information about the
            // certificate used by the user to sign the file.
            var signerCert = result.Certificate;

            // At this point, you'd typically store the signed PDF on your database. For demonstration
            // purposes, we'll store the PDF on our mock Storage class.

            // The SignatureResult object has various methods for writing the signature file to a stream
            // (WriteTo()), local file (WriteToFile()), open a stream to read the content (OpenRead()) and
            // get its contents (GetContent()). For large files, avoid the method GetContent() to avoid
            // memory allocation issues.
            string fileId;

            using (var resultStream = result.OpenRead()) {
                fileId = StorageMock.Store(resultStream, ".pdf");
            }

            // Render the signature information page.
            return(View("SignatureInfo", new SignatureInfoModel()
            {
                File = fileId,
                SignerCertificate = signerCert
            }));
        }
Пример #18
0
        public virtual ActionResult DeleteSignatureByUser(SignatureModel signature)
        {
            var  messageStatus = MessageNotificationCodes.DeleteDataSucessfully;
            bool deleted       = false;

            try
            {
                deleted = Signatures.DeleteSignatureByUserSignatureId(signature.UserSignatureId);

                if (!deleted)
                {
                    messageStatus = MessageNotificationCodes.DeleteDataFail;
                }

                return(RedirectToAction("IndexSignatures", new { messageStatus = messageStatus }));
            }
            catch (Exception)
            {
                messageStatus = MessageNotificationCodes.DeleteDataFail;
            }

            return(RedirectToAction("IndexSignatures", new { messageStatus = messageStatus }));
        }
Пример #19
0
 public ApprovalModel()
 {
     Signature = new SignatureModel();
     Status    = 1; // Initially set as open
 }
Пример #20
0
        private dynamic dbSetSignature(SignatureModel task, ref int totalRecordCount)
        {
            bool   initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false;
            string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString();
            string localIP  = this.HttpContext.Connection.LocalIpAddress.ToString();

            SignatureModel model = new SignatureModel();

            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(
                           GIxUtils.DecodeConnectionString(
                               _configuration,
                               ref _loginRequest,
                               Request.Headers["X-WebGI-Authentication"],
                               Request.Headers["X-WebGI-Version"])))
                {
                    sqlConnection.Open();
                    using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
                    {
                        sqlCommand.Connection  = sqlConnection;
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlCommand.CommandText = "dbo.[usp_WebGI_SetSignature]";
                        //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey);
                        sqlCommand.Parameters.AddWithValue("@IP_Local", localIP);
                        sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP);
                        sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid);
                        sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt);
                        sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version);

                        sqlCommand.Parameters.AddWithValue("@SignatureId", task.SignatureId);
                        sqlCommand.Parameters.AddWithValue("@DocTypeId", task.DocTypeId);
                        sqlCommand.Parameters.AddWithValue("@ProjectId", task.ProjectId);
                        sqlCommand.Parameters.AddWithValue("@PositionId", task.PositionId);
                        sqlCommand.Parameters.AddWithValue("@Level", task.Level);
                        sqlCommand.Parameters.AddWithValue("@MinAmount", task.MinAmount);
                        sqlCommand.Parameters.AddWithValue("@MaxAmount", task.MaxAmount);

                        SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int);
                        outputValue.Direction = ParameterDirection.Output;

                        SqlDataReader recordSet = sqlCommand.ExecuteReader();
                        using (recordSet)
                        {
                            object value;
                            if (recordSet.Read())
                            {
                                if ((value = recordSet[recordSet.GetOrdinal("SignatureId")]) != System.DBNull.Value)
                                {
                                    model.SignatureId = (int)value;
                                }
                            }
                            recordSet.Close();
                            recordSet.Dispose();

                            if (outputValue.Value != null)
                            {
                                totalRecordCount = (int)outputValue.Value;
                            }
                        }
                    }

                    sqlConnection.Close();
                    sqlConnection.Dispose();
                }
            }

            catch (Exception ex)
            {
                GIxUtils.Log(ex);
                throw new Exception(ex.Message);
            }

            return(model);
        }
Пример #21
0
        public static SignatureModel GetSignature(string access_token)
        {
            SignatureModel model = null;
            try
            {
                string ticket = GetTicket(access_token);
                if (ticket.IsNullOrEmpty())
                    return null;
                string timestamp = Convert.ToString(ConvertDateTimeInt(DateTime.Now));
                string noncestr = createNonceStr();
                //string signature = "noncestr=" + noncestr + "&jsapi_ticket=" + ticket + "&timestamp=" + timestamp + "&url=" + HttpContext.Current.Request.Url.ToString();
                string rawstring = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + HttpContext.Current.Request.Url.ToString();

                string signature = FormsAuthentication.HashPasswordForStoringInConfigFile(rawstring, "SHA1");//SHA1_Hash(rawstring);

                System.Collections.Hashtable signPackage = new System.Collections.Hashtable();
                signPackage.Add("appId", ConfigurationManager.AppSettings["OAuthAppID"]);
                signPackage.Add("nonceStr", noncestr);
                signPackage.Add("timestamp", timestamp);
                signPackage.Add("url", HttpContext.Current.Request.Url.ToString());
                signPackage.Add("signature", signature);
                signPackage.Add("rawString", rawstring);
                model = new SignatureModel() { Timestamp = timestamp, Noncestr = noncestr, Signature = signature, Ticket = ticket };
                //if (HttpContext.Current.Session[JSAPI_SIGNATURE] == null)
                //{
                //    string ticket = GetTicket(access_token);
                //    if (ticket.IsNullOrEmpty())
                //        return null;
                //    string timestamp = Convert.ToString(ConvertDateTimeInt(DateTime.Now));
                //    string noncestr = createNonceStr();
                //    //string signature = "noncestr=" + noncestr + "&jsapi_ticket=" + ticket + "&timestamp=" + timestamp + "&url=" + HttpContext.Current.Request.Url.ToString();
                //    string rawstring = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + HttpContext.Current.Request.Url.ToString();

                //    string signature = FormsAuthentication.HashPasswordForStoringInConfigFile(rawstring, "SHA1");//SHA1_Hash(rawstring);

                //    System.Collections.Hashtable signPackage = new System.Collections.Hashtable();
                //    signPackage.Add("appId", ConfigurationManager.AppSettings["OAuthAppID"]);
                //    signPackage.Add("nonceStr", noncestr);
                //    signPackage.Add("timestamp", timestamp);
                //    signPackage.Add("url", HttpContext.Current.Request.Url.ToString());
                //    signPackage.Add("signature", signature);
                //    signPackage.Add("rawString", rawstring);
                //    model = new SignatureModel() { Timestamp = timestamp, Noncestr = noncestr, Signature = signature, Ticket = ticket };
                //    HttpContext.Current.Session[JSAPI_SIGNATURE] = model;
                //}
                //else
                //{
                //    model = HttpContext.Current.Session[JSAPI_SIGNATURE] as SignatureModel;
                //}
            }
            catch (Exception ex)
            {
                Log.Default.Error(ex);
                Log.Default.Debug("微信JSSDK:" + ex);
            }
            return model;
        }
Пример #22
0
        public static SignatureModel GetSignature(string access_token, string OAuthAppID)
        {
            SignatureModel model = null;
            try
            {
                string ticket = GetTicket(access_token);
                if (ticket.IsNullOrEmpty())
                    return null;
                string timestamp = Convert.ToString(ConvertDateTimeInt(DateTime.Now));
                string noncestr = createNonceStr();
                //string signature = "noncestr=" + noncestr + "&jsapi_ticket=" + ticket + "&timestamp=" + timestamp + "&url=" + HttpContext.Current.Request.Url.ToString();
                string rawstring = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + HttpContext.Current.Request.Url.ToString();

                string signature = FormsAuthentication.HashPasswordForStoringInConfigFile(rawstring, "SHA1");//SHA1_Hash(rawstring);

                System.Collections.Hashtable signPackage = new System.Collections.Hashtable();
                signPackage.Add("appId", OAuthAppID);
                signPackage.Add("nonceStr", noncestr);
                signPackage.Add("timestamp", timestamp);
                signPackage.Add("url", HttpContext.Current.Request.Url.ToString());
                signPackage.Add("signature", signature);
                signPackage.Add("rawString", rawstring);
                model = new SignatureModel() { Timestamp = timestamp, Noncestr = noncestr, Signature = signature, Ticket = ticket };
            }
            catch (Exception ex)
            {
            }
            return model;
        }
Пример #23
0
        private dynamic dbGetSignature(ref int totalRecordCount)
        {
            bool   initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false;
            string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString();
            string localIP  = this.HttpContext.Connection.LocalIpAddress.ToString();

            string page        = Request.Query["page"].ToString();
            string start       = Request.Query["start"].ToString();
            string limit       = Request.Query["limit"].ToString();
            string signatureId = Request.Query["SignatureId"];

            SignatureModel model = new SignatureModel();

            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(
                           GIxUtils.DecodeConnectionString(
                               _configuration,
                               ref _loginRequest,
                               Request.Headers["X-WebGI-Authentication"],
                               Request.Headers["X-WebGI-Version"])))
                {
                    sqlConnection.Open();
                    using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
                    {
                        sqlCommand.Connection  = sqlConnection;
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlCommand.CommandText = "dbo.[usp_WebGI_GetSignature]";
                        //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey);
                        sqlCommand.Parameters.AddWithValue("@IP_Local", localIP);
                        sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP);
                        sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid);
                        sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt);
                        sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version);

                        sqlCommand.Parameters.AddWithValue("@SignatureId", signatureId);


                        SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int);
                        outputValue.Direction = ParameterDirection.Output;

                        SqlDataReader recordSet = sqlCommand.ExecuteReader();
                        using (recordSet)
                        {
                            object value;
                            if (recordSet.Read())
                            {
                                var properties = model.GetType().GetProperties();
                                foreach (var el in properties)
                                {
                                    string name = el.Name;
                                    value = recordSet[recordSet.GetOrdinal(name)];

                                    if (value != System.DBNull.Value)
                                    {
                                        switch (el.PropertyType.Name)
                                        {
                                        case "Int32":
                                            el.SetValue(model, (int)value);
                                            break;

                                        case "String":
                                            el.SetValue(model, (string)value);
                                            break;

                                        case "Boolean":
                                            el.SetValue(model, (bool)value);
                                            break;

                                        case "Decimal":
                                            //case "Nullable'1":
                                            el.SetValue(model, (decimal)value);
                                            break;
                                        }
                                    }
                                }
                            }
                            recordSet.Close();
                            recordSet.Dispose();

                            if (outputValue.Value != null)
                            {
                                totalRecordCount = (int)outputValue.Value;
                            }
                        }
                    }

                    sqlConnection.Close();
                    sqlConnection.Dispose();
                }
            }

            catch (Exception ex)
            {
                GIxUtils.Log(ex);
                throw new Exception(ex.Message);
            }

            return(model);
        }
Пример #24
0
        public async Task <IActionResult> SignData(SignatureModel data, int?cades)
        {
            try
            {
                var filePath = Path.GetTempFileName();
                if (data.inputFile.Length > 0)
                {
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        //METODELE DE SEMNARE DIN API
                        await data.inputFile.CopyToAsync(stream);

                        MemoryStream memoryStream = new MemoryStream();
                        await data.inputFile.CopyToAsync(memoryStream);

                        string hash_algorithm = ""; string sign_algorithm = ""; int signature_type;
                        if (data.algorithm == 1)
                        {
                            hash_algorithm = "2.16.840.1.101.3.4.2.1";
                            sign_algorithm = "1.2.840.113549.1.1.11";
                        }
                        else
                        {
                            hash_algorithm = "1.3.14.3.2.26";
                            sign_algorithm = "1.3.14.3.2.29";
                        }
                        if (data.inputFile.ContentType == "application/pdf")
                        {
                            signature_type = 1;
                        }
                        else if (data.inputFile.ContentType == "text/xml")
                        {
                            signature_type = 2;
                        }
                        else
                        {
                            signature_type = 3;
                        }

                        if (cades == 1)
                        {
                            signature_type = 3;
                        }
                        InputSignatureAdvanced inputSignatureAdvanced = new InputSignatureAdvanced()
                        {
                            credentialsID  = data.credentialsID,
                            hashAlgo       = hash_algorithm,
                            signAlgo       = sign_algorithm,
                            OTP            = data.otp,
                            PIN            = data.pin,
                            signatureType  = signature_type,
                            documentStream = memoryStream.GetBuffer()
                        };
                        var            ceva        = Encoding.UTF8.GetBytes(memoryStream.GetBuffer().ToString());
                        JsonSerializer serializer  = new JsonSerializer();
                        ErrorLogger    errorLogger = new ErrorLogger();
                        string         baseURL     = _configuration.GetSection("CSC_API").GetSection("BaseURL").Value;

                        MyHttpClient myHttpClient = new MyHttpClient(serializer, errorLogger, baseURL);
                        var          response     = myHttpClient.PAdES(_accessToken.GetAccessToken().access_token, inputSignatureAdvanced);
                        if (response == null || response.Contains("error"))
                        {
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            //eu primesc byte array
                            OutputAdvancedSignature output = serializer.Deserialize <OutputAdvancedSignature>(response);

                            MemoryStream signedMemory = new MemoryStream(output.signedDocument);

                            signedMemory.Position = 0;
                            if (signature_type == 1)
                            {
                                return(File(signedMemory, "application/pdf", "signed-pdf.pdf"));
                            }
                            else if (signature_type == 2)
                            {
                                return(File(signedMemory, "text/xml", "signed-xml.xml"));
                            }
                            else
                            {
                                return(File(signedMemory, "application/pkcs7-signature", "signed-cms.p7s"));
                            }
                        }
                        //METODELE DE SEMNARE DIN CLIENT

                        // bool flag = false;
                        // MemoryStream memoryxml = new MemoryStream();
                        //if (cades == 1)
                        //{
                        //    MemoryStream memory = new MemoryStream();
                        //    if (data.algorithm == 1)
                        //    {
                        //        //SHA256 RSA
                        //        memory = SBBSignCMS(stream, data.credentialsID, "2.16.840.1.101.3.4.2.1", "1.2.840.113549.1.1.11", data.otp, data.pin);

                        //    }
                        //    else
                        //    {
                        //        //SHA1 RSA
                        //        memory = SBBSignCMS(stream, data.credentialsID, "1.3.14.3.2.26", "1.3.14.3.2.29", data.otp, data.pin);
                        //    }
                        //    if (memory != null)
                        //    {
                        //        memory.Position = 0;
                        //        return File(memory, "application/pkcs7-signature", "test.p7s");
                        //    }
                        //}
                        //else
                        //{
                        //    if (data.inputFile.ContentType == "application/pdf")
                        //    {
                        //        if (data.algorithm == 1)
                        //        {
                        //            //SHA256 RSA
                        //            flag = SBBSignPDF(stream, data.credentialsID, "2.16.840.1.101.3.4.2.1", "1.2.840.113549.1.1.11", data.otp, data.pin);

                        //        }
                        //        else
                        //        {
                        //            //SHA1 RSA
                        //            flag = SBBSignPDF(stream, data.credentialsID, "1.3.14.3.2.26", "1.3.14.3.2.29", data.otp, data.pin);

                        //        }
                        //        stream.Close();
                        //        stream.Dispose();
                        //    }
                        //    else if (data.inputFile.ContentType == "text/xml")
                        //    {
                        //        if (data.algorithm == 1)
                        //        {
                        //            //SHA
                        //            memoryxml = SBBSignXML(stream, data.credentialsID, "2.16.840.1.101.3.4.2.1", "1.2.840.113549.1.1.11", data.otp, data.pin);

                        //        }
                        //        else
                        //        {

                        //            memoryxml = SBBSignXML(stream, data.credentialsID, "1.3.14.3.2.26", "1.3.14.3.2.29", data.otp, data.pin);

                        //        }
                        //    }

                        //    if (flag == true)
                        //    {
                        //        var memory = new MemoryStream();

                        //        using (FileStream signedStrem = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                        //        {
                        //            await signedStrem.CopyToAsync(memory);
                        //        }
                        //        memory.Position = 0;
                        //        return File(memory, "application/pdf", "lorena-signed.pdf");
                        //    }

                        //    if (memoryxml != null)
                        //    {

                        //        memoryxml.Position = 0;
                        //        return File(memoryxml, "text/xml", "lorena-signed.xml");
                        //    }
                        //}
                    }
                }


                else
                {
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex) { return(RedirectToAction("Index")); }
        }
 public SignatureModels GetTicket(SignatureModel model)
 {
     return(Service.AddSignature(model));
 }
Пример #26
0
 public ActionResult Signature(SignatureModel model)
 {
     return(View(model));
 }