Ejemplo n.º 1
0
        public bool Authorize(HttpRequestAuthParameters ap)//IHeaders headers, IPEndPoint endPoint, string mac)
        {
            //if (headers == null) {
            //  throw new ArgumentNullException("headers");
            //}
            //string ua;
            //if (!headers.TryGetValue("User-Agent", out ua)) {
            //  return false;
            //}
            if (string.IsNullOrEmpty(ap.UserAgent))
            {
                return(false);
            }
            var rv = userAgents.ContainsKey(ap.UserAgent);

            if (!rv)
            {
                _logger.DebugFormat("Rejecting {0}. Not in User-Agent whitelist", ap.UserAgent);
            }
            else
            {
                _logger.DebugFormat("Accepted {0} via User-Agent whitelist", ap.UserAgent);
            }
            return(rv);
        }
Ejemplo n.º 2
0
        //IHeaders headers, IPEndPoint endPoint, string mac)
        public bool Authorize(HttpRequestAuthParameters ap)
        {
            if (string.IsNullOrEmpty(ap.Mac)) {
            return false;
              }

              var rv = macs.ContainsKey(ap.Mac);
              if (!rv) {
            _logger.DebugFormat("Rejecting {0}. Not in MAC whitelist", ap.Mac ?? "<UNKNOWN>");
              }
              else {
            _logger.DebugFormat("Accepted {0} via MAC whitelist", ap.Mac);
              }
              return rv;
        }
Ejemplo n.º 3
0
 //IHeaders headers, IPEndPoint endPoint, string mac)
 public bool Authorize(HttpRequestAuthParameters ap)
 {
     //if (endPoint == null) {
       //  return false;
       //}
       //var addr = endPoint.Address;
       if (ap.Address == null) {
     return false;
       }
       var rv = ips.ContainsKey(ap.Address);
       if (!rv) {
     _logger.DebugFormat("Rejecting {0}. Not in IP whitelist", ap.Address);
       }
       else {
     _logger.DebugFormat("Accepted {0} via IP whitelist", ap.Address);
       }
       return rv;
 }
Ejemplo n.º 4
0
 //IHeaders headers, IPEndPoint endPoint, string mac)
 public bool Authorize(HttpRequestAuthParameters ap)
 {
     _logger.NoticeFormat("Authorize:[{0}]", ap);
       if (methods.Count == 0) {
     return true;
       }
       try {
     foreach (var m in methods) {
       if (m.Authorize(ap)) {
     return true;
       }
     }
     return false;
       }
       catch (Exception ex) {
     _logger.Error("Failed to authorize", ex);
     return false;
       }
 }
Ejemplo n.º 5
0
        public bool Authorize(HttpRequestAuthParameters ap)//IHeaders headers, IPEndPoint endPoint, string mac)
        {
            if (string.IsNullOrEmpty(ap.Mac))
            {
                return(false);
            }

            var rv = macs.ContainsKey(ap.Mac);

            if (!rv)
            {
                _logger.DebugFormat("Rejecting {0}. Not in MAC whitelist", ap.Mac ?? "<UNKNOWN>");
            }
            else
            {
                _logger.DebugFormat("Accepted {0} via MAC whitelist", ap.Mac);
            }
            return(rv);
        }
Ejemplo n.º 6
0
 //IHeaders headers, IPEndPoint endPoint, string mac)
 public bool Authorize(HttpRequestAuthParameters ap)
 {
     //if (headers == null) {
       //  throw new ArgumentNullException("headers");
       //}
       //string ua;
       //if (!headers.TryGetValue("User-Agent", out ua)) {
       //  return false;
       //}
       if (string.IsNullOrEmpty(ap.UserAgent)) {
     return false;
       }
       var rv = userAgents.ContainsKey(ap.UserAgent);
       if (!rv) {
     _logger.DebugFormat("Rejecting {0}. Not in User-Agent whitelist", ap.UserAgent);
       }
       else {
     _logger.DebugFormat("Accepted {0} via User-Agent whitelist", ap.UserAgent);
       }
       return rv;
 }
Ejemplo n.º 7
0
 public bool Authorize(HttpRequestAuthParameters ap)//IHeaders headers, IPEndPoint endPoint, string mac)
 {
     _logger.NoticeFormat("Authorize:[{0}]", ap);
     if (methods.Count == 0)
     {
         return(true);
     }
     try {
         foreach (var m in methods)
         {
             if (m.Authorize(ap))
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex) {
         _logger.Error("Failed to authorize", ex);
         return(false);
     }
 }
Ejemplo n.º 8
0
        public bool Authorize(HttpRequestAuthParameters ap)//IHeaders headers, IPEndPoint endPoint, string mac)
        {
            //if (endPoint == null) {
            //  return false;
            //}
            //var addr = endPoint.Address;
            if (ap.Address == null)
            {
                return(false);
            }
            var rv = ips.ContainsKey(ap.Address);

            if (!rv)
            {
                _logger.DebugFormat("Rejecting {0}. Not in IP whitelist", ap.Address);
            }
            else
            {
                _logger.DebugFormat("Accepted {0} via IP whitelist", ap.Address);
            }
            return(rv);
        }