def change_password(dta): """Return a string with a message describing how the request went.""" if cereconf.ENABLE_BOFHD_CRYPTO: # TODO: Check server cert from M2Crypto.m2xmlrpclib import Server, SSL_Transport svr = Server(cereconf.BOFH_URL, SSL_Transport(), encoding='iso8859-1') else: svr = xmlrpclib.Server(cereconf.BOFH_URL, encoding='iso8859-1') # Simple sanity check of values for k in 'newpass', 'pass', 'uname': if dta.getfirst(k, '') == '': return "Field %s cannot be blank" % k if dta.getfirst('newpass') != dta.getfirst('newpass2'): return "New passwords must be equal" try: secret = svr.login(dta.getfirst('uname'), dta.getfirst('pass')) svr.run_command(secret, "account_password", dta.getfirst('uname'), dta.getfirst('newpass')) except xmlrpclib.Fault, m: if m.faultCode == 666: return "The operation did not succeed: <pre>%s</pre>" % m.faultString else: return _internalError(m.faultString, sys.exc_info())
def __init__(self, url, bofh_client, cacert_file=None, rand_cmd=None): self.__bc = bofh_client if url.startswith("https"): from M2Crypto.m2xmlrpclib import Server, SSL_Transport from M2Crypto import SSL if not os.path.exists('/dev/random') and rand_cmd is not None: from M2Crypto.Rand import rand_add rand_file = os.popen(rand_cmd, 'r') rand_string = rand_file.read() rand_file.close() rand_add(rand_string, len(rand_string)) ctx = SSL.Context('sslv3') if cacert_file is not None: ctx.load_verify_info(cacert_file) ctx.set_verify(SSL.verify_peer, 10) self.conn = Server(url, SSL_Transport(ctx), encoding='iso8859-1') else: self.conn = xmlrpclib.Server(url, encoding='iso8859-1')
def xmlrpc_srv(): # Server is ../https/START_xmlrpc.py or ./xmlrpc_srv.py. zs = Server('https://127.0.0.1:39443', SSL_Transport()) print zs.Testing(1, 2, 3) print zs.BringOn('SOAP')
def ZServerSSL(): # Server is Zope-2.6.4 on ZServerSSL/0.12. zs = Server('https://127.0.0.1:8443/', SSL_Transport()) print zs.propertyMap()