コード例 #1
0
        public static bool isNavigationBlocked(HTTPProtocolFilter.FilterPolicy httpPolicy, Uri referURI, Uri newURI, out string reason)
        {
            reason = "init final";
            bool isBlocked = true;

            if (httpPolicy.getMode() == HTTPProtocolFilter.WorkingMode.ENFORCE)
            {
                string urlReason = "init main reason";
                if (httpPolicy.isWhitelistedURL(newURI, out urlReason))
                {
                    isBlocked = false;
                }
                else // check the referer
                {
                    if (referURI != null)
                    {
                        string refererReason = "init ref reason";
                        if (httpPolicy.isWhitelistedURL(referURI, out refererReason))
                        {
                            if (httpPolicy.findAllowedDomain(referURI.Host).AllowRefering)
                            {
                                isBlocked = false;
                            }
                            else
                            {
                                reason = referURI.ToString() + " Is not allowed as referer. <br/><br/>" + urlReason;
                            }
                        }
                        else
                        {
                            reason = "<h3>Target:</h3></br>"
                                     + urlReason + "<br /><h3>Referrer:</h3></br>" + refererReason;
                        }
                    }
                    else
                    {
                        reason = urlReason;
                    }
                }
            }
            else
            {
                isBlocked = false;
            }

            return(isBlocked);
        }
コード例 #2
0
        public static bool isHTMLPageBlocked(HTTPProtocolFilter.FilterPolicy httpPolicy, string HeaderText, string BodyText, out string reason)
        {
            bool isBlocked = false;

            reason = "init body reason";
            if (httpPolicy.isBodyBlocked(HeaderText, out reason))
            {
                reason    = "Header is blocked. <br />" + reason;
                isBlocked = true;
            }
            else if (httpPolicy.isBodyBlocked(BodyText, out reason))
            {
                reason    = "HTML Body is blocked. <br />" + reason;
                isBlocked = true;
            }
            return(isBlocked);
        }