Ejemplo n.º 1
0
def registerAccount(username, vaultaddress, password):
    """ Init you vault account
    """
    client = SFLvaultClient(str(settings.fileName()))
    try:
        client.user_setup(username, vaultaddress, password)
    except Exception, e:
        ErrorMessage(e)
        return False
Ejemplo n.º 2
0
def registerAccount(username, vaultaddress, password):
    """ Init you vault account
    """
    client = SFLvaultClient(str(settings.fileName()))
    try:
        client.user_setup(username, vaultaddress, password)
    except Exception, e:
        ErrorMessage(e)
        return False
Ejemplo n.º 3
0
def setSecret(wallet_id, password=None):
    settings = Config()
    client = SFLvaultClient(str(settings.fileName()))

    # Disable wallet
    if wallet_id == '0':
        client.cfg.wallet_set(wallet_id, None)
        return True
    # Check if sflvault item exists
    if getSecret() != False:
        question = QtGui.QMessageBox(
            QtGui.QMessageBox.Question,
            "Save password in your wallet",
            "This password already exists."
            "Do you want to replace it ?",
        )
        question.addButton(QtGui.QMessageBox.Save)
        question.addButton(QtGui.QMessageBox.Cancel)
        # Ask to user if he wants to replace old password
        ret = question.exec_()
        if ret == QtGui.QMessageBox.Cancel:
            # Do nothing
            return False
        # Simplify code or keep it simple to understand ?
        else:
            # Replace password
            try:
                return client.cfg.wallet_set(wallet_id, password)
            except Exception, e:
                ErrorMessage(e)
                return False
Ejemplo n.º 4
0
    def getVault(self):
        """Get the SFLVault server vault"""
        global vault
        if vault is None:
            vault = SFLvaultClient(os.environ['SFLVAULT_CONFIG'], shell=True)
            vault.passphrase = u'test'
            vault.username = u'admin'

            def givepass():
                return vault.passphrase

            vault.set_getpassfunc(givepass)
            vault.user_setup(vault.username, self.url, vault.passphrase)
            self.cfg = vault.cfg
        return vault
Ejemplo n.º 5
0
def getAuth():
    """
        Get authentication
    """
    global client
    #if not client:
    client = SFLvaultClient(str(settings.fileName()))

    # Check if wallet is disabled
    if client.cfg.wallet_list()[0][4] == True:
        client.getpassfunc = manual_auth

    try:
        # Search nothing, just to get a valid client
        status = client.search(["}{[a]"])
        # If password is bad ...
        if status == False:
            e = Exception("ConnectionDenied")
            e.message = error_message.tr("Connection Denied")
            raise e
    except Exception, e:
        ErrorMessage(e)
        return False
Ejemplo n.º 6
0
def getAuth():
    """
        Get authentication
    """
    global client
    # if not client:
    client = SFLvaultClient(str(settings.fileName()))

    # Check if wallet is disabled
    if client.cfg.wallet_list()[0][4] == True:
        client.getpassfunc = manual_auth

    try:
        # Search nothing, just to get a valid client
        status = client.search(["}{[a]"])
        # If password is bad ...
        if status == False:
            e = Exception("ConnectionDenied")
            e.message = error_message.tr("Connection Denied")
            raise e
    except Exception, e:
        ErrorMessage(e)
        return False
Ejemplo n.º 7
0
    def getVault(self):
        """Get the SFLVault server vault"""
        global vault
        if vault is None:
            vault = SFLvaultClient(os.environ['SFLVAULT_CONFIG'], shell=True)
            vault.passphrase = u'test'
            vault.username = u'admin'    

            def givepass():
                return vault.passphrase        
            vault.set_getpassfunc(givepass)
            vault.user_setup(vault.username, 
                             self.url, 
                             vault.passphrase)
            self.cfg = vault.cfg
        return vault
Ejemplo n.º 8
0
    def getVault(self):
        """Get the SFLVault server vault"""
        if 'vault' not in globs:
            SFLvaultClient.delete_all_groups = delete_all_groups
            SFLvaultClient.delete_all_users = delete_all_users
            SFLvaultClient.delete_all_machines = delete_all_machines
            SFLvaultClient.delete_all_customers = delete_all_customers

            vault = SFLvaultClient(getConfFileAdmin(), shell=True)

            globs['vault'] = vault
            passphrase = u'test'
            username = u'admin'

            def givepass():
                return passphrase
            globs['vault'].set_getpassfunc(givepass)
            log.warn("testing user setup")
            globs['vault'].user_setup(username, 'http://localhost:6555/vault/rpc', passphrase)
            globs['cfg'] = globs['vault'].cfg
        return globs['vault']
Ejemplo n.º 9
0
    def fillWallet(self):
        self.wallet.clear()
        client = SFLvaultClient(str(self.settings.fileName()))
        backend_list = client.cfg.wallet_list()
        self.wallet.addItem(backend_list[0][1],
                            QtCore.QVariant(backend_list[0][0]))
        # hide useless fields
        if backend_list[0][4] == True:
            self.check_wallet(0)

        for i, backend in enumerate(backend_list[1:]):
            # recommend
            if backend[3] == "Recommended":
                self.wallet.addItem("* - " + backend[1],
                                    QtCore.QVariant(backend[0]))
            # just supported
            elif backend[3] == "Supported":
                self.wallet.addItem(backend[1], QtCore.QVariant(backend[0]))
            # Set current wallet
            if backend[4] == True:
                self.wallet.setCurrentIndex(i + 1)
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        """ Success page """
        QtGui.QWizardPage.__init__(self, parent)
        self.parent = parent
        self.settings = self.parent.parent.settings

        self.setTitle(self.tr("Wallet configuration saved successfully"))

        client = SFLvaultClient(str(self.settings.fileName()))
        backend_list = client.cfg.wallet_list()
        # If manual is choosen
        if backend_list[0][4] == 0:
            label = QtGui.QLabel(self.tr("Wallet is now disabled."))
        else:
            label = QtGui.QLabel(
                self.tr("Your password was saved in your wallet."))
        label.setWordWrap(True)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(label)
        self.setFinalPage(True)
        self.setLayout(layout)
Ejemplo n.º 11
0
from Crypto.PublicKey import ElGamal

from sflvault.client import SFLvaultClient
from sflvault.clientqt.gui.config.config import Config
from error import *

try:
    import keyring
except:
    print "No keyring system supported"

client = None
error_message = QtCore.QObject()

settings = Config()
client_alias = SFLvaultClient(str(settings.fileName()))


def manual_auth():
    password, ok = QtGui.QInputDialog.getText(
        None,
        "SFLvault password",
        "Type your SFLvault password",
        QtGui.QLineEdit.Password,
    )
    return str(password)


def getSecret():
    wallet_setting = str(settings.value("SFLvault/wallet").toString())
    if hasattr(keyring.backend, wallet_setting):