예제 #1
0
        /// <summary>
        /// Determines whether the request is for the CookiesRequiredUrl defined in web.config
        /// </summary>
        /// <returns>True if the request is to the CookiesRequiredUrl, otherwise False</returns>
        private static bool GetRequestIsCookiesRequiredUrl()
        {
            CasAuthentication.Initialize();

            HttpContext context = HttpContext.Current;
            HttpRequest request = context.Request;

            bool cookiesRequiredUrlIsDefined = !String.IsNullOrEmpty(CasAuthentication.CookiesRequiredUrl);
            bool requestIsCookiesRequiredUrl = cookiesRequiredUrlIsDefined && request.RawUrl.StartsWith(UrlUtil.ResolveUrl(CasAuthentication.CookiesRequiredUrl), true, CultureInfo.InvariantCulture);

            bool result =
                (
                    requestIsCookiesRequiredUrl
                );

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Determines whether the current request requires a Gateway authentication redirect
        /// </summary>
        /// <returns>True if the request requires Gateway authentication, otherwise False</returns>
        internal static bool GetRequestRequiresGateway()
        {
            CasAuthentication.Initialize();

            HttpContext context = HttpContext.Current;
            HttpRequest request = context.Request;

            GatewayStatus status = CasAuthentication.GetGatewayStatus();

            bool gatewayEnabled                     = CasAuthentication.Gateway;
            bool gatewayWasNotAttempted             = (status == GatewayStatus.NotAttempted);
            bool requestDoesNotHaveGatewayParameter = !GetRequestHasGatewayParameter();
            bool cookiesRequiredUrlIsDefined        = !string.IsNullOrEmpty(CasAuthentication.CookiesRequiredUrl);
            bool requestIsNotCookiesRequiredUrl     = !GetRequestIsCookiesRequiredUrl();
            bool notAuthorizedUrlIsDefined          = !String.IsNullOrEmpty(CasAuthentication.NotAuthorizedUrl);
            bool requestIsNotAuthorizedUrl          = notAuthorizedUrlIsDefined && request.RawUrl.StartsWith(UrlUtil.ResolveUrl(CasAuthentication.NotAuthorizedUrl), true, CultureInfo.InvariantCulture);

            bool result =
                (
                    gatewayEnabled &&
                    gatewayWasNotAttempted &&
                    requestDoesNotHaveGatewayParameter &&
                    cookiesRequiredUrlIsDefined &&
                    requestIsNotCookiesRequiredUrl &&
                    !requestIsNotAuthorizedUrl
                );

            return(result);
        }