def server_connect_success(self, server):
        """
        Callback when a server connects successfully.

        We begin "synchronising", where the server object downloads data
        about the server, and then we query it to update our UI
        """
        # Hide "add server" window
        self.builder.get_object("addserver").hide()
        # Append to historical host list on "add server" window
        self.builder.get_object("listaddserverhosts").append([server.host])
        # Fill left tree and get all data (pool, vm, storage, template..)
        Thread(target=server.sync).start()

        # If we use a master password then save the password
        # Password is saved encrypted with XTEA
        encrypted_password = ""
        if self.password:
            x = xtea.crypt("X" * (16-len(self.password)) + self.password,
                           server.password, self.iv)
            encrypted_password = x.encode("hex")
        self.config_hosts[server.host] = [server.user, encrypted_password,
                                          server.ssl, server.verify_ssl]
        self.config['servers']['hosts'] = self.config_hosts
        # Save relation host/user/passwords to configuration
        self.config.write()
Ejemplo n.º 2
0
    def server_connect_success(self, server):
        """
        Callback when a server connects successfully.

        We begin "synchronising", where the server object downloads data
        about the server, and then we query it to update our UI
        """
        # Hide "add server" window
        self.builder.get_object("addserver").hide()
        # Append to historical host list on "add server" window
        self.builder.get_object("listaddserverhosts").append([server.host])
        # Fill left tree and get all data (pool, vm, storage, template..)
        Thread(target=server.sync).start()

        # If we use a master password then save the password
        # Password is saved encrypted with XTEA
        encrypted_password = ""
        if self.password:
            x = xtea.crypt("X" * (16 - len(self.password)) + self.password,
                           server.password, self.iv)
            encrypted_password = x.encode("hex")
        self.config_hosts[server.host] = [
            server.user, encrypted_password, server.ssl, server.verify_ssl
        ]
        self.config['servers']['hosts'] = self.config_hosts
        # Save relation host/user/passwords to configuration
        self.config.write()
Ejemplo n.º 3
0
 def finish_add_server(self, host, user, password, iter=None, ssl = None):
     if self.xc_servers[host].is_connected == True:
         # If we are connected to server (authentication is ok too)
         if (self.selected_iter or iter) and self.selected_type == "server":
             # Remove from left tree, it will be created again with "fill_tree_with_vms"
             if iter:
                 self.treestore.remove(iter)
             else:
                 self.treestore.remove(self.selected_iter)
         # Hide "add server" window
         self.builder.get_object("addserver").hide()
         # Append to historical host list on "add server" window
         self.builder.get_object("listaddserverhosts").append([host])
         # Fill left tree and get all data (pool, vm, storage, template..)
         #self.xc_servers[host].fill_tree_with_vms(self.treestore, self.treeroot, self.treeview)
         self.builder.get_object("lblprogessconnect").set_label("Synchronizing...")
         t = Thread(target=self.xc_servers[host].fill_tree_with_vms, args=(self.treestore, self.treeroot, self.treeview))
         t.start()
         # Remember, we are connected, if we use a master password then save the password
         # Password is saved encrypted with XTEA
         if self.password:
             z = xtea.crypt("X" * (16-len(self.password)) + self.password, password, self.iv)
             self.config_hosts[host] = [user, z.encode("hex"), ssl]
         else:
             self.config_hosts[host] = [user, "", ssl]
         self.config['servers']['hosts'] = self.config_hosts
         # Save relation host/user/passwords to configuration
         self.config.write()
     else:
         # If connection failed.. show add server dialog again
         self.builder.get_object("addserver").show()
         # Append to historical host list on "add server" window
         # And hide progress bar
         self.builder.get_object("wprogressconnect").hide()
         # Show a alert dialog showing error
         self.show_error_dlg("%s" % self.xc_servers[host].error_connecting, "Error connecting")
     
     if self.selected_host == None:
         self.selected_host = host
Ejemplo n.º 4
0
def crypt(key, data, iv):
    """
    Encrypt or decrypt the given data with the given
    key using the XTEA algorithm in CFB mode.
    """
    return xtea.crypt(key, data, iv)
Ejemplo n.º 5
0
def crypt(key, data, iv):
    return xtea.crypt(key, data, iv)
Ejemplo n.º 6
0
def xtea_crypt(password, text, enc):
    passhash = generate_key(password)  #utils.generate_key(
    iv = passhash[len(passhash) - 8:]
    password = passhash[48:]
    return xtea.crypt(password, text, iv, enc=enc)
Ejemplo n.º 7
0
def run_xtea(password, content, mode_encode=True):
    passhash = generate_key(password)
    iv = bytes(passhash[len(passhash) - BYTE_OFFSET:], 'utf-8')
    password = bytes(passhash[48:], 'utf-8')
    return xtea.crypt(password, content, iv, mode='CFB', enc=mode_encode)
Ejemplo n.º 8
0
def crypt(key, data, iv):
    """
    Encrypt or decrypt the given data with the given
    key using the XTEA algorithm in CFB mode.
    """
    return xtea.crypt(key, data, iv)