Esempio n. 1
0
 def showHidePassword (self,event):
     if self.chk.GetValue():
         self.password.SetValue(util.decrypt(config.getRootPwd(),self.accountObj.pwd))
         self.secret.SetValue(util.decrypt(config.getRootPwd(),self.accountObj.secret) if self.accountObj.secret else "")
     else:
         self.password.SetValue(myGui.INFO_HIDE_TXT)
         self.secret.SetValue(myGui.INFO_HIDE_TXT)
Esempio n. 2
0
 def showHidePassword(self, event):
     if self.chk.GetValue():
         self.password.SetValue(
             util.decrypt(config.getRootPwd(), self.accountObj.pwd))
         self.secret.SetValue(
             util.decrypt(config.getRootPwd(), self.accountObj.secret
                          ) if self.accountObj.secret else "")
     else:
         self.password.SetValue(myGui.INFO_HIDE_TXT)
         self.secret.SetValue(myGui.INFO_HIDE_TXT)
Esempio n. 3
0
    def onChange(self):
        pwdService = PwdService()
        masterService = MasterService()

        val = self.ShowModal()
        if val == wx.ID_OK:
            if len(self.oldPwd.GetValue()) < 5 or len(
                    self.oldPwd.GetValue()) > 16:
                myGui.showErrorDialog(myGui.ERR_ROOTPWD_LEN)
                self.oldPwd.SetFocus()
                self.onChange()
            elif len(self.newPwd.GetValue()) < 5 or len(
                    self.newPwd.GetValue()) > 16:
                myGui.showErrorDialog(myGui.ERR_ROOTPWD_LEN)
                self.newPwd.SetFocus()
                self.onChange()
            elif self.newPwd.GetValue() != self.newPwd2.GetValue():
                myGui.showErrorDialog(myGui.ERR_NEWROOT_IDENTICAL)
                self.newPwd.SetValue('')
                self.newPwd2.SetValue('')
                self.newPwd.SetFocus()
                self.onChange()
            elif self.oldPwd.GetValue() != config.getRootPwd():
                myGui.showErrorDialog(myGui.ERR_OLDROOT_WRONG)
                self.oldPwd.SetFocus()
                self.onChange()

        # validation checking done
            else:
                masterService.changeRootPwd(self.newPwd.GetValue())
                myGui.showInfoDialog(myGui.INFO_ROOTPWD)
def export():
    """
    do the export logic
    """
    msg  = '' #return value
    conn = __getConnection()
    #root password
    key  = config.getRootPwd()


    sql = 'select title,  username,password, secret, description FROM ACCOUNT'
    cur = conn.cursor()
    cur.execute(sql)

    lines = []
    for row in cur.fetchall():
        (title,uid,pwd,secret,description) = row
        #decrypt
        title = '"' + title
        if secret:
            secret = util.decrypt(key, secret)
        uid = util.decrypt(key, uid)
        pwd = util.decrypt(key, pwd)
        note = description + u"\\n>>>>>>>>>>>>>>>>>>>>>>\\n" + secret + u'"'
        note = re.sub("\n|\r","\\n",note)
        lines.append(u'","'.join((title,uid,pwd,u"",note)))
    cur.close()
    # print re.sub(r"\\u([a-f0-9]{4})", lambda mg: unichr(int(mg.group(1), 16)), lines.__repr__())

    print "\n".join(lines)
Esempio n. 5
0
 def onChange(self):
     pwdService = PwdService()
     masterService = MasterService()
     
     val = self.ShowModal()
     if val == wx.ID_OK:
         if len(self.oldPwd.GetValue()) < 5 or len(self.oldPwd.GetValue()) > 16:
             myGui.showErrorDialog(myGui.ERR_ROOTPWD_LEN)
             self.oldPwd.SetFocus()
             self.onChange()
         elif len(self.newPwd.GetValue()) < 5 or len(self.newPwd.GetValue()) >16:
             myGui.showErrorDialog(myGui.ERR_ROOTPWD_LEN)
             self.newPwd.SetFocus()
             self.onChange()
         elif self.newPwd.GetValue() != self.newPwd2.GetValue():
             myGui.showErrorDialog(myGui.ERR_NEWROOT_IDENTICAL)
             self.newPwd.SetValue('')
             self.newPwd2.SetValue('')
             self.newPwd.SetFocus()
             self.onChange()
         elif self.oldPwd.GetValue() != config.getRootPwd():
             myGui.showErrorDialog(myGui.ERR_OLDROOT_WRONG)
             self.oldPwd.SetFocus()
             self.onChange()
         
     # validation checking done
         else:
             masterService.changeRootPwd(self.newPwd.GetValue())
             myGui.showInfoDialog(myGui.INFO_ROOTPWD)
def upgrade():
    """
    do the upgrade logic
    """
    msg  = '' #return value
    conn = __getConnection()
    #root password
    key  = config.getRootPwd()

    if __table_exists(conn, "config"):
        version = read_data_version(conn)
        if version != config.VERSION:
            update_data_version(conn)
            # do upgrade if needed, update version 
    else:
        #check if Account.secret column exits
        v10x = not __column_exists(conn, 'account','secret')
        #do upgrade here
        msg  = __upgrade_10x_110(key,conn,v10x)

        
        #create config table
        sql = """
            CREATE TABLE CONFIG ( 
            name TEXT(200) NOT NULL, 
            value TEXT(500) NOT NULL 
            ); """
        ins_sql = """insert into config(name,value) values(?,?) ;"""

        cur = conn.cursor()
        cur.execute(sql)
        cur.execute(ins_sql,('version',config.VERSION,))
        conn.commit()
        cur.close()
    return msg
Esempio n. 7
0
def export():
    """
    do the export logic
    """
    msg = ''  #return value
    conn = __getConnection()
    #root password
    key = config.getRootPwd()

    sql = 'select title,  username,password, secret, description FROM ACCOUNT'
    cur = conn.cursor()
    cur.execute(sql)

    lines = []
    for row in cur.fetchall():
        (title, uid, pwd, secret, description) = row
        #decrypt
        title = '"' + title
        if secret:
            secret = util.decrypt(key, secret)
        uid = util.decrypt(key, uid)
        pwd = util.decrypt(key, pwd)
        note = description + u"\\n>>>>>>>>>>>>>>>>>>>>>>\\n" + secret + u'"'
        note = re.sub("\n|\r", "\\n", note)
        lines.append(u'","'.join((title, uid, pwd, u"", note)))
    cur.close()
    # print re.sub(r"\\u([a-f0-9]{4})", lambda mg: unichr(int(mg.group(1), 16)), lines.__repr__())

    print "\n".join(lines)
Esempio n. 8
0
 def onCopyPassword(self, event):
     account = self.pwdService.getPwdById(self.selectedPwdId)
     # decrypted password
     dePwd = util.decrypt(config.getRootPwd(), account.pwd)
     text_data = wx.TextDataObject(dePwd)
     if wx.TheClipboard.Open():
         wx.TheClipboard.SetData(text_data)
         wx.TheClipboard.Close()
     myGui.showInfoDialog(myGui.INFO_CLIPBOARD, account.title)
Esempio n. 9
0
 def loadData(self):
     a = self.accountObj
     self.title.SetValue(a.title)
     self.username.SetValue(a.username)
     self.description.SetValue(a.description)
     self.secret.SetValue(util.decrypt(config.getRootPwd(), a.secret) if a.secret else "")
     for tag in a.tags:
         name = tag.name
         self.tags.SetStringSelection(name,True)
Esempio n. 10
0
 def onCopyPassword(self,event):
     account = self.pwdService.getPwdById(self.selectedPwdId)
     # decrypted password
     dePwd = util.decrypt(config.getRootPwd(),account.pwd)
     text_data = wx.TextDataObject(dePwd)
     if wx.TheClipboard.Open():
         wx.TheClipboard.SetData(text_data)
         wx.TheClipboard.Close()
     myGui.showInfoDialog(myGui.INFO_CLIPBOARD , account.title)
Esempio n. 11
0
 def loadData(self):
     a = self.accountObj
     self.title.SetValue(a.title)
     self.username.SetValue(a.username)
     self.description.SetValue(a.description)
     self.secret.SetValue(
         util.decrypt(config.getRootPwd(), a.secret) if a.secret else "")
     for tag in a.tags:
         name = tag.name
         self.tags.SetStringSelection(name, True)