def on_ok(self): # Verify Smart Card Available if self.ms2.value: v = self.ms2.get_selected_objects()[0] if v == 'Register': if client.askForRegist(): if Smartcard.isSmartCardAvailable(): self.parentApp.getForm("PIN").destination = "Register" self.parentApp.switchForm("PIN") else: npyscreen.notify_wait("You have no Smartcard connected", title="Failure", form_color="WARNING") else: print "ERROR MESSAGE" elif v == 'Log In': if client.askForLogIn(): if Smartcard.isSmartCardAvailable(): self.parentApp.getForm("PIN").destination = "Log In" self.parentApp.switchForm("PIN") else: self.parentApp.switchForm("Log In") else: print "ERROR MESSAGE" else: npyscreen.notify_wait( "Project Safebox - Security UA\n\n-> José Sequeira 64645\n" + "-> Vasco Santos 64191", title='Project Info', form_color='CRITICAL')
def beforeEditing(self): self.name = "New User" # Give CC Username card = Smartcard.Smartcard(self.pin.value) if Smartcard.isSmartCardAvailable(): self.wgUsername.value, self.bi.value = client.readCC(card) self.bi.editable = False else: self.bi.value = '' self.bi.editable = True self.wgUsername.hidden = True self.pin.hidden = True self.wgUsername.editable = False self.wgPass1.value = ''
def on_ok(self): if len(self.pin.value) == 4 and self.pin.value.isdigit(): if not Smartcard.pinCorrect(self.pin.value): npyscreen.notify_wait("WRONG PIN") else: self.parentApp.getForm(self.destination).pin.value = self.pin.value self.parentApp.switchForm(self.destination) else: npyscreen.notify_wait("WRONG PIN FORMAT")
def on_ok(self): pw = self.wgPass1.value global LogUser card = Smartcard.Smartcard(self.pin.value) LogUser = client.logInUser(self.bi.value, pw, card) if LogUser is not False: npyscreen.notify_wait("Valid Login", title='Sucess', form_color='VERYGOOD') self.parentApp.switchForm("Logged") else: self.text.value = "TRY AGAIN THE LOGIN" self.text.hidden = False npyscreen.notify_wait("INVALID LOGIN", title='Failure', form_color='CRITICAL')
def on_ok(self): if self.wgPass1.value is '' or self.wgPass2.value is '' or\ self.wgUsername is '': npyscreen.notify_wait("Please correctly fill in all fields", title='Error', form_color='WARNING') card = Smartcard.Smartcard(self.pin.value) if self.wgPass2.value != self.wgPass1.value: npyscreen.notify_wait("Not the same password", title='Password Error', form_color='WARNING') elif excludeFromDict(self.wgPass1.value) or len(self.wgPass1.value) < 5: npyscreen.notify_wait("Weak Password. You can do better. We believe in you") elif client.registUser(self.bi.value, self.wgPass1.value, self.mail.value, card): npyscreen.notify_wait("Register for user %s successful\nPrivate Key stored in PrivateKeys/Private_key_<username>" % self.wgUsername.value, title="Success", form_color="VERYGOOD") self.parentApp.switchForm("MAIN") else: npyscreen.notify_wait("There was a problem with your regist", title="Failure", form_color="WARNING")