示例#1
0
        //[Test]
        public void QATest()
        {
            _addressSvc.Configuration.Url = "http://qa.avalara.com/avatax.services";

            PingResult pingResult = _addressSvc.Ping("");

            Assert.IsTrue(pingResult.Version.StartsWith("4.0."));
            Assert.AreEqual(SeverityLevel.Success, pingResult.ResultCode);

            Address address = new Address();

            address.Line1      = "900 Winslow Way";
            address.Line2      = "Ste 130";
            address.City       = "Bainbridge Island";
            address.Region     = "WA";
            address.PostalCode = "98110";

            ValidateRequest validateRequest = new ValidateRequest();

            validateRequest.Address  = address;
            validateRequest.TextCase = TextCase.Upper;

            ValidateResult result = _addressSvc.Validate(validateRequest);

            Assert.AreEqual(SeverityLevel.Success, result.ResultCode);
        }
示例#2
0
        public async Task <string[]> ExecuteAsync(
            ValidateRequest <TModel> request)
        {
            var validator = new ValidationRuleValidator <TModel>(_builder);

            return(await validator.ExecuteAsync(request));
        }
        public async Task <string[]> ExecuteAsync(
            ValidateRequest <TModel> request)
        {
            var models = _propertyExpression.Compile()(request.Model);
            var path   = ConcatPath(request.Path, _propertyExpression);

            var validators = _builder.Build();
            var errors     = new List <string>();

            var index = 0;

            foreach (var model in models)
            {
                var forRequest = new ValidateRequest <TProperty>(
                    model,
                    string.Format("{0}[{1}]", path, index));
                index++;

                foreach (var validator in validators)
                {
                    errors.AddRange(
                        await validator.ExecuteAsync(forRequest));
                }
            }

            return(errors.ToArray());
        }
示例#4
0
        public void TaxabilityTest()
        {
            Address        address;
            ValidateResult result;

            address            = new Address();
            address.Line1      = "900 Winslow Way";
            address.Line2      = "Ste 130";
            address.City       = "Bainbridge Island";
            address.Region     = "WA";
            address.PostalCode = "98110";

            ValidateRequest validateRequest = new ValidateRequest();

            validateRequest.Address    = address;
            validateRequest.TextCase   = TextCase.Upper;
            validateRequest.Taxability = true;

            result = _addressSvc.Validate(validateRequest);

            foreach (Message message in result.Messages)
            {
                Console.WriteLine(message.Name + ": " + message.Summary);
            }

            Assert.AreEqual(SeverityLevel.Success, result.ResultCode);
            Assert.AreEqual(1, result.Addresses.Count);
            Assert.AreEqual(true, result.Taxable);
        }
        public async Task <bool> Validate(HttpClient http, ValidateRequest request)
        {
            // await AddCsrfToken(http, JSRuntime);
            var response = await http.PutJsonAsync <HttpResponseMessage>("account", request);

            return(response.IsSuccessStatusCode);
        }
        public AuthenticeResponse Authenticate(AuthenticateCR req)
        {
            AuthenticeResponse resp = new AuthenticeResponse();

            try
            {
                if (ValidateRequest.Authenticate(req))
                {
                    UserCRUD userCRUD      = new UserCRUD();
                    string   statusMessage = string.Empty;
                    if (IsUserValid(req.EmailID, req.Password, out statusMessage))
                    {
                        resp.Token         = JWTService.GenerateToken(req.EmailID);
                        resp.StatusCode    = HttpStatusCode.OK;
                        resp.StatusMessage = HttpStatusCode.OK.ToString();
                    }
                    else
                    {
                        resp.StatusCode    = HttpStatusCode.Unauthorized;
                        resp.StatusMessage = statusMessage;
                    }
                }
                else
                {
                    resp.StatusCode    = HttpStatusCode.BadRequest;
                    resp.StatusMessage = HttpStatusCode.BadRequest.ToString();
                }
            }
            catch (Exception es)
            {
                resp.StatusCode    = HttpStatusCode.InternalServerError;
                resp.StatusMessage = HttpStatusCode.InternalServerError.ToString();
            }
            return(resp);
        }
示例#7
0
        private IFileEditStrategy GetExcludedFileEditStrategy(ValidateRequest request, string sitecoreWebRoot)
        {
            var exclusion =
                Exclusions.First(x => x.SitecoreRole == request.SitecoreRole && request.FilePath.Contains(x.FileName));

            if (exclusion == null)
            {
                return(new NullFileEditStrategy(sitecoreWebRoot));
            }

            Logger.Info("***FILE EXLUSION*** - " + request.FilePath);

            switch (exclusion.Action)
            {
            case ConfigEditOptions.NA:
                return(new NullFileEditStrategy(sitecoreWebRoot));

            case ConfigEditOptions.Disable:
                return(new DisableFileEditStrategy(sitecoreWebRoot));

            case ConfigEditOptions.Enable:
                return(new EnableFileEditStrategy(sitecoreWebRoot));

            case ConfigEditOptions.TBC:
                return(new NullFileEditStrategy(sitecoreWebRoot));

            default:
                throw new ArgumentOutOfRangeException(nameof(request.EditOption), request.EditOption, null);
            }
        }
        private static void CheckForValidation(IGuestControllerClient guestControllerClient, string displayName, Action <IValidateDisplayNameResult> callback)
        {
            ValidateRequest validateRequest = new ValidateRequest();

            validateRequest.displayName = displayName;
            ValidateRequest request = validateRequest;

            guestControllerClient.Validate(request, delegate(GuestControllerResult <ValidateResponse> r)
            {
                if (!r.Success)
                {
                    callback(new ValidateDisplayNameResult(success: false));
                }
                else
                {
                    ValidateResponse response = r.Response;
                    if (response.error == null)
                    {
                        callback(new ValidateDisplayNameResult(success: true));
                    }
                    else
                    {
                        callback(new ValidateDisplayNameExistsResult(success: false));
                    }
                }
            });
        }
        public void Validate(ValidateRequest request, Action <GuestControllerResult <ValidateResponse> > callback)
        {
            QueueItem item = CreateQueueItem("/client/{client-id}/validate", HttpMethod.POST, request, GuestControllerAuthenticationType.ApiKey, callback);

            queue.Add(item);
            ExecuteNextCall();
        }
示例#10
0
        /// <summary>
        /// Method to create a new forgot password request.
        /// </summary>
        /// <param name="forgotPasswordDto">forgotpassword dto contains dtails required by system to generate a new forgot password request.</param>
        /// <returns>ResponseModel containing the forgot password request creation status</returns>
        public ResponseModel ForgotPassword(ForgotPasswordDto forgotPasswordDto)
        {
            var validationStatus = ValidateRequest.ValidateForgotPasswordDto(forgotPasswordDto);

            if (!(bool)validationStatus.First)
            {
                return(ReturnStatements.BadRequestResponse(validationStatus.Second));
            }

            forgotPasswordDto = validationStatus.Second;
            using (var unitOfWork = new UnitOfWork())
            {
                var user = unitOfWork.Users.Find(m => m.Handle.Equals(forgotPasswordDto.Handle));

                if (user == null)
                {
                    return(ReturnStatements.FailedResponse(Strings.UserDoNotExist));
                }

                user.ForgotPasswordFlag = true;
                user.ForgotPasswordCode = Functions.GenerateCode().ToString();
                unitOfWork.Users.Update(user);
                var saveResponse = unitOfWork.Complete();

                if (saveResponse.Equals(Integers.UnsuccessfullDatabaseSave))
                {
                    return(ReturnStatements.FailedResponse(DynamicListForResponse.Create(forgotPasswordDto)));
                }

                SendMail(forgotPasswordDto.Handle, user.ForgotPasswordCode, user.EmailId, true);
                return(ReturnStatements.SuccessResponse(DynamicListForResponse.Create(forgotPasswordDto)));
            }
        }
        public static ValidateResponse Validate(ValidateRequest validateRequest)
        {
            ValidateResponse validateResponse = new ValidateResponse();

            ErrorResponse errorResponse = validateCredentials(credentials);
            string        responseCode  = errorResponse.responseCode;

            if (errorResponse.responseCode != "00")
            {
                validateResponse.responseCode = errorResponse.responseCode;
                validateResponse.responseMsg  = errorResponse.responseMsg;
                return(validateResponse);
            }

            if (validateRequest == null)
            {
                validateResponse.responseCode = "14";
                validateResponse.responseMsg  = "Missing Validate Request object";
                return(validateResponse);
            }

            String jsonValidateRequest = JsonConvert.SerializeObject(validateRequest);

            try
            {
                var response = WebClientUtil.PostResponse(credentials.url, RemitaBillerUrl.Validate(), jsonValidateRequest, _header);
                validateResponse = JsonConvert.DeserializeObject <ValidateResponse>(response);
            }
            catch (Exception)
            {
                throw;
            }
            return(validateResponse);
        }
        /// <summary>
        /// Validates the user is online.
        /// 项目用到的
        /// </summary>
        /// <param name="validateRequest">The login request.</param>
        /// <returns></returns>
        public ValidateResponse ValidateUserIsOnline(ValidateRequest validateRequest)
        {
            ValidateResponse loginResponse = new ValidateResponse();
            User             user          = validateRequest.User;

            try
            {
                lock (synchronizeObjectCall)
                {
                    // User is not yet logged in.
                    if (iPow.Service.SSO.WebService.OnLineUserService
                        .OnLineUserList.Where(e => e.id == user.id && e.username == user.username).Any())
                    {
                        //存在
                        loginResponse.User = user;
                    }
                }
            }
            catch (Exception ex)
            {
                loginResponse.Fault         = new SingleSignOnFault();
                loginResponse.Fault.Message = ex.Message;
            }
            return(loginResponse);
        }
示例#13
0
        /// <summary>
        /// Method to add patient to database.
        /// </summary>
        /// <param name="newPatientDto">newPatientDto contains information of patient to be added.</param>
        /// <returns>ResponseModel containing patient addition status</returns>
        public ResponseModel Add(PatientDto newPatientDto, int userId)
        {
            var validationStatus = ValidateRequest.ValidatePatientDto(newPatientDto);

            if (!(bool)validationStatus.First)
            {
                return(ReturnStatements.BadRequestResponse(validationStatus.Second));
            }

            newPatientDto = validationStatus.Second;

            using (var unitOfWork = new UnitOfWork())
            {
                var dbPatient = DtoToDatabase.Patient(newPatientDto, userId);
                unitOfWork.Patients.Add(dbPatient);
                var saveResponse = unitOfWork.Complete();

                if (saveResponse.Equals(Integers.UnsuccessfullDatabaseSave))
                {
                    return(ReturnStatements.FailedResponse(DynamicListForResponse.Create(newPatientDto)));
                }

                SendMail(newPatientDto);
                return(ReturnStatements.SuccessResponse(DynamicListForResponse.Create(newPatientDto)));
            }
        }
示例#14
0
    public async Task <bool> Validate(ValidateRequest validateRequest, CancellationToken token)
    {
        _logger.LogTrace($"Validate for id={validateRequest.Id}");

        foreach (var request in validateRequest.PrincipleDigests)
        {
            IdentityEntry?identityEntry = await GetIdentity(request.PrincipleId, token);

            if (identityEntry == null || request.JwtSignature.IsEmpty())
            {
                _logger.LogError($"Cannot find signing data for PrincipleId={request.PrincipleId}");
                return(false);
            }

            IPrincipalSignature principleSignature = new PrincipalSignature(request.PrincipleId, _issuer, _audience, identityEntry.Subject, identityEntry.GetRsaParameters());

            try
            {
                JwtTokenDetails tokenDetails = new JwtTokenParserBuilder()
                                               .SetPrincipleSignature(principleSignature)
                                               .Build()
                                               .Parse(request.JwtSignature);

                _logger.LogTrace($"JWT validated for PrincipleId={request.PrincipleId}");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Failed validation for PrincipleId={request.PrincipleId}");
                return(false);
            }
        }

        return(true);
    }
示例#15
0
        /// <summary>
        /// Method to update an old patient.
        /// </summary>
        /// <param name="oldPatientDto">oldPatientDto contains information of patient to be modified.</param>
        /// <returns>ResponseModel regarding the modification status of the patient</returns>
        public ResponseModel Update(PatientDto oldPatientDto, int userId)
        {
            var validationStatus = ValidateRequest.ValidatePatientDto(oldPatientDto);

            if (!(bool)validationStatus.First)
            {
                return(ReturnStatements.BadRequestResponse(validationStatus.Second));
            }

            oldPatientDto = validationStatus.Second;

            using (var unitOfWork = new UnitOfWork())
            {
                var findPatient = unitOfWork.Patients.Find(m => m.Id.Equals(oldPatientDto.Id));

                if (findPatient == null)
                {
                    return(ReturnStatements.FailedResponse(Strings.NoPatientFound));
                }

                if (!findPatient.UserId.Equals(userId))
                {
                    return(ReturnStatements.FailedResponse(Strings.Unauthorized));
                }

                findPatient = MapForUpdate(oldPatientDto, findPatient);
                unitOfWork.Patients.Update(findPatient);
                var saveResponse = unitOfWork.Complete();
                return(Functions.ReturnGeneric(saveResponse, Strings.SuccessfullModification, Strings.UnsuccessfullModification));
            }
        }
        public UserResponse GetUser(long id)
        {
            UserResponse response = new UserResponse();

            try
            {
                if (ValidateRequest.GetUser(id))
                {
                    var result = new UserCRUD().GetUser(id);
                    if (result == null)
                    {
                        response.NotFound();
                    }
                    else
                    {
                        response.OK();
                        response.User = result;
                    }
                }
                else
                {
                    response.BadRequest();
                }
            }
            catch (Exception es)
            {
                logger.Error(string.Format("GetUser, UserID={0}", id));
                logger.Error("GetUser " + es.StackTrace);
                response.InternalServerError();
            }
            return(response);
        }
        private bool IsValid(string license)
        {
            try
            {
                if (string.IsNullOrEmpty(license))
                {
                    throw new ArgumentNullException();
                }

                var request = new ValidateRequest
                {
                    License     = license,
                    FingerPrint = SecurityUtility.GetMd5Hash(AppConfigUtility.FingerPrint)
                };

                var response = WebServiceUtility.Post(AppConfigUtility.ValidateLicenseUrl, request.ToJSON());

                if (!response.Success)
                {
                    throw new LicenseNotValidException(response.Message);
                }

                return(true);
            }
            catch (LicenseNotValidException)
            {
                throw;
            }
            catch (Exception ex)
            {
                LogUtility.Log(LogUtility.LogType.SystemError, MethodBase.GetCurrentMethod().Name, ex.Message);
                return(false);
            }
        }
示例#18
0
        public async Task <string[]> ExecuteAsync(
            ValidateRequest <TModel> request)
        {
            var errors = new List <string>();

            if (request.Model == null)
            {
                errors.Add(request
                           .FormatError(NotNullPredicate.Name)
                           );
            }
            else
            {
                var forRequest = new ValidateRequest <TProperty>(
                    _propertyExpression.Compile()(request.Model),
                    ConcatPath(request.Path, _propertyExpression)
                    );

                var validators = _builder.Build();
                foreach (var validator in validators)
                {
                    errors.AddRange(
                        await validator.ExecuteAsync(forRequest));
                }
            }

            return(errors.ToArray());
        }
示例#19
0
        /// <summary>
        /// Method to add user to database.
        /// </summary>
        /// <param name="newUserDto">newUserDto contains personal information of user and user id and password.</param>
        /// <returns>ResponseModel of user addition in database.</returns>
        public ResponseModel Add(UserDto newUserDto)
        {
            var validationStatus = ValidateRequest.ValidateUserDto(newUserDto);

            if (!(bool)validationStatus.First)
            {
                return(ReturnStatements.BadRequestResponse(validationStatus.Second));
            }
            newUserDto = validationStatus.Second;
            using (var unitOfWork = new UnitOfWork())
            {
                var checkIfUserAlreadyExist = unitOfWork.Users.Find(m => m.Handle.Equals(newUserDto.Handle) || m.EmailId.Equals(newUserDto.EmailId)) != null;

                if (checkIfUserAlreadyExist)
                {
                    return(ReturnStatements.BadRequestResponse(Strings.UserAlreadyExist));
                }
                var dbUser         = DtoToDatabase.User(newUserDto);
                var loginDto       = new LoginDto(loginHandle: newUserDto.Handle, loginPassword: newUserDto.Password);
                var dbUserPassword = DtoToDatabase.UserPassword(loginDto, dbUser.Id);
                dbUserPassword.User = dbUser;
                unitOfWork.UserPasswords.Add(dbUserPassword);

                var saveResponse = unitOfWork.Complete();

                if (saveResponse.Equals(Integers.UnsuccessfullDatabaseSave))
                {
                    return(ReturnStatements.FailedResponse(DynamicListForResponse.Create(loginDto)));
                }

                SendMail(loginDto.LoginHandle, dbUser.VerificationCode, dbUser.EmailId, false);
                return(ReturnStatements.SuccessResponse(DynamicListForResponse.Create(loginDto)));
            }
        }
示例#20
0
        public IFileEditStrategy Create(ValidateRequest request, string sitecoreWebRoot)
        {
            if (FileIsExcluded(request))
            {
                return(GetExcludedFileEditStrategy(request, sitecoreWebRoot));
            }

            if (!IsValidSearchOption(request.SearchOption, request.FilePath))
            {
                return(new DisableFileEditStrategy(sitecoreWebRoot));
            }

            switch (request.EditOption)
            {
            case ConfigEditOptions.NA:
                return(new NullFileEditStrategy(sitecoreWebRoot));

            case ConfigEditOptions.Disable:
                return(new DisableFileEditStrategy(sitecoreWebRoot));

            case ConfigEditOptions.Enable:
                return(new EnableFileEditStrategy(sitecoreWebRoot));

            case ConfigEditOptions.TBC:
                return(new NullFileEditStrategy(sitecoreWebRoot));

            default:
                throw new ArgumentOutOfRangeException(nameof(request.EditOption), request.EditOption, null);
            }
        }
示例#21
0
        public static bool ValidateToken(string accessToken, string clientToken)
        {
            bool            tokenValidated  = false;
            ValidateRequest validateRequest = new ValidateRequest(accessToken, clientToken);

            HttpWebRequest httpValidateWebRequest = (HttpWebRequest)WebRequest.Create(CommonData.authServerValidateURL);

            httpValidateWebRequest.ContentType = "application/json";
            httpValidateWebRequest.Method      = "POST";

            using (StreamWriter streamWriter = new StreamWriter(httpValidateWebRequest.GetRequestStream()))
            {
                string json = JsonConvert.SerializeObject(validateRequest);

                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();

                try
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)httpValidateWebRequest.GetResponse();
                    using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    {
                        tokenValidated = true;
                    }
                }
                catch (Exception)
                {
                    tokenValidated = RefreshToken(accessToken, clientToken);
                }
            }

            return(tokenValidated);
        }
        public static void Test()
        {
            string accountNumber = ConfigurationManager.AppSettings["AvaTax:AccountNumber"];
            string licenseKey = ConfigurationManager.AppSettings["AvaTax:LicenseKey"];
            string serviceURL = ConfigurationManager.AppSettings["AvaTax:ServiceUrl"];

            AddressSvc addressSvc = new AddressSvc();

            // Header Level Parameters
            // Required Header Parameters
            addressSvc.Configuration.Security.Account = accountNumber;
            addressSvc.Configuration.Security.License = licenseKey;
            addressSvc.Configuration.Url = serviceURL;
            addressSvc.Configuration.ViaUrl = serviceURL;
            addressSvc.Profile.Client = "AvaTaxSample";

            // Optional Header Parameters
            addressSvc.Profile.Name = "Development";

            ValidateRequest validateRequest = new ValidateRequest();

            Address address = new Address();
            // Required Request Parameters
            address.Line1 = "118 N Clark St";
            address.City = "Chicago";
            address.Region = "IL";

            // Optional Request Parameters
            address.Line2 = "Suite 100";
            address.Line3 = "ATTN Accounts Payable";
            address.Country = "US";
            address.PostalCode = "60602";

            validateRequest.Address = address;
            validateRequest.Coordinates = true;
            validateRequest.Taxability = true;
            validateRequest.TextCase = TextCase.Upper;

            ValidateResult validateResult = addressSvc.Validate(validateRequest);

            Console.WriteLine("ValidateAddressTest Result: " + validateResult.ResultCode.ToString());
            if (!validateResult.ResultCode.Equals(SeverityLevel.Success))
            {
                foreach (Message message in validateResult.Messages)
                {
                    Console.WriteLine(message.Summary);
                }
            }
            else
            {
                Console.WriteLine(validateResult.Addresses[0].Line1
                    + " "
                    + validateResult.Addresses[0].City
                    + ", "
                    + validateResult.Addresses[0].Region
                    + " "
                    + validateResult.Addresses[0].PostalCode);
            }
        }
示例#23
0
        public async Task <ActionResult> Validate(string id, [FromBody] ValidateRequest request)
        {
            var signed = await enclave.Validate(enclave.ParseKeyId(id), request.Value);

            return(Ok(new ValidateResult {
                Result = signed
            }));
        }
示例#24
0
        public async Task <bool> Validate(ValidateRequest validateRequest, CancellationToken token = default)
        {
            _logger.LogTrace($"Signing request for id={validateRequest.Id}");

            HttpResponseMessage response = await _httpClient.PostAsJsonAsync($"api/signing/validate", validateRequest, token);

            return(response.StatusCode == HttpStatusCode.OK ? true : false);
        }
示例#25
0
        private TelekomJsonWebRequest <TelekomResponse> CreateValidateWebRequest(ValidateRequest request)
        {
            EnsureRequestValid(request);

            string uri = ServiceBaseUrl
                         + string.Format("/validatednumbers/{0}", request.Number);

            return(CreateAuthenticatedRequest <TelekomResponse>(uri, HttpMethod.POST, request));
        }
示例#26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["CompanyID"] == null || Session["BranchID"] == null)
            {
                ValidateRequest.SetDataSession(User.Identity.Name);
            }

            if (!IsPostBack)
            {
                //get ticket date and time
                deTicketDate.TimeSectionProperties.Visible = true;
                deTicketDate.DisplayFormatString           = "g";
                deTicketDate.Date = System.DateTime.Now;
                //get the next ticket number
                string    query      = "SELECT MAX(ID) + 1 FROM tblTicket";
                DataTable dt         = DataBase.GetDT(query);
                string    NextTicket = dt.Rows[0][0].ToString();
                tbTicket.Text     = NextTicket;
                Session["Ticket"] = NextTicket;
                //get customer and branch
                try
                {
                    query = "SELECT t2.Name + ' - ' + t1.Name FROM tblBranch t1 INNER JOIN tblCompany t2 ON t2.ID = t1.CompanyID WHERE t1.ID = @ID";
                    List <SqlParameter> sp1 = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@ID", SqlDbType = SqlDbType.Int, Value = Session["BranchID"]
                        }
                    };
                    dt            = DataBase.GetDT(sp1, query);
                    tbBranch.Text = dt.Rows[0][0].ToString();
                }
                catch
                {
                    tbBranch.Enabled  = true;
                    tbBranch.NullText = "enter your Country here";
                }
                //get Creator
                query = "SELECT Name, Title, WorkPhone, MobilePhone, HasWhatsapp FROM aspnet_Users WHERE UserName = @UserName";
                List <SqlParameter> sp = new List <SqlParameter>
                {
                    new SqlParameter()
                    {
                        ParameterName = "@UserName", SqlDbType = SqlDbType.NVarChar, Value = User.Identity.Name
                    }
                };
                dt           = DataBase.GetDT(sp, query, "ApplicationServices");
                tbName.Text  = dt.Rows[0][0].ToString();
                tbTitle.Text = dt.Rows[0][1].ToString();
                tbEmail.Text = Membership.GetUser().Email;

                tbWork.Text     = dt.Rows[0][2].ToString();
                tbMobile.Text   = dt.Rows[0][3].ToString();
                chWhats.Checked = dt.Rows[0][4].ToString() == "True" ? true:false;
            }
        }
示例#27
0
 public MainController(
     DbOperations dbOperations,
     UserAuthentication userAuthentication,
     ValidateRequest validateRequest)
 {
     _dbOperations       = dbOperations;
     _userAuthentication = userAuthentication;
     _validateRequest    = validateRequest;
 }
示例#28
0
    public async Task <IActionResult> Validate([FromBody] ValidateRequest validateRequest, CancellationToken token)
    {
        bool result = await _signingService.Validate(validateRequest, token);

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

        return(Ok(true));
    }
示例#29
0
        private bool FileIsExcluded(ValidateRequest request)
        {
            var roleExclusions = Exclusions.Where(x => x.SitecoreRole == request.SitecoreRole);

            if (!roleExclusions.Any())
            {
                return(false);
            }

            return(roleExclusions.Any(x => request.FilePath.Contains(x.FileName)));
        }
示例#30
0
        private ValidateRequest CreateValidationRequest(string file, ConfigEditOptions editOption)
        {
            var request = new ValidateRequest()
            {
                FilePath     = file.Trim(),
                EditOption   = editOption,
                SearchOption = _commandLineOptions.SearchOption,
                SitecoreRole = _commandLineOptions.SitecoreRole
            };

            return(request);
        }
        public virtual async Task <string[]> ExecuteAsync(
            ValidateRequest <TModel> model)
        {
            var errors = new List <string>();

            foreach (var validator in _builder.Build())
            {
                errors.AddRange(
                    await validator.ExecuteAsync(model));
            }

            return(errors.ToArray());
        }
 /// <remarks/>
 public void ValidateAsync(ValidateRequest ValidateRequest, object userState) {
     if ((this.ValidateOperationCompleted == null)) {
         this.ValidateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnValidateOperationCompleted);
     }
     this.InvokeAsync("Validate", new object[] {
                 ValidateRequest}, this.ValidateOperationCompleted, userState);
 }
 /// <remarks/>
 public void ValidateAsync(ValidateRequest ValidateRequest) {
     this.ValidateAsync(ValidateRequest, null);
 }
 /// <summary>
 /// Validates the user is online.
 /// 项目用到的
 /// </summary>
 /// <param name="validateRequest">The login request.</param>
 /// <returns></returns>
 public ValidateResponse ValidateUserIsOnline(ValidateRequest validateRequest)
 {
     ValidateResponse loginResponse = new ValidateResponse();
     User user = validateRequest.User;
     try
     {
         lock (synchronizeObjectCall)
         {
             // User is not yet logged in.
             if (Miaow.Service.SSO.WebService.OnLineUserService
                 .OnLineUserList.Where(e=> e.id == user.id && e.username == user.username).Any())
             {
                 //存在
                 loginResponse.User = user;
             }
         }
     }
     catch (Exception ex)
     {
         loginResponse.Fault = new SingleSignOnFault();
         loginResponse.Fault.Message = ex.Message;
     }
     return loginResponse;
 }