예제 #1
0
 def setup(self):
   self.suppress_body = False
   if self.server.enable_ssl:
     self.connection = self.request
     self.rfile = socket._fileobject(self.request, "rb", self.rbufsize)
     self.wfile = socket._fileobject(self.request, "wb", self.wbufsize)
   else:
     SimpleXMLRPCRequestHandler.setup(self)
예제 #2
0
 def do_POST(self):
     try:
         remote_token = self.headers["Bitbake-token"]
     except:
         remote_token = None
     if 0 and remote_token != self.server.connection_token and remote_token != "observer":
         self.report_503()
     else:
         if remote_token == "observer":
             self.server.readonly = True
         else:
             self.server.readonly = False
         SimpleXMLRPCRequestHandler.do_POST(self)
예제 #3
0
 def do_POST(self):
     try:
         remote_token = self.headers["Bitbake-token"]
     except:
         remote_token = None
     if 0 and remote_token != self.server.connection_token and remote_token != "observer":
         self.report_503()
     else:
         if remote_token == "observer":
             self.server.readonly = True
         else:
             self.server.readonly = False
         SimpleXMLRPCRequestHandler.do_POST(self)
예제 #4
0
 def __init__(self, request, client_address, server):
     # mengosongkan variabel datas, agar setiap aktivitas tidak ter-stack
     datas.clear()
     # inisialisasi timestamp
     request_date = datetime.now().strftime('%A %d-%m-%Y %H:%M')
     # melakukan print ip serta port dari aktivitas client
     print("Alamat IP Client: ", client_address[0], " Port: ",
           client_address[1])
     # melakukan print timestamp dari aktivitas client
     print("Waktu Aktivitas Client: ", request_date)
     # menyimpan data ip, port, serta timestamp kedalam variabel datas
     datas.extend([client_address[0], client_address[1], request_date])
     SimpleXMLRPCRequestHandler.__init__(self, request, client_address,
                                         server)
예제 #5
0
 def do_POST(self):
   """Add authentication to the XMLRPC handlers."""
   log.debug('do_POST: path %s', self.path)
   log.debug('  content-length: %s', int(self.headers.getheader('content-length', 0)))
   #print '  headers: %s' % self.headers
   if self.headers.getheader('Authorization') is None:
     log.debug('do_POST: No auth received')
     self.do_AUTHHEAD()
     self.wfile.write('No auth received')
   elif authorizor.valid_auth(self.headers.getheader('Authorization')):
     SimpleXMLRPCRequestHandler.do_POST(self)
   else:
     log.info('do_POST: invalid auth')
     self.do_AUTHHEAD()
     self.wfile.write('Not authenticated: ')
     self.wfile.write(self.headers.getheader('Authorization'))
예제 #6
0
 def parse_request(self):
     if SimpleXMLRPCRequestHandler.parse_request(self):
         if self.auth(self.headers):
             return True
         else:
             self.send_error(401, 'Unauthorized')
     return False
예제 #7
0
 def parse_request(myself):
     if SimpleXMLRPCRequestHandler.parse_request(myself):
         if self.authenticate(myself.headers):
             return True
         else:
             myself.send_error(401, "Authentication failure")
             return False
예제 #8
0
 def parse_request(myself):
     if SimpleXMLRPCRequestHandler.parse_request(myself):
         if self.authenticate(myself.headers):
             return True
         else:
             myself.send_error(401, "Authentication failure")
             return False
예제 #9
0
    def decode_request_content(self, data):
        global count
        count = count + 1
        data = SimpleXMLRPCRequestHandler.decode_request_content(self, data)
        doc = parseString(data)
        ps = doc.getElementsByTagName("params")[0]

        methodName = doc.getElementsByTagName(
            "methodName")[0].childNodes[0].nodeValue
        self.logger.info("-- %s (from %s) --" % (methodName, self.client_ip))
        fname = "none.xml"
        if methodName == "system.multicall":
            self.insert_multicall_client_ip(doc)
            fname = "multi_%d.xml" % count
        else:
            pdoc = parseString(''' <param><value>
                  <string>%s</string>
                  </value></param>''' % (self.client_ip, ))
            p = pdoc.firstChild.cloneNode(True)
            fname = "single_%d.xml" % count
            if methodName in self.secure_methods:
                ps.appendChild(p)
        if 0:
            with open(fname, "w") as f:
                f.write("%s" % doc.toxml())
                print("[xmlrpc] Writing XML to %s" % fname)
        return doc.toxml()
            def parse_request(request):
                if SimpleXMLRPCRequestHandler.parse_request(request):
                    if self.authenticate(request.headers):
                        return True

                    else:
                        request.send_error(401,'Authentication failed,try again')
                return False
 def parse_request(myself):
     if SimpleXMLRPCRequestHandler.parse_request(myself):
         basic, foo, encoded = myself.headers.get('Authorization').partition(' ')
         username, foo, password = b64decode(encoded).decode('UTF-8').partition(':')
         if username == 'admin':
             return True
         else:
             myself.send_error(401, 'Authentication failed')
             return False
예제 #12
0
 def parse_request(self):
     if SimpleXMLRPCRequestHandler.parse_request(self):
         # Next we authenticate
         if self.authenticate(self.headers):
             return True
         else:
             # if authentication fails, tell the client
             self.send_error(401, 'Authentication failed')
     return False
예제 #13
0
 def parse_request(self):
     if SimpleXMLRPCRequestHandler.parse_request(self):
         # Next we authenticate
         if self.authenticate(self.headers):
             return True
         else:
             # if authentication fails, tell the client
             self.send_error(401, 'Authentication failed')
     return False
            def parse_request(request):
                if SimpleXMLRPCRequestHandler.parse_request(request):
                    if self.authenticate(request.headers):
                        return True

                    else:
                        request.send_error(401,
                                           'Authentication failed,try again')
                return False
 def parse_request(request):
     if SimpleXMLRPCRequestHandler.parse_request(request):
         # authenticate
         if self.authenticate(request.headers):
             return True
         else:
             # if authentication fails return 401
             request.send_error(401,
                                'Authentication failed, Try agin.')
     return False
예제 #16
0
 def parse_request(self):
     # first, call the original implementation which returns
     # True if all OK so far
     if SimpleXMLRPCRequestHandler.parse_request(self):
         # next we authenticate
         if self.authenticate(self.headers):
             return True
         else:
             # if authentication fails, tell the client
             self.send_error(401, 'Authentication failed')
     return False
예제 #17
0
 def parse_request(myself):
     if SimpleXMLRPCRequestHandler.parse_request(myself):
         basic, foo, encoded = myself.headers.get(
             'Authorization').partition(' ')
         username, foo, password = b64decode(encoded).decode(
             'UTF-8').partition(':')
         if username == 'admin':
             return True
         else:
             myself.send_error(401, 'Authentication failed')
             return False
예제 #18
0
 def parse_request(self):
     # first, call the original implementation which returns
     # True if all OK so far
     if SimpleXMLRPCRequestHandler.parse_request(self):
         # next we authenticate
         if self.authenticate(self.headers):
             return True
         else:
             # if authentication fails, tell the client
             self.send_error(401, 'Authentication failed')
     return False
예제 #19
0
 def do_POST(self):
     self._userrole = self.checklogindata()
     if self._userrole > 0:
         urlPath = getUrlPath(self.path)
         if urlPath in HttpsHandler.rpc_paths:
             return SimpleXMLRPCRequestHandler.do_POST(self)
         elif urlPath[:8] == '/getsong':
             SongSender.handlegetsong(self, 'POST')
         elif urlPath[:6] == '/songs':
             self.__handleweb('POST', self._userrole)
         elif urlPath[:4] == "/m3u":
             SongSender.handle_get_playlist(self, 'POST')
         elif urlPath[:8] == "/public/":
             SongSender.handlePublicFolderView(self, urlPath[8:])
         else:
             SongSender.handleerror(self)
예제 #20
0
 def log_message(self, format, *args):
     if 0:
         SimpleXMLRPCRequestHandler.log_message(self, format, *args)
예제 #21
0
 def __init__(self,req,addr,server):
     self.client_ip,self.client_port = addr
     print(self.client_ip)
     SimpleXMLRPCRequestHandler.__init__(self,req,addr,server)
예제 #22
0
 def do_POST(self):
     ip_address, ip_port = self.client_address
     if ip_address!='127.0.0.1':
         self.report_404()
         return
     SimpleXMLRPCRequestHandler.do_POST(self)
예제 #23
0
 def log_message(self, format, *args):
     if 0:
         SimpleXMLRPCRequestHandler.log_message(self, format, *args)
예제 #24
0
 def end_headers(self):
     self.send_header("Access-Control-Allow-Headers",
                      "Origin, X-Requested-With, Content-Type, Accept")
     self.send_header("Access-Control-Allow-Origin", "*")
     SimpleXMLRPCRequestHandler.end_headers(self)
예제 #25
0
  def do_POST(self, command='POST'):
    (scheme, netloc, path, params, query, frag) = urlparse(self.path)
    qs = parse_qs(query)
    self.getHostInfo()
    self.command = command

    if not self.performAuthChecks(scheme, netloc, path, qs): return

    posted = None
    self.post_data = tempfile.TemporaryFile()
    self.old_rfile = self.rfile
    try:
      # First, buffer the POST data to a file...
      clength = cleft = int(self.headers.get('content-length'))
      while cleft > 0:
        rbytes = min(64*1024, cleft)
        self.post_data.write(self.rfile.read(rbytes))
        cleft -= rbytes

      # Juggle things so the buffering is invisble.
      self.post_data.seek(0)
      self.rfile = self.post_data

      ctype, pdict = cgi.parse_header(self.headers.get('content-type'))
      if ctype.lower() == 'multipart/form-data':
        self.post_data.seek(0)
        posted = cgi.FieldStorage(
          fp=self.post_data,
          headers=self.headers,
          environ={'REQUEST_METHOD': command, 'CONTENT_TYPE': ctype})
      elif ctype.lower() == 'application/x-www-form-urlencoded':
        if clength >= 50*1024*1024:
          raise Exception(("Refusing to parse giant posted query "
                           "string (%s bytes).") % clength)
        posted = cgi.parse_qs(self.rfile.read(clength), 1)
      elif self.host_config.get('xmlrpc', False):
        # We wrap the XMLRPC request handler in _BEGIN/_END in order to
        # expose the request environment to the RPC functions.
        RCI = self.server.RCI
        return RCI._END(SimpleXMLRPCRequestHandler.do_POST(RCI._BEGIN(self)))

      self.post_data.seek(0)
    except socket.error:
      pass
    except Exception as e:
      logging.Log([('err', 'POST error at %s: %s' % (path, e))])
      self.sendResponse('<h1>Internal Error</h1>\n', code=500, msg='Error')
      self.rfile = self.old_rfile
      self.post_data = None
      return

    if not self.performPostAuthChecks(scheme, netloc, path, qs, posted): return
    try:
      return self.handleHttpRequest(scheme, netloc, path, params, query, frag,
                                    qs, posted)
    except socket.error:
      pass
    except Exception as e:
      logging.Log([('err', 'Error handling POST at %s: %s' % (path, e))])
      self.sendResponse('<h1>Internal Error</h1>\n', code=500, msg='Error')

    self.rfile = self.old_rfile
    self.post_data = None
예제 #26
0
 def end_headers(self):
     """ End response header with adding Access-Control-Allow-Origin
     
     This is done to enable CORS request from all clients """
     self.send_header("Access-Control-Allow-Origin", "*")
     SimpleXMLRPCRequestHandler.end_headers(self)
예제 #27
0
 def parse_request(self):
     # first, call the original implementation which returns
     # True if all OK so far
     if SimpleXMLRPCRequestHandler.parse_request(self):
         return True
     return False
예제 #28
0
 def __init__(self, request, client_address, server):
     self.client_ip, self.client_port = client_address
     self.logger.debug("==== received XMLRPC (from %s:%s)" %
                       (self.client_ip, self.client_port))
     SimpleXMLRPCRequestHandler.__init__(self, request, client_address,
                                         server)
예제 #29
0
 def end_headers(self):
     self.send_header("Access-Control-Allow-Headers",
                      "Origin, X-Requested-With, Content-Type, Accept")
     self.send_header("Access-Control-Allow-Origin", "*")
     SimpleXMLRPCRequestHandler.end_headers(self)
예제 #30
0
 def end_headers(self):
     # Hack to add a specific header
     # Thk to: https://gist.github.com/rca/4063325
     self.send_my_headers()
     SimpleXMLRPCRequestHandler.end_headers(self)
예제 #31
0
 def end_headers(self):
     # Hack to add a specific header
     # Thk to: https://gist.github.com/rca/4063325
     self.send_my_headers()
     SimpleXMLRPCRequestHandler.end_headers(self)
예제 #32
0
 def do_POST(self):
     try:
         SimpleXMLRPCRequestHandler.do_POST(self)
     except Exception as e:
         print("do_post exception:", e)
예제 #33
0
 def __init__(self, request, client_address, server):
     self.server = server
     SimpleXMLRPCRequestHandler.__init__(self, request, client_address, server)
예제 #34
0
 def __init__(self, request, client_address, server):
     self.server = server
     SimpleXMLRPCRequestHandler.__init__(self, request, client_address, server)
예제 #35
0
 def __init__(self, *args, **kwargs):
   SimpleXMLRPCRequestHandler.__init__(self, *args, **kwargs)
   self.HTTPRequestHandler = SimpleHTTPRequestHandler.__init__(self, *args, **kwargs)
예제 #36
0
 def send_header(self, hdr, value):
     self.assert_no_newline(value)
     return SimpleXMLRPCRequestHandler.send_header(self, hdr, value)
예제 #37
0
 def end_headers(self):
     """ End response header with adding Access-Control-Allow-Origin
     
     This is done to enable CORS request from all clients """
     self.send_header("Access-Control-Allow-Origin", "*")
     SimpleXMLRPCRequestHandler.end_headers(self)