示例#1
0
        /// <summary>
        /// Redirect the current request to SSO site for authentication check
        /// </summary>
        /// <param name="Path"></param>
        private void RedirectToSSOSite()
        {
            string originalRequestUrl = Path;

            //Clean up all current QueryString parameters before redirecting to SSO site
            originalRequestUrl = UriUtil.RemoveParameter(originalRequestUrl, AppConstants.UrlParams.REQUEST_ID);
            originalRequestUrl = UriUtil.RemoveParameter(originalRequestUrl, AppConstants.UrlParams.ACTION);
            originalRequestUrl = UriUtil.RemoveParameter(originalRequestUrl, AppConstants.UrlParams.TOKEN);
            string ssoSiteUrl = string.Format(SSOSiteUrlConfig, HttpUtility.UrlEncode(originalRequestUrl));

            //Redirect to SSO site
            Response.Redirect(ssoSiteUrl);
        }
示例#2
0
        /// <summary>
        /// Redirect to Login page
        /// </summary>
        /// <param name="Urlpath"></param>
        protected void RedirectToLoginPage()
        {
            //Before redirecting to login URL, remove the Token and RequestId parameter value from the QueryString (If they are there)
            //that were appended by the SSO sites. Reason is, these two parameter values are now expired.
            //From the login screen, user will log in and the SSO site will re-generate the Token and RequestId
            string originalRequestUrl = Request.Url.OriginalString;

            originalRequestUrl = UriUtil.RemoveParameter(originalRequestUrl, AppConstants.UrlParams.REQUEST_ID);
            originalRequestUrl = UriUtil.RemoveParameter(originalRequestUrl, AppConstants.UrlParams.TOKEN);


            //Current request is redirected from SSO site. So, do not further redirect to SSO site
            SessionAPI.RequestRedirectFlag = false;
            Response.Redirect(VirtualPathUtility.ToAbsolute(string.Format("{0}?{1}={2}", LoginUrl, AppConstants.UrlParams.RETURN_URL, HttpUtility.UrlEncode(originalRequestUrl))));
        }
示例#3
0
        /// <summary>
        /// Logs out the current user
        /// </summary>
        protected void Logout()
        {
            if (CurrentUser == null)
            {
                RedirectToLoginPage();
                return;
            }
            string currentURL = Request.Url.OriginalString;

            currentURL = UriUtil.RemoveParameter(currentURL, AppConstants.UrlParams.REQUEST_ID);
            currentURL = UriUtil.RemoveParameter(currentURL, AppConstants.UrlParams.TOKEN);

            string ssoSiteUrl = string.Format(SSOSiteUrlConfig, HttpUtility.UrlEncode(currentURL));
            string LogoutUrl  = string.Format("{0}&{1}={2}&{3}={4}", ssoSiteUrl, AppConstants.UrlParams.ACTION, AppConstants.ParamValues.LOGOUT, AppConstants.UrlParams.TOKEN, SessionAPI.CurrentUser.Token);

            CurrentUser = null;
            Response.Redirect(LogoutUrl);
        }
示例#4
0
        /// <summary>
        /// Performs login action onto server
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        protected bool Login(string UserName, string Password)
        {
            CurrentUser = AuthUtil.Instance.Authenticate(UserName, Password);

            if (CurrentUser != null)
            {
                string returnUrl = Request.Params[AppConstants.UrlParams.RETURN_URL];
                if (string.IsNullOrEmpty(returnUrl))
                {
                    returnUrl = UriUtil.GetAbsolutePathForRelativePath(DefaultUrl);
                }
                else
                {
                    returnUrl = UriUtil.RemoveParameter(returnUrl, AppConstants.UrlParams.ACTION);
                }
                string ssoSiteUrl = string.Format(SSOSiteUrlConfig, HttpUtility.UrlEncode(returnUrl));

                Response.Redirect(string.Format("{0}&{1}={2}", ssoSiteUrl, AppConstants.UrlParams.TOKEN, CurrentUser.Token));
            }

            return(false);
        }