def authenticate(self): mService = MasterService() val = self.ShowModal() if val == wx.ID_OK: pwd = self.pwdBox.GetValue()#def encryptFile(fullFileName, key, overwrite=False): if not(mService.authentication(pwd)): #logging.warning("Login fails") myGui.showErrorDialog(myGui.ERR_LOGIN) global RETRY if RETRY > 1: RETRY=RETRY-1 self.__setLabelText() self.pwdBox.SetValue('') return self.authenticate() else: return False else: #logging.warning("Login successful.") config.setRootPwd(pwd) return True else: return False
def authenticate(self): mService = MasterService() val = self.ShowModal() if val == wx.ID_OK: pwd = self.pwdBox.GetValue( ) #def encryptFile(fullFileName, key, overwrite=False): if not (mService.authentication(pwd)): #logging.warning("Login fails") myGui.showErrorDialog(myGui.ERR_LOGIN) global RETRY if RETRY > 1: RETRY = RETRY - 1 self.__setLabelText() self.pwdBox.SetValue('') return self.authenticate() else: return False else: #logging.warning("Login successful.") config.setRootPwd(pwd) return True else: return False
def onSearch(self): keyword = unicode(self.searchBox.text()) if len(keyword) == 0: myGui.showErrorDialog(myGui.ERR_SEARCH_EMPTY) else: global SEARCHRESULT SEARCHRESULT = self.pwdFunc.getSearchResult(keyword) self.reloadWindow(myGui.ID_TAG_SEARCH)
def copyToClipboard(self,event): if len(self.txtPwd.GetValue().strip()) > 0: text_data = wx.TextDataObject(self.txtPwd.GetValue()) if wx.TheClipboard.Open(): wx.TheClipboard.SetData(text_data) wx.TheClipboard.Close() myGui.showInfoDialog(myGui.INFO_PWD_CLIPBOARD ) else: myGui.showErrorDialog(myGui.ERR_PWD_COPY)
def copyToClipboard(self, event): if len(self.txtPwd.GetValue().strip()) > 0: text_data = wx.TextDataObject(self.txtPwd.GetValue()) if wx.TheClipboard.Open(): wx.TheClipboard.SetData(text_data) wx.TheClipboard.Close() myGui.showInfoDialog(myGui.INFO_PWD_CLIPBOARD) else: myGui.showErrorDialog(myGui.ERR_PWD_COPY)
def onSearch(self,event): kwBox = self.FindWindowByName(myGui.NAME_TEXTBOX_SEARCH) keyword = kwBox.GetValue() if(len(keyword)==0): myGui.showErrorDialog(myGui.ERR_SEARCH_EMPTY) kwBox.SetFocus() else: self.searchResult = self.pwdService.getSearchResult(keyword) self.reLoadWindow(myGui.ID_TAG_SEARCH)
def onSearch(self, event): kwBox = self.FindWindowByName(myGui.NAME_TEXTBOX_SEARCH) keyword = kwBox.GetValue() if (len(keyword) == 0): myGui.showErrorDialog(myGui.ERR_SEARCH_EMPTY) kwBox.SetFocus() else: self.searchResult = self.pwdService.getSearchResult(keyword) self.reLoadWindow(myGui.ID_TAG_SEARCH)
def onSave(self): var = self.exec_() if var: tagName = unicode(self.tag.text()) if not tagName: myGui.showErrorDialog(myGui.ERR_NEWTAG_EMPTY) self.onSave() elif not self.tagFunc.isTagNameValid(tagName, self.tagID): myGui.showErrorDialog(myGui.ERR_NEWTAG_UNIQUE) self.onSave() else: self.tagFunc.editTag(self.tagID, tagName)
def doSave(self): pwdFunc = PwdFunc() var = self.exec_() if var: if len(unicode(self.title.text())) == 0: myGui.showErrorDialog(myGui.ERR_TITLE_EMPTY) self.title.setFocus() self.doSave() elif len(unicode(self.account.text())) == 0: myGui.showErrorDialog(myGui.ERR_ACCOUNT_EMPTY) self.account.setFocus() self.doSave() elif len(unicode(self.password.text())) == 0: myGui.showErrorDialog(myGui.ERR_PWD_EMPTY) self.password.setFocus() self.doSave() elif not pwdFunc.isTitleNameValid(unicode(self.title.text())): myGui.showErrorDialog(myGui.ERR_ACCOUNTTITLE_UNIQUE) self.title.setFocus() self.doSave() else: nTitle = unicode(self.title.text()) nDescription = unicode(self.description.toPlainText()) nAccount = unicode(self.account.text()) nPassword = unicode(self.password.text()) nSecret = unicode(self.secret.toPlainText()).encode('utf-8') nTagIDs = [] cnt = self.tags.count() for idx in xrange(cnt): if self.tags.item(idx).isSelected(): nTagIDs.append(self.tagIDList[idx]) pwdFunc.addAccount(nTitle, nDescription, nAccount, nPassword, nSecret, nTagIDs)
def onSave(self): val = self.ShowModal() if val == wx.ID_OK: name = self.GetValue() if not name: myGui.showErrorDialog(myGui.ERR_NEWTAG_EMPTY) self.onSave() elif not self.tagService.isTagNameValid(name,self.tagId): myGui.showErrorDialog(myGui.ERR_NEWTAG_UNIQUE) self.onSave() else: self.tagService.editTag(self.tagId,name)
def onSave(self): tagService = TagService() val = self.ShowModal() if val == wx.ID_OK: name = self.GetValue() if not name: myGui.showErrorDialog(myGui.ERR_NEWTAG_EMPTY) self.onSave() elif not tagService.isTagNameValid(name): myGui.showErrorDialog(myGui.ERR_NEWTAG_UNIQUE) self.onSave() else: tagService.addNewTag(name)
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 doSave(self): pwdService = PwdService() val = self.ShowModal() if val == wx.ID_OK: if len(self.title.GetValue()) == 0: myGui.showErrorDialog(myGui.ERR_TITLE_EMPTY) self.title.SetFocus() self.doSave() elif len(self.account.GetValue()) ==0: myGui.showErrorDialog(myGui.ERR_ACCOUNT_EMPTY) self.account.SetFocus() self.doSave() elif len(self.password.GetValue()) ==0: myGui.showErrorDialog(myGui.ERR_PWD_EMPTY) self.password.SetFocus() self.doSave() elif not pwdService.isTagNameValid(self.title.GetValue()): myGui.showErrorDialog(myGui.ERR_ACCOUNTTITLE_UNIQUE) self.title.SetFocus() self.doSave() else: vTitle = self.title.GetValue() vDescription = self.description.GetValue() vAccount = self.account.GetValue() vPassword = self.password.GetValue() vSecret = self.secret.GetValue() vTagIds = [] for idx in self.tags.GetSelections(): vTagIds.append(self.tags.GetClientData(idx)) pwdService.addAccount(vTitle,vDescription,vAccount,vPassword,vSecret, vTagIds)
def onSave(self): tagFunc = TagFunc() self.tag.setFocus() var = self.exec_() if var: tagName = unicode(self.tag.text()) if not tagName: myGui.showErrorDialog(myGui.ERR_NEWTAG_EMPTY) self.onSave() elif not tagFunc.isTagNameValid(tagName): myGui.showErrorDialog(myGui.ERR_NEWTAG_UNIQUE) self.onSave() else: tagFunc.addNewTag(tagName)
def onSave(self): val = self.ShowModal() if val == wx.ID_OK: name = self.GetValue() if not name: myGui.showErrorDialog(myGui.ERR_NEWTAG_EMPTY) self.onSave() elif not self.tagService.isTagNameValid(name, self.tagId): myGui.showErrorDialog(myGui.ERR_NEWTAG_UNIQUE) self.onSave() else: self.tagService.editTag(self.tagId, name)
def onChg(self): pwdFunc = PwdFunc() masterFunc = MasterFunc() self.oldPwd.setFocus() val = self.exec_() if val: if len(unicode(self.oldPwd.text())) < 5 or len(unicode(self.oldPwd.text())) > 16: myGui.showErrorDialog(myGui.ERR_MASTERPWD_LEN) self.oldPwd.setFocus() self.onChg() elif len(unicode(self.newPwd.text())) < 5 or len(unicode(self.newPwd.text())) > 16: myGui.showErrorDialog(myGui.ERR_MASTERPWD_LEN) self.newPwd.setFocus() self.onChg() elif unicode(self.newPwd.text()) != unicode(self.newPwd2.text()): myGui.showErrorDialog(myGui.ERR_NEWMASTER_IDENTICAL) self.newPwd.clear() self.newPwd2.clear() self.newPwd.setFocus() self.onChg() elif unicode(self.oldPwd.text()) != config.getMasterPwd(): myGui.showErrorDialog(myGui.ERR_OLDMASTER_WRONG) self.oldPwd.setFocus() self.onChg() else: masterFunc.changeMasterPwd(unicode(self.newPwd.text())) myGui.showInfoDialog(myGui.INFO_MASTERPWD)
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 doSave(self): pwdService = PwdService() val = self.ShowModal() if val == wx.ID_OK: if len(self.title.GetValue()) == 0: myGui.showErrorDialog(myGui.ERR_TITLE_EMPTY) self.title.SetFocus() self.doSave() elif len(self.account.GetValue()) == 0: myGui.showErrorDialog(myGui.ERR_ACCOUNT_EMPTY) self.account.SetFocus() self.doSave() elif len(self.password.GetValue()) == 0: myGui.showErrorDialog(myGui.ERR_PWD_EMPTY) self.password.SetFocus() self.doSave() elif not pwdService.isTagNameValid(self.title.GetValue()): myGui.showErrorDialog(myGui.ERR_ACCOUNTTITLE_UNIQUE) self.title.SetFocus() self.doSave() else: vTitle = self.title.GetValue() vDescription = self.description.GetValue() vAccount = self.account.GetValue() vPassword = self.password.GetValue() vSecret = self.secret.GetValue() vTagIds = [] for idx in self.tags.GetSelections(): vTagIds.append(self.tags.GetClientData(idx)) pwdService.addAccount(vTitle, vDescription, vAccount, vPassword, vSecret, vTagIds)
def doGenerate(self,event): patternList=[] if self.chkLower.GetValue(): patternList.append('lower') if self.chkUpper.GetValue(): patternList.append('upper') if self.chkNumber.GetValue(): patternList.append('number') if self.chkChar.GetValue(): patternList.append('punc') if len(patternList)==0: myGui.showErrorDialog(myGui.ERR_PWD_EMPTYPATTERN) else: try: length = int(self.txtLength.GetValue()) if length>0: self.txtPwd.SetValue(util.getRadomString(length, patternList)) self.btGen.SetLabel('Regenerate') self.btCopy.Enable(True) else: myGui.showErrorDialog(myGui.ERR_PWD_LEN) self.txtLength.SetFocus() except ValueError: myGui.showErrorDialog(myGui.ERR_PWD_LEN) self.txtLength.SetFocus()
def doGenerate(self, event): patternList = [] if self.chkLower.GetValue(): patternList.append('lower') if self.chkUpper.GetValue(): patternList.append('upper') if self.chkNumber.GetValue(): patternList.append('number') if self.chkChar.GetValue(): patternList.append('punc') if len(patternList) == 0: myGui.showErrorDialog(myGui.ERR_PWD_EMPTYPATTERN) else: try: length = int(self.txtLength.GetValue()) if length > 0: self.txtPwd.SetValue( util.getRadomString(length, patternList)) self.btGen.SetLabel('Regenerate') self.btCopy.Enable(True) else: myGui.showErrorDialog(myGui.ERR_PWD_LEN) self.txtLength.SetFocus() except ValueError: myGui.showErrorDialog(myGui.ERR_PWD_LEN) self.txtLength.SetFocus()
def authenticate(self): mFunc = MasterFunc() self.setLabelText() self.pwd.setFocus() var = self.exec_() if var: inPwd = unicode(self.pwd.text()) if not (mFunc.authenticate(inPwd)): myGui.showErrorDialog(myGui.ERR_LOGIN) global RETRY if RETRY > 1: RETRY -= 1 self.setLabelText() self.pwd.clear() return self.authenticate() else: return False else: config.setMasterPwd(inPwd) return True else: return False
def doGenerate(self): patternList = [] if self.low.isChecked(): patternList.append('lower') if self.up.isChecked(): patternList.append('upper') if self.num.isChecked(): patternList.append('number') if self.punc.isChecked(): patternList.append('punc') if len(patternList) == 0: myGui.showErrorDialog(myGui.ERR_PWD_EMPTYPATTERN) else: try: length = int(unicode(self.leng.text())) if length > 0: self.pwd.setText(util.getRandomString(length, patternList)) self.genBtn.setText('Re&generate') self.cpBtn.setEnabled(True) else: myGui.showErrorDialog(myGui.ERR_PWD_LEN) except ValueError: myGui.showErrorDialog(myGui.ERR_PWD_LEN)