コード例 #1
0
        public IActionResult DetailsReturn(string language_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(language_state))
            {
                mState = new StateOfRequest("LangNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(language_state);
            }
            mState.StartTime = DateTime.Now;

            int             orgId         = mState.OrgId;
            List <Language> languagesTemp = _languagesManager.GetOnePageOfLanguages(mState);
            string          temp_state    = JsonUtil.SetJsonStringFromObject(mState);

            ViewBag.LanguageState = temp_state;

            return(View(nameof(LanguagesList), languagesTemp));
        }
コード例 #2
0
        private void AuthenticateUsingMembershipProvider(AuthenticateEventArgs e)
        {
            var provider = LoginUtil.GetProvider(this.MembershipProvider);

            e.Authenticated = provider.ValidateUser(
                this.UserNameInternal, this.PasswordInternal);
        }
コード例 #3
0
 internal bool AccessibleToUser(IPrincipal user)
 {
     return(string.IsNullOrEmpty(this.Roles) || LoginUtil.IsInRoles(user, this.Roles.Split(new char[]
     {
         ','
     })));
 }
コード例 #4
0
        /// <summary>
        /// Initializes the service before MakeApiCall.
        /// </summary>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="parameters">The method parameters.</param>
        protected override void InitForCall(string methodName, object[] parameters)
        {
            DfaAppConfig config      = this.User.Config as DfaAppConfig;
            string       oAuthHeader = null;

            if (this.GetType().Name == "LoginRemoteService")
            {
                // The choice of OAuth comes only when calling LoginRemoteService.
                // All other services will still use the login token.
                if (config.AuthorizationMethod == DfaAuthorizationMethod.OAuth2)
                {
                    if (this.User.OAuthProvider != null)
                    {
                        oAuthHeader = this.User.OAuthProvider.GetAuthHeader();
                    }
                    else
                    {
                        throw new DfaApiException(null, DfaErrorMessages.OAuthProviderCannotBeNull);
                    }
                }
            }
            else
            {
                if (this.Token == null)
                {
                    this.Token = LoginUtil.GetAuthenticationToken(this.User, this.Signature.Version);
                }
            }

            ContextStore.AddKey("OAuthHeader", oAuthHeader);
            ContextStore.AddKey("RequestHeader", requestHeader);
            ContextStore.AddKey("Token", Token);

            base.InitForCall(methodName, parameters);
        }
コード例 #5
0
        // GET: Singarea/Add
        // the view of adding singareas to Singarea table
        public IActionResult Add(string singarea_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(singarea_state))
            {
                mState = new StateOfRequest("AreaNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(singarea_state);
            }

            if ((mState.IsFirstAddRecord) || (mState.OrgId == 0))
            {
                // the first id of this page became the selected original id
                // or SateOfRequest.OrgId = 0
                mState.OrgId = mState.FirstId;
            }

            mState.StartTime = DateTime.Now;
            string temp_state = JsonUtil.SetJsonStringFromObject(mState);

            ViewBag.SingareaState = temp_state; // pass the Json string to View

            Singarea singarea = new Singarea(); // create a new Singarea object

            return(View(singarea));
        }
コード例 #6
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     if (!base.DesignMode)
     {
         MasterPage master = base.Master;
         while (master != null && this.iMasterPage == null)
         {
             this.iMasterPage = (master as IMasterPage);
             master           = master.Master;
         }
     }
     if (base.Form != null)
     {
         Control contentPlaceHolder = this.ContentPlaceHolder;
         if (contentPlaceHolder != null)
         {
             this.InjectDefaultLayoutControls(contentPlaceHolder);
             this.InitExtenderParameters();
         }
     }
     if (!string.IsNullOrEmpty(this.SetRoles) && !LoginUtil.IsInRoles(this.Context.User, this.SetRoles.Split(new char[]
     {
         ','
     })))
     {
         this.ReadOnly = true;
     }
 }
コード例 #7
0
 public void GivenILoggedIntoDesignerApplication()
 {
     if (!LoginUtil.Login(ObjectRepository.config.getUserName(), ObjectRepository.config.getPassword()))
     {
         ScenarioContext.Current["ActResult"] = "Failed";
     }
 }
コード例 #8
0
        public static bool SetText(IWebElement Locator, string text, string logMessageOnException)
        {
            // element = GenericHelper.GetElement(Locator);
            // element.SendKeys(text);
            bool isTextEntered = false;

            try
            {
                if (Locator != null && Locator.Displayed)
                {
                    LoginUtil.ScrollIntoView(Locator);
                    ObjectRepository.webelement = GenericHelper.GetElement(Locator);
                    ObjectRepository.webelement.SendKeys(text);
                    isTextEntered = true;
                }
                if (!isTextEntered)
                {
                    //LogException("Object does not exist and failed to set text to textbox", String.Empty, logMessageOnException);
                }
            }
            catch (Exception e)
            {
                // LogException("Failed to set text to textbox", e.ToString(), logMessageOnException);
            }
            return(isTextEntered);
        }
コード例 #9
0
        // GET: Singarea/5
        public async Task <IActionResult> Details(string singarea_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(singarea_state))
            {
                mState = new StateOfRequest("AreaNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(singarea_state);
            }
            Singarea singarea = await _singareasManager.FindOneSingareaById(mState.OrgId);

            if (singarea == null)
            {
                // go to previous view (List view)
                return(Redirect(HttpContext.Request.Headers["Referer"]));
            }
            else
            {
                mState.OrgId = singarea.Id;
                mState.OrgNo = singarea.AreaNo;
                string temp_state = JsonUtil.SetJsonStringFromObject(mState);

                ViewBag.SingareaState = temp_state;
                return(View(singarea));
            }
        }
コード例 #10
0
        public IActionResult DetailsReturn(string singarea_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(singarea_state))
            {
                mState = new StateOfRequest("AreaNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(singarea_state);
            }
            mState.StartTime = DateTime.Now;

            int             orgId         = mState.OrgId;
            List <Singarea> singareasTemp = _singareasManager.GetOnePageOfSingareas(mState);
            string          temp_state    = JsonUtil.SetJsonStringFromObject(mState);

            ViewBag.SingareaState = temp_state;

            return(View(nameof(SingareasList), singareasTemp));
        }
コード例 #11
0
        public IActionResult Find(string area_no, string area_na, string search_type, string submitbutton, string singarea_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(singarea_state))
            {
                mState = new StateOfRequest("AreaNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(singarea_state);
            }
            mState.StartTime = DateTime.Now;
            string temp_state = JsonUtil.SetJsonStringFromObject(mState);

            if (string.IsNullOrEmpty(area_no))
            {
                area_no = string.Empty;
            }
            area_no = area_no.Trim();

            if (string.IsNullOrEmpty(area_na))
            {
                area_na = string.Empty;
            }
            area_na = area_na.Trim();

            string sButton = submitbutton.ToUpper();

            if (sButton == "CANCEL")
            {
                temp_state = JsonUtil.SetJsonStringFromObject(mState);
                return(RedirectToAction(nameof(SingareasList), new { singarea_state = temp_state }));
            }
            if (string.IsNullOrEmpty(search_type))
            {
                // search_type not defined
                return(View());
            }

            string searchType = search_type.Trim();

            mState.OrderBy = searchType;
            Singarea singarea = new Singarea(); // new object

            singarea.AreaNo = area_no;          // for order by "AreaNo"
            singarea.AreaNa = area_na;          // for order by "AreaNa"

            List <Singarea> singareasTemp = _singareasManager.FindOnePageOfSingareasForOneSingarea(mState, singarea, -1);

            temp_state            = JsonUtil.SetJsonStringFromObject(mState);
            ViewBag.SingareaState = temp_state;

            return(View(nameof(SingareasList), singareasTemp));
        }
コード例 #12
0
        // GET: Language/5
        public async Task <IActionResult> Details(string language_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(language_state))
            {
                mState = new StateOfRequest("LangNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(language_state);
            }
            Language language = await _languagesManager.FindOneLanguageById(mState.OrgId);

            if (language == null)
            {
                // go to previous view (List view)
                return(Redirect(HttpContext.Request.Headers["Referer"]));
            }
            else
            {
                mState.OrgId = language.Id;
                mState.OrgNo = language.LangNo;
                string temp_state = JsonUtil.SetJsonStringFromObject(mState);
                ViewBag.LanguageState = temp_state;

                return(View(language));
            }
        }
コード例 #13
0
        public async Task <IActionResult> DeleteConfirmed(string submitbutton, string singarea_state, [Bind("Id", "AreaNo, AreaNa, AreaEn")] Singarea singarea)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(singarea_state))
            {
                mState = new StateOfRequest("AreaNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(singarea_state);
            }
            mState.StartTime = DateTime.Now;
            string temp_state = JsonUtil.SetJsonStringFromObject(mState);

            int    orgId   = mState.OrgId;
            string sButton = submitbutton.ToUpper();

            if (sButton == "CANCEL")
            {
                temp_state = JsonUtil.SetJsonStringFromObject(mState);
                return(RedirectToAction(nameof(SingareasList), new { singarea_state = temp_state }));
            }

            if (ModelState.IsValid)
            {
                // start deleting the singarea from table
                int result = await _singareasManager.DeleteOneSingareaById(orgId);

                if (result == ErrorCodeModel.Succeeded)
                {
                    // succeeded to delete a singarea
                    List <Singarea> singareasTemp = _singareasManager.GetOnePageOfSingareas(mState);
                    temp_state            = JsonUtil.SetJsonStringFromObject(mState);
                    ViewBag.SingareaState = temp_state;

                    return(View(nameof(SingareasList), singareasTemp));
                }
                else
                {
                    ViewData["ErrorMessage"] = ErrorCodeModel.GetErrorMessage(result);
                }
            }
            else
            {
                // Model.IsValid = false
                ViewData["ErrorMessage"] = ErrorCodeModel.GetErrorMessage(ErrorCodeModel.ModelBindingFailed);
            }

            // failed
            ViewBag.SingareaState = temp_state;
            return(View(singarea));
        }
コード例 #14
0
        public IActionResult ChangeOrder(string singarea_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(singarea_state))
            {
                mState = new StateOfRequest("AreaNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(singarea_state);
            }
            mState.StartTime = DateTime.Now;

            // Added on 2018-11-24
            // start from first page
            mState.CurrentPageNo = 1;
            List <Singarea> singareasTemp = _singareasManager.GetOnePageOfSingareas(mState);
            string          temp_state    = JsonUtil.SetJsonStringFromObject(mState);

            ViewBag.SingareaState = temp_state;

            return(View(nameof(SingareasList), singareasTemp));

            /*s
             * int orgId = 0;
             * if (mState.OrgId == 0)
             * {
             *  // no singarea found or selected in this page
             *  // then use the first singarea of this page
             *  orgId = mState.FirstId;
             * }
             * else
             * {
             *  orgId = mState.OrgId;
             * }
             *
             * if (orgId != 0)
             * {
             *  Singarea singarea = new Singarea();
             *  List<Singarea> singareasTemp = _singareasManager.FindOnePageOfSingareasForOneSingarea(mState, singarea, orgId);
             *  string temp_state = JsonUtil.SetJsonStringFromObject(mState);
             *
             *  ViewBag.SingareaState = temp_state;
             *  return View(nameof(SingareasList), singareasTemp);
             * }
             * else
             * {
             *  // return to the previous page
             *  return Redirect(HttpContext.Request.Headers["Referer"]);
             * }
             */
        }
コード例 #15
0
        public IActionResult ChangeOrder(string language_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(language_state))
            {
                mState = new StateOfRequest("LangNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(language_state);
            }
            mState.StartTime = DateTime.Now;

            // Added on 2018-11-24
            // start from first page
            mState.CurrentPageNo = 1;
            List <Language> languagesTemp = _languagesManager.GetOnePageOfLanguages(mState);
            string          temp_state    = JsonUtil.SetJsonStringFromObject(mState);

            ViewBag.LanguageState = temp_state;

            return(View(nameof(LanguagesList), languagesTemp));

            /*
             * int orgId = 0;
             * if (mState.OrgId == 0)
             * {
             *  // no language found or selected in this page
             *  // then use the first language of this page
             *  orgId = mState.FirstId;
             * }
             * else
             * {
             *  orgId = mState.OrgId;
             * }
             *
             * if (orgId != 0)
             * {
             *  Language language = new Language();
             *  List<Language> languagesTemp = await _languagesManager.FindOnePageOfLanguagesForOneLanguage(mState, language, orgId);
             *  string temp_state = JsonUtil.SetJsonStringFromObject(mState);
             *
             *  ViewBag.LanguageState = temp_state;
             *  return View(nameof(LanguagesList), languagesTemp);
             * }
             * else
             * {
             *  // return to the previous page
             *  return Redirect(HttpContext.Request.Headers["Referer"]);
             * }
             */
        }
コード例 #16
0
        public async Task <IActionResult> Edit(string submitbutton, string language_state, [Bind("Id", "LangNo, LangNa, LangEn")] Language language)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            StateOfRequest mState;

            if (string.IsNullOrEmpty(language_state))
            {
                mState = new StateOfRequest("LangNo");
            }
            else
            {
                mState = JsonUtil.GetObjectFromJsonString <StateOfRequest>(language_state);
            }
            mState.StartTime = DateTime.Now;
            string temp_state = JsonUtil.SetJsonStringFromObject(mState);

            int    orgId   = mState.OrgId; // = language.Id
            string sButton = submitbutton.ToUpper();

            if (sButton == "CANCEL")
            {
                temp_state = JsonUtil.SetJsonStringFromObject(mState);
                return(RedirectToAction(nameof(LanguagesList), new { language_state = temp_state }));
            }
            if (ModelState.IsValid)
            {
                // start updating table
                int result = await _languagesManager.UpdateOneLanguageById(orgId, language);

                if (result == ErrorCodeModel.Succeeded)
                {
                    // succeeded to update
                    Language        newLanguage   = new Language();
                    List <Language> languagesTemp = _languagesManager.FindOnePageOfLanguagesForOneLanguage(mState, newLanguage, orgId);
                    temp_state = JsonUtil.SetJsonStringFromObject(mState);

                    ViewBag.LanguageState = temp_state;
                    return(View(nameof(LanguagesList), languagesTemp));
                }
                else
                {
                    ViewData["ErrorMessage"] = ErrorCodeModel.GetErrorMessage(result);
                }
            }
            else
            {
                // Model.IsValid = false
                ViewData["ErrorMessage"] = ErrorCodeModel.GetErrorMessage(ErrorCodeModel.ModelBindingFailed);
            }

            ViewBag.LanguageState = temp_state;
            return(View(language));
        }
コード例 #17
0
    private void GALogin()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "登录失败!";
        var password = Request.Form["htxtPassword"]; //登录密码改在客户用js 的DES加密
        var userName = Request.Form["txtUserName"];
        var vcode    = Request.Form["txtCode"];
        //    var remember = Request.Form["rememberme"] == "on" ? true : false;
        string ssCode = string.Empty;

        if (Session["session_verifycode"] != null)
        {
            ssCode = Session["session_verifycode"].ToString();
            Session.Remove("session_verifycode");
        }
        else
        {
            Response.Write(result.ToJsonString());
            Response.ContentType = "application/json";
            Response.End();
        }
        if (!ssCode.Equals(vcode, StringComparison.CurrentCultureIgnoreCase))
        {
            result.Msg = "验证码错误,请重新输入!";
            Response.Write(result.ToJsonString());
            Response.ContentType = "application/json";
            Response.End();
        }
        //解密的密码
        var    PPassword = DES.uncMe(password, userName);
        string msg;

        //将明文密码转化为MD5加密
        password = CryptTools.HashPassword(PPassword);
        LoginResultEnum loginResult = LoginUtil.GALogin(StringSafeFilter.Filter(userName), StringSafeFilter.Filter(password.ToUpper()), false, out msg);

        if (loginResult == LoginResultEnum.LoginSuccess)
        {
            result.IsSuccess = true;
            result.Msg       = msg;
        }

        if (loginResult == LoginResultEnum.NoUser ||
            loginResult == LoginResultEnum.OtherError || loginResult == LoginResultEnum.PasswordError ||
            loginResult == LoginResultEnum.LockUser)
        {
            result.Msg = msg;
        }

        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }
コード例 #18
0
        public IActionResult Find(string singarea_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            ViewBag.SingareaState = singarea_state;
            return(View());
        }
コード例 #19
0
        public override Task Process(HttpContext context)
        {
            var tokenHeader =
                ((Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameRequestHeaders)context.Request.Headers)
                .HeaderAuthorization;
            var token = tokenHeader.ToString().Replace("Bearer", string.Empty).Trim();

            _user = LoginUtil.GetToken(token)?.Username;
            return(base.Process(context));
        }
コード例 #20
0
        public sealed override bool?TryIsInRole(ExchangeRunspaceConfiguration rbacConfiguration)
        {
            if (this.descriptor == null)
            {
                this.descriptor = this.ecpFeature.GetFeatureDescriptor();
            }
            bool value = LoginUtil.CheckUrlAccess(this.descriptor.ServerPath);

            return(new bool?(value));
        }
コード例 #21
0
        public IActionResult Print()
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            ViewData["Message"] = "Under construction now ..........";
            return(View());
        }
コード例 #22
0
        public IActionResult Find(string language_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            ViewBag.LanguageState = language_state;
            return(View());
        }
コード例 #23
0
        public bool ChangePassword(UserContext context, string oldPass, string newPass)
        {
            var user = context.ValidateUser();

            if (!LoginUtil.ValidatePassword(oldPass, user.PasswordHash))
            {
                return(false);
            }
            var newUser = new User(user.Username, newPass, user.Admin);

            UserContext.UpdateDefault(newUser, user.Id);
            return(true);
        }
コード例 #24
0
        public ActionResult Index(LoginBundle Creds)
        {
            string UserName = string.Empty;
            string Password = string.Empty;
            string Table    = string.Empty;
            string Redirect = string.Empty;

            if (Creds.WhichLogin == 1)
            {
                // Principal creds
                UserName = Creds.PrincipalCreds.Email;
                Password = Creds.PrincipalCreds.Password;
                Table    = "principal";
                Redirect = "Principal";
                ViewBag.PrincipalActive = "active";
                ViewBag.PrincipalError  = "active";
            }
            else if (Creds.WhichLogin == 2)
            {
                // Hod creds
                UserName          = Creds.HodCreds.Email;
                Password          = Creds.HodCreds.Password;
                Table             = "hod";
                Redirect          = "Hod";
                ViewBag.HODActive = "active";
                ViewBag.HODError  = "active";
            }
            else if (Creds.WhichLogin == 3)
            {
                // Faculty creds
                UserName = Creds.FacultyCreds.Email;
                Password = Creds.FacultyCreds.Password;
                Table    = "faculty";
                Redirect = "Faculty";
                ViewBag.TeacherActive = "active";
                ViewBag.TeacherError  = "active";
            }

            LoginUtil util = new LoginUtil();

            if (util.Login(UserName, Password, Table))
            {
                return(RedirectToAction("Index", Redirect));
            }
            else
            {
                return(View());
            }
        }
コード例 #25
0
        protected override void OnLoad(EventArgs e)
        {
            string[] roles = new string[]
            {
                "FFO"
            };
            ListView listView = (ListView)this.FindControl("AcceptedDomainsListView");

            if (LoginUtil.IsInRoles(HttpContext.Current.User, roles))
            {
                listView.ShowSearchBar = false;
                return;
            }
            listView.ShowSearchBar = true;
        }
コード例 #26
0
        public IActionResult Find(string song_state)
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                return(View(nameof(Index)));
            }

            List <SelectListItem> languageSelectList = _languagesManager.GetSelectListOfLanguages(new StateOfRequest("LangNa"));
            List <SelectListItem> singerSelectList   = _singersManager.GetSelectListOfSingers(new StateOfRequest("SingNa"));

            ViewBag.LanguageList = languageSelectList;
            ViewBag.SingerList   = singerSelectList;
            ViewBag.SongState    = song_state;
            return(View());
        }
コード例 #27
0
        // GET: /<controller>/
        public async Task <IActionResult> Index()
        {
            if (!LoginUtil.CheckIfLoggedIn(HttpContext))
            {
                ViewData["Message"] = "Please login before doing data management.";
                return(View());
            }
            int gameId = 1; // for Color balls
            List <Playerscore> top10List = await _playerscoreManager.GetTop10ScoresList(gameId);

            string rValue = JsonUtil.SetJsonStringFromObject(top10List);

            ViewData["Message"] = rValue;

            // ViewData["Message"] = "Under construction now ..........";
            return(View());
        }
コード例 #28
0
        private void Application_PostAuthenticateRequest(object sender, EventArgs e)
        {
            HttpContext httpContext = HttpContext.Current;
            string      text        = httpContext.Request.Headers["msExchProxyUri"];

            if (!string.IsNullOrEmpty(text))
            {
                Uri    uri   = new Uri(text);
                string text2 = (uri.Segments.Length > 1) ? uri.Segments[1].TrimEnd(new char[]
                {
                    '/'
                }) : string.Empty;
                if (text2.Equals(RbacModule.ecpAppPath.Value, StringComparison.OrdinalIgnoreCase) && !text2.Equals(RbacModule.ecpAppPath.Value))
                {
                    string url = "/" + RbacModule.ecpAppPath + uri.PathAndQuery.Substring(RbacModule.ecpAppPath.Value.Length + 1);
                    httpContext.Response.Redirect(url, true);
                    return;
                }
            }
            if (httpContext.Request.HttpMethod == "GET" && !RbacModule.bypassXFrameOptions && !RbacModule.xFrameOptionsExceptionList.Contains(httpContext.Request.AppRelativeCurrentExecutionFilePath))
            {
                httpContext.Response.Headers.Set("X-Frame-Options", "SameOrigin");
            }
            AuthenticationSettings authenticationSettings = new AuthenticationSettings(httpContext);

            httpContext.User = authenticationSettings.Session;
            authenticationSettings.Session.SetCurrentThreadPrincipal();
            if (!httpContext.IsAcsOAuthRequest())
            {
                httpContext.CheckCanary();
            }
            authenticationSettings.Session.RequestReceived();
            if (authenticationSettings.Session is RbacPrincipal)
            {
                if (!OAuthHelper.IsWebRequestAllowed(httpContext))
                {
                    ErrorHandlingUtil.TransferToErrorPage("notavailableforpartner");
                }
                if (!LoginUtil.CheckUrlAccess(httpContext.Request.FilePath))
                {
                    ErrorHandlingUtil.TransferToErrorPage("noroles");
                    return;
                }
                this.FlightRewrite(httpContext);
            }
        }
コード例 #29
0
        internal static void ApplyRolesFilterRecursive(Control c, IPrincipal currentUser, IVersionable versionableObject)
        {
            IAttributeAccessor attributeAccessor = c as IAttributeAccessor;

            if (attributeAccessor != null)
            {
                string             attribute          = attributeAccessor.GetAttribute("SetRoles");
                string             attribute2         = attributeAccessor.GetAttribute("DataBoundProperty");
                PropertyDefinition propertyDefinition = (versionableObject != null && !string.IsNullOrEmpty(attribute2)) ? versionableObject.ObjectSchema[attribute2] : null;
                if (propertyDefinition != null && !versionableObject.IsPropertyAccessible(propertyDefinition))
                {
                    Properties.HideControl(c, Properties.FindAssociatedLabel(c));
                }
                else if ((!string.IsNullOrEmpty(attribute) && !LoginUtil.IsInRoles(currentUser, attribute.Split(new char[]
                {
                    ','
                }))) || (!string.IsNullOrEmpty(attribute2) && versionableObject != null && versionableObject.IsReadOnly))
                {
                    string attribute3      = attributeAccessor.GetAttribute("NoRoleState");
                    Label  associatedLabel = Properties.FindAssociatedLabel(c);
                    if (!string.IsNullOrEmpty(attribute3) && NoRoleState.Hide == (NoRoleState)Enum.Parse(typeof(NoRoleState), attribute3))
                    {
                        Properties.HideControl(c, associatedLabel);
                    }
                    else
                    {
                        Properties.MakeControlRbacDisabled(c, associatedLabel);
                        if (!string.IsNullOrEmpty(attributeAccessor.GetAttribute("helpId")))
                        {
                            attributeAccessor.SetAttribute("helpId", string.Empty);
                        }
                        attributeAccessor.SetAttribute("MandatoryParam", null);
                    }
                }
            }
            if (c.HasControls())
            {
                foreach (object obj in c.Controls)
                {
                    Control c2 = (Control)obj;
                    Properties.ApplyRolesFilterRecursive(c2, currentUser, versionableObject);
                }
            }
        }
コード例 #30
0
        public static bool SetText(IWebElement element, string text)
        {
            bool isTextEntered = false;

            try
            {
                if (element.GetProperty("class") != null)
                {
                    LoginUtil.ScrollIntoView(element);
                    element.SendKeys(text);
                    isTextEntered = true;
                }
            }
            catch (Exception e)
            {
                // LogException("Failed to set text to textbox", e.ToString(), logMessageOnException);
            }
            return(isTextEntered);
        }