Beispiel #1
0
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = parent.frame
        self.keychain = MyKeyChain()

        self.Bind(wx.EVT_BUTTON, self.OnButton)
Beispiel #2
0
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()
        self.type = self.getType()

        self.Bind(wx.EVT_TEXT, self.OnText)
Beispiel #3
0
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()

        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio)
        self.Bind(wx.EVT_BUTTON, self.OnButton)
        self.Bind(wx.EVT_TEXT, self.OnText)
Beispiel #4
0
class PasswordValidator(wx.PyValidator):
    """This class acts as validator to the values, the user 
    is able to set in the dialog created by class settingsDialog
    """
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = parent.frame
        self.keychain = MyKeyChain()

        self.Bind(wx.EVT_BUTTON, self.OnButton)

    def OnButton(self, event=None):
        textCtrl = self.GetWindow()
        setOptions = {
        "setFullAccess": "Set the full access password",
        "setRestrictedAccess": "Set the restricted access password",
        "setViewAccess": "Set the view access password",
        "unsetFullAccess": "Unset the full access password",
        "unsetRestrictedAccess": "Unset the restricted access password",
        "unsetViewAccess": "Unset the view access password"
        }
        for type, title in setOptions.iteritems():
            if textCtrl.GetName() == type:
                if type[:2] == "un":
                    dialog = UnsetPassword(self.parent, title, textCtrl.GetName())
                else:
                    dialog = SetPassword(self.parent, title, textCtrl.GetName())
                result = dialog.ShowModal()
                if result == wx.ID_OK:
                    self.parent.parent.FindWindowByName("settingsCancelButton").Disable()
                    self.parent.parent.FindWindowByName("settingsOkButton").Enable()
                dialog.Destroy()
        return True

    def Clone(self):
         return PasswordValidator(self.parent)

    def Validate(self, win):
        return True

    def TransferToWindow(self):
        textCtrl = self.GetWindow()
        if self.getType(textCtrl.GetName()) != None:
            if self.keychain.isKey(self.getType(textCtrl.GetName())) == False:
                textCtrl.Disable()
        return True

    def camelize(self, type):
        return str(type[0].lower() + type[1:])

    def getType(self, type):
        if type[:5] == "unset":
            return self.camelize(type[5:])
        else:
            return None

    def TransferFromWindow(self):
        return True
Beispiel #5
0
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = parent.frame
        self.keychain = MyKeyChain()

        self.Bind(wx.EVT_BUTTON, self.OnButton)
Beispiel #6
0
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()
        self.type = self.getType()

        self.Bind(wx.EVT_TEXT, self.OnText)
Beispiel #7
0
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()

        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio)
        self.Bind(wx.EVT_BUTTON, self.OnButton)
        self.Bind(wx.EVT_TEXT, self.OnText)
Beispiel #8
0
class UnsetPasswordValidator(wx.PyValidator):
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()
        self.type = self.getType()

        self.Bind(wx.EVT_TEXT, self.OnText)

    def camelize(self, type):
        return str(type[0].lower() + type[1:])

    def getType(self):
        if self.parent.type[:3] == "set":
            return self.camelize(self.parent.type[3:])
        else:
            return self.camelize(self.parent.type[5:])

    def OnText(self, event=None):
        old = self.parent.FindWindowByName("oldPassword")
        if self.keychain.isKey(self.type) == True:
            if self.keychain.comparePassword(self.type,
                                             old.GetValue()) == True:
                self.parent.FindWindowByName("goButton").Enable()
                return True
        self.parent.FindWindowByName("goButton").Disable()
        return False

    def Clone(self):
        return UnsetPasswordValidator(self.parent)

    def Validate(self, event=None):
        return True

    def TransferToWindow(self):
        textCtrl = self.GetWindow()
        if self.keychain.isKey(self.type) == False:
            self.parent.FindWindowByName("oldPasswordLabel").Disable()
            self.parent.FindWindowByName("oldPassword").Disable()

    def TransferFromWindow(self):
        if self.OnText() == True:
            if self.keychain.isKey(self.type) == True:
                self.keychain.removePassword(self.type)
        return True
Beispiel #9
0
class UnsetPasswordValidator(wx.PyValidator):
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()
        self.type = self.getType()

        self.Bind(wx.EVT_TEXT, self.OnText)

    def camelize(self, type):
        return str(type[0].lower() + type[1:])

    def getType(self):
        if self.parent.type[:3] == "set":
            return self.camelize(self.parent.type[3:])
        else:
            return self.camelize(self.parent.type[5:])

    def OnText(self, event=None):
        old = self.parent.FindWindowByName("oldPassword")
        if self.keychain.isKey(self.type) == True:
            if self.keychain.comparePassword(self.type, old.GetValue()) == True:
                    self.parent.FindWindowByName("goButton").Enable()
                    return True
        self.parent.FindWindowByName("goButton").Disable()
        return False

    def Clone(self):
         return UnsetPasswordValidator(self.parent)

    def Validate(self, event=None):
        return True

    def TransferToWindow(self):
        textCtrl = self.GetWindow()
        if self.keychain.isKey(self.type) == False:
            self.parent.FindWindowByName("oldPasswordLabel").Disable()
            self.parent.FindWindowByName("oldPassword").Disable()

    def TransferFromWindow(self):
        if self.OnText() == True:
            if self.keychain.isKey(self.type) == True:
                self.keychain.removePassword(self.type)
        return True
Beispiel #10
0
class WelcomeValidator(wx.PyValidator):
    """Validates all widgets of class TemplateDesignerWelcome
    
    The validator checks, of password is required and calls
    class TemplateDesignerFrame if all checks run successfully
    
    """
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()

        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio)
        self.Bind(wx.EVT_BUTTON, self.OnButton)
        self.Bind(wx.EVT_TEXT, self.OnText)

    def OnText(self, event=None):
        """Checks if entered password is correct
        
        If password is correct, ok button becomes enabled
        
        """
        textCtrl = self.GetWindow()
        for selection in ["fullAccess", "restrictedAccess", "viewAccess"]:
            radio = self.parent.FindWindowByName(selection)
            compare = self.keychain.comparePassword(selection,
                                                    textCtrl.GetValue())
            if radio.GetValue() == True and compare == True:
                self.parent.goButton.Enable()
                return True
        self.parent.goButton.Disable()

    def OnButton(self, event=None):
        """Calls the class TemplateDesignerFrame if user input is valid
        
        if user input is valid, returns True, else returns False
        
        """
        textCtrl = self.GetWindow()
        if textCtrl.GetName() == "goButton":
            for selection in ["fullAccess", "restrictedAccess", "viewAccess"]:
                radio = self.parent.FindWindowByName(selection)
                pw = self.parent.FindWindowByName("password")
                if pw.IsEnabled() == True and radio.GetValue() == True:
                    compare = self.keychain.comparePassword(
                        selection, pw.GetValue())
                    if compare == True:
                        self.parent.OnExitWindow()
                        frame = TemplateDesignerFrame(None, selection)
                        frame.Show(True)
                elif pw.IsEnabled() == False and radio.GetValue() == True:
                    self.parent.OnExitWindow()
                    frame = TemplateDesignerFrame(None, selection)
                    frame.Show(True)
        return False

    def OnRadio(self, event=None):
        """Enables and Disables the password text 
        control dependend on the system settings
        
        returns True
        
        """
        textCtrl = self.GetWindow()
        for selection in ["fullAccess", "restrictedAccess", "viewAccess"]:
            check = self.keychain.isKey(selection)
            if textCtrl.GetName() == selection and check == True:
                self.parent.FindWindowByName("passwordLabel").Enable()
                self.parent.FindWindowByName("password").Enable()
                self.parent.FindWindowByName("password").SetValue("")
                self.parent.goButton.Disable()
                return True
            elif textCtrl.GetName() == selection and check == False:
                self.parent.FindWindowByName("passwordLabel").Disable()
                self.parent.FindWindowByName("password").Disable()
                self.parent.goButton.Enable()
                return True

    def Clone(self):
        return WelcomeValidator(self.parent)

    def Validate(self):
        return True

    def TransferToWindow(self):
        return True

    def TransferFromWindow(self):
        return True
Beispiel #11
0
class WelcomeValidator(wx.PyValidator):
    """Validates all widgets of class TemplateDesignerWelcome
    
    The validator checks, of password is required and calls
    class TemplateDesignerFrame if all checks run successfully
    
    """
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()

        self.Bind(wx.EVT_RADIOBUTTON, self.OnRadio)
        self.Bind(wx.EVT_BUTTON, self.OnButton)
        self.Bind(wx.EVT_TEXT, self.OnText)

    def OnText(self, event=None):
        """Checks if entered password is correct
        
        If password is correct, ok button becomes enabled
        
        """
        textCtrl = self.GetWindow()
        for selection in ["fullAccess", "restrictedAccess", "viewAccess"]:
            radio = self.parent.FindWindowByName(selection)
            compare = self.keychain.comparePassword(selection, textCtrl.GetValue())
            if radio.GetValue() == True and compare == True:
                    self.parent.goButton.Enable()
                    return True
        self.parent.goButton.Disable()

    def OnButton(self, event=None):
        """Calls the class TemplateDesignerFrame if user input is valid
        
        if user input is valid, returns True, else returns False
        
        """
        textCtrl = self.GetWindow()
        if textCtrl.GetName() == "goButton":
            for selection in ["fullAccess", "restrictedAccess", "viewAccess"]:
                radio = self.parent.FindWindowByName(selection)
                pw = self.parent.FindWindowByName("password")
                if pw.IsEnabled() == True and radio.GetValue() == True:
                        compare = self.keychain.comparePassword(selection, pw.GetValue())
                        if compare == True:
                            self.parent.OnExitWindow()
                            frame = TemplateDesignerFrame(None, selection)
                            frame.Show(True)
                elif pw.IsEnabled() == False and radio.GetValue() == True:
                    self.parent.OnExitWindow()
                    frame = TemplateDesignerFrame(None, selection)
                    frame.Show(True)
        return False

    def OnRadio(self, event=None):
        """Enables and Disables the password text 
        control dependend on the system settings
        
        returns True
        
        """
        textCtrl = self.GetWindow()
        for selection in ["fullAccess", "restrictedAccess", "viewAccess"]:
            check = self.keychain.isKey(selection)
            if textCtrl.GetName() == selection and check == True:
                self.parent.FindWindowByName("passwordLabel").Enable()
                self.parent.FindWindowByName("password").Enable()
                self.parent.FindWindowByName("password").SetValue("")
                self.parent.goButton.Disable()
                return True
            elif textCtrl.GetName() == selection and check == False:
                self.parent.FindWindowByName("passwordLabel").Disable()
                self.parent.FindWindowByName("password").Disable()
                self.parent.goButton.Enable()
                return True

    def Clone(self):
         return WelcomeValidator(self.parent)

    def Validate(self):
        return True

    def TransferToWindow(self):
        return True

    def TransferFromWindow(self):
        return True
Beispiel #12
0
class PasswordValidator(wx.PyValidator):
    """This class acts as validator to the values, the user 
    is able to set in the dialog created by class settingsDialog
    """
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = parent.frame
        self.keychain = MyKeyChain()

        self.Bind(wx.EVT_BUTTON, self.OnButton)

    def OnButton(self, event=None):
        textCtrl = self.GetWindow()
        setOptions = {
            "setFullAccess": "Set the full access password",
            "setRestrictedAccess": "Set the restricted access password",
            "setViewAccess": "Set the view access password",
            "unsetFullAccess": "Unset the full access password",
            "unsetRestrictedAccess": "Unset the restricted access password",
            "unsetViewAccess": "Unset the view access password"
        }
        for type, title in setOptions.iteritems():
            if textCtrl.GetName() == type:
                if type[:2] == "un":
                    dialog = UnsetPassword(self.parent, title,
                                           textCtrl.GetName())
                else:
                    dialog = SetPassword(self.parent, title,
                                         textCtrl.GetName())
                result = dialog.ShowModal()
                if result == wx.ID_OK:
                    self.parent.parent.FindWindowByName(
                        "settingsCancelButton").Disable()
                    self.parent.parent.FindWindowByName(
                        "settingsOkButton").Enable()
                dialog.Destroy()
        return True

    def Clone(self):
        return PasswordValidator(self.parent)

    def Validate(self, win):
        return True

    def TransferToWindow(self):
        textCtrl = self.GetWindow()
        if self.getType(textCtrl.GetName()) != None:
            if self.keychain.isKey(self.getType(textCtrl.GetName())) == False:
                textCtrl.Disable()
        return True

    def camelize(self, type):
        return str(type[0].lower() + type[1:])

    def getType(self, type):
        if type[:5] == "unset":
            return self.camelize(type[5:])
        else:
            return None

    def TransferFromWindow(self):
        return True
Beispiel #13
0
class SetPasswordValidator(wx.PyValidator):
    def __init__(self, parent):
        wx.PyValidator.__init__(self)

        self.parent = parent
        self.frame = self.parent.GetTopLevelParent()
        self.keychain = MyKeyChain()
        self.type = self.getType()

        self.Bind(wx.EVT_TEXT, self.OnText)

    def camelize(self, type):
        return str(type[0].lower() + type[1:])

    def getType(self):
        if self.parent.type[:3] == "set":
            return self.camelize(self.parent.type[3:])
        else:
            return self.camelize(self.parent.type[5:])

    def checkPasswordQuality(self, password):
        """checkPasswordQuality returns True if given passwords are 
        at least 5 signs long and include and include alpha and 
        numeric values
        
        Else returns False
        
        """
        if re.match(r"(.*[0-9]+.*[a-zA-Z]+.*)|(.*[a-zA-Z]+.*[0-9]+.*)", password) \
        and len(password) > 4:
            return True
        return False

    def OnText(self, event=None):
        old = self.parent.FindWindowByName("oldPassword")
        new = self.parent.FindWindowByName("newPassword")
        repeat = self.parent.FindWindowByName("repeatPassword")
        if self.keychain.isKey(self.type) == True:
            if self.keychain.comparePassword(self.type, old.GetValue()) == True:
                quality = self.checkPasswordQuality(repeat.GetValue())
                if new.GetValue() == repeat.GetValue() and quality == True:
                    self.parent.FindWindowByName("goButton").Enable()
                    return True
        else:
            quality = self.checkPasswordQuality(repeat.GetValue())
            if new.GetValue() == repeat.GetValue() and quality == True:
                self.parent.FindWindowByName("goButton").Enable()
                return True
        self.parent.FindWindowByName("goButton").Disable()
        return False

    def Clone(self):
         return SetPasswordValidator(self.parent)

    def Validate(self, event=None):
        return True

    def TransferToWindow(self):
        textCtrl = self.GetWindow()
        if self.keychain.isKey(self.type) == False:
            self.parent.FindWindowByName("oldPasswordLabel").Disable()
            self.parent.FindWindowByName("oldPassword").Disable()

    def TransferFromWindow(self):
        if self.OnText() == True:
            password = self.parent.FindWindowByName("repeatPassword").GetValue()
            if self.keychain.isKey(self.type) == True:
                self.keychain.changePassword(self.type, password)
            else:
                self.keychain.setPassword(self.type, password)
        return True