private mvc.ActionResult CreateForm(ProxyAuthRequestResult req, Guid instanceId) { var jArgs = (JObject)JsonConvert.DeserializeObject(req.Arguments); SvcBldr.Token = req.Token; return(CreateDocumentAndRedirect(req, jArgs, instanceId)); }
private mvc.ActionResult CreateDocumentAndRedirect(ProxyAuthRequestResult req, JObject jArgs, Guid instanceId) { var fSvc = SvcBldr.FormsV2(); var cdsr = fSvc.CreateDocument(new FormDocumentCreateArgs { IsTemporary = true, FormTemplateId = new Guid(jArgs["FormTemplateId"].Value <string>()) //Convert failure when .Value<Guid> is used. }); ExceptionsML.Check(cdsr.Error); var vrId = Functions.NewSeq(); jArgs["DocumentVersionId"] = cdsr.Result.Version.Id; jArgs["FormRequestId"] = req.Id; jArgs["ViewRequestId"] = vrId; jArgs["UseRecaptcha"] = false; ExceptionsML.Check(cdsr.Error); var secSvc = SvcBldr.SecurityV2(); var viewerCPR = new ProxyAuthRequest { Id = vrId, ExpirationType = ExpirationMode.CustomCount, ExpirationValue = "1", //Expires as soon as the form is submitted. RequestType = ProxyAuthRequestType.AccessViewer, Token = req.Token, Parameters = JsonConvert.SerializeObject(jArgs) }; var cprSR = secSvc.CreateProxyRequest(viewerCPR); ExceptionsML.Check(cprSR.Error); var fsc = GuestSessionCookie.Create(Response, cprSR.Result, instanceId, req.Id); return(RedirectToAction("Index", fsc)); }
internal void Load(string baseUri, ProxyAuthRequestResult par) { _svcBldr.Token = par.Token; EncryptedToken = par.Token; Options = par.Arguments; var svc = _svcBldr.BulkDataV2(); var sr = svc.GetBulkGuestData(); ExceptionsML.Check(sr.Error); var result = sr.Result; BulkData = JsonConvert.SerializeObject(sr); if (result.LicenseTokens != null) { Licenses = new List <TokenKey>((result.LicenseTokens)); } User = result.CurrentUser; CurrentUser = JsonConvert.SerializeObject(new { Name = result.CurrentUser.Username, Id = result.CurrentUser.Id }); CompanyName = result.CompanyName; HttpRuntimeSection httpRuntimeSection = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection; MaxRequestLength = httpRuntimeSection.MaxRequestLength; IsReadOnlyUser = result.CurrentUser.ReadOnlyUser; Version = Functions.GetVersion(); SystemPreferences = JsonConvert.SerializeObject(result.CompanySettings); var views = GetCachedViews(baseUri); CommonTemplates = JsonConvert.SerializeObject(views); }
private static void ValidateRecaptcha(ProxyAuthRequestResult par, GuestChallengeModel model, HttpRequestBase request) { var recapResponse = request.Form["g-recaptcha-response"]; JObject args = null; if (!String.IsNullOrEmpty(par.Arguments)) { args = (JObject)JsonConvert.DeserializeObject(par.Arguments); } var useRecaptcha = false; if (args != null && args["UseRecaptcha"] != null && bool.TryParse(args["UseRecaptcha"].Value <string>(), out useRecaptcha) && useRecaptcha) { if (String.IsNullOrWhiteSpace(recapResponse)) { model.ShowRecaptcha = GoogleReCaptcha.CanAccess(); } else { var gr = new GoogleReCaptcha(); if (!gr.IsValid(recapResponse, request.UserHostAddress)) { model.ErrorMessages.Add(Constants.i18n("invalidRecaptcha")); model.ShowRecaptcha = GoogleReCaptcha.CanAccess(); } } } }
private static void ValidatePasswordFillModelProxyRequest(ProxyAuthRequestResult par, GuestChallengeModel model, HttpRequestBase request, ServiceBuilder svcBldr) { var pass = request.Form["password"]; var svc = svcBldr.SecurityV2(); if (par.HasPassword && !String.IsNullOrWhiteSpace(pass)) //Has a password and one has been provided by the user { var pwSR = svc.GetProxyRequest(new GetProxyRequestArgs { Id = par.Id, InstanceId = par.InstanceId, Password = pass }); if (pwSR.Error != null) { model.ErrorMessages.Add(pwSR.Error.Message); model.ShowPassword = true; } else { model.ProxyRequest = pwSR.Result; } } else if (!par.HasPassword && !model.ShowRecaptcha) //Does not have a password and is not showing the recaptcha, get the full ProxyAuthRequest (decrements counts, returns a restricted token). { var prSR = svc.GetProxyRequest(new GetProxyRequestArgs { Id = par.Id, InstanceId = par.InstanceId, Password = pass }); if (prSR.Error != null) { if (prSR.Error.Type == typeof(ProxyAuthRequestExpiredException).ToString()) { switch (par.RequestType) { case ProxyAuthRequestType.DownloadFiles: throw new Exception(Constants.i18n("downloadFilesProxyRequestExpired")); case ProxyAuthRequestType.AccessViewer: throw new Exception(Constants.i18n("accessViewerProxyRequestExpired")); case ProxyAuthRequestType.CreateForm: throw new Exception(Constants.i18n("createFormProxyRequestExpired")); default: ExceptionsML.Check(prSR.Error); break; } } ExceptionsML.Check(prSR.Error); } model.ProxyRequest = prSR.Result; } else //Has a password and it has not been filled out yet or is showing recaptcha { model.ProxyRequest = par; model.ShowPassword = par.HasPassword; } }
private mvc.ActionResult DownloadFiles(ProxyAuthRequestResult request, string connectionId) { try { BaseToken = request.Token; var ip = GetIP(); var server = GetServerURI(); var sb = new ServiceBuilder(server, request.Token, ip); sb.Options = ServiceRequestOptions.OverrideErrors; var docClient = sb.DocumentV2(); var documentIds = new List <Guid>(); SendOptions sendOptions = new SendOptions { ActionType = ActionType.Downloaded, ExportType = ExportDocumentType.Native, IncludeAnnotations = true, IncludeRedactions = true, PageSelection = null, Password = null }; var parameters = new ProxySendOptions { DocumentIds = null, SendOptions = null }; if (request.Arguments.StartsWith("{")) { parameters = JsonConvert.DeserializeObject <ProxySendOptions>(request.Arguments); } else if (request.Arguments.StartsWith("<?xml version=\"1.0\" encoding=\"utf-16\"?><ProxySendOptions")) { parameters = (ProxySendOptions)parameters.DeserializeObject(request.Arguments); } else { documentIds = (List <Guid>)documentIds.DeserializeObject(request.Arguments); } documentIds = parameters.DocumentIds ?? documentIds; sendOptions = parameters.SendOptions ?? sendOptions; sendOptions.ConnectionId = connectionId; sendOptions.ActionType = ActionType.Downloaded; //Downloading here so the action type is always download. var sr = docClient.PrepForSend(new Framework.DataContracts.V2.PrepForSendPackage { DocumentIds = documentIds.ToArray(), SendOptions = sendOptions }); if (sr.Error != null) { return(View("../Home/Oops", sr.Error)); } if (sr.Result == Constants.GONE_OOP) { return(new mvc.EmptyResult()); } else { var fileName = Path.GetFileName(sr.Result); var mimeType = sr.Result.GetMIMEType(); var ftSvc = sb.FileTransferV2(); var bytes = RemoteFileHandler.DownloadFile(sr.Result, ftSvc); return(File(bytes, mimeType, fileName)); } } catch (Exception ex) { return(Result(null, ExceptionsML.GetExceptionML(ex), mvc.JsonRequestBehavior.AllowGet)); } }