Пример #1
0
def accountValidateLogin(accountsRegistry, identity, password):
    # can be used for both Email & User type accounts
    for account in accountsRegistry:
        if account.getIdentifier() == identity:
            return SecurityServer.validatePW(account.passwordHashed, account.salt, password)
    print("doesn't exist")
    return False
Пример #2
0
 def __init__(self):
     self.state = "status"
     self.transferKey = 0
     self.securityServer = SecurityServer.securityServer()
     self.accountUserRegistry = Storage.accountsLoad("User")
     self.songRegistry = Storage.songListLoad()
     print("FILES LOADED")
     self.currentUser = []
Пример #3
0
def accountsLoad(accountsType):
    accountsRegistry = []
    filename = "accounts" + accountsType
    try:
        f = open(filename, "rb")
    except FileNotFoundError:
        print("404 - Returing Test Variable")
        if accountsType == "Email":
            address = "*****@*****.**"
            addressPass = "******"
            hashedPassword, salt = SecurityServer.hashPW(addressPass)
            tmail = accountEmail(address, hashedPassword, salt)
            accountAdd(accountsRegistry, tmail)
            address = "*****@*****.**"
            addressPass = "******"
            hashedPassword, salt = SecurityServer.hashPW(addressPass)
            tmail = accountEmail(address, hashedPassword, salt)
            accountAdd(accountsRegistry, tmail)
            address = "*****@*****.**"
            addressPass = "******"
            hashedPassword, salt = SecurityServer.hashPW(addressPass)
            tmail = accountEmail(address, hashedPassword, salt)
            accountAdd(accountsRegistry, tmail)
            #accountsSave(accountsRegistry, "Email")
        elif accountsType == "User":
            userName = "******"
            userPass = "******"
            hashedPassword, salt = SecurityServer.hashPW(userPass)
            tuser = accountUser(userName, hashedPassword, salt,
                                ["*****@*****.**", "*****@*****.**"])
            accountAdd(accountsRegistry, tuser)
            #accountsSave(accountsRegistry, "User") # Will only be saved if something get's added.
        elif accountsType == "MailList":
            tmailList = mailingList("testlist", [
                "*****@*****.**", "*****@*****.**",
                "*****@*****.**"
            ])
            accountAdd(accountsRegistry, tmailList)
        else:
            print("Unknown type, returning empty variable")
        return accountsRegistry
    else:
        accountsRegistry = pickle.load(f)
        f.close()
    return accountsRegistry
Пример #4
0
 def commandREGISTER(self, argument, module):
     userName = CommonFunctions.firstWord(argument)
     if Storage.accountExists(self.accountUserRegistry, userName):
         self.code554(", account already exists.", module)
     else:
         userPass = CommonFunctions.secondWord(argument)
         hashedPassword, salt = SecurityServer.hashPW(userPass)
         tuser = Storage.accountUser(userName, hashedPassword, salt,
                                     ["", ""])
         Storage.accountAdd(self.accountUserRegistry, tuser)
         Storage.accountsSave(self.accountUserRegistry, "User")
         self.code250(" Account Registered Successfuly, Log in.", module)
Пример #5
0
    def __init__(self):
        self.state = "keyExchange"
        self.transferKey = 0
        self.securityServer = SecurityServer.securityServer()

        self.accountEmailRegistry = Storage.accountsLoad("Email")
        self.accountUserRegistry = Storage.accountsLoad("User")
        self.emailListRegistry = Storage.accountsLoad("MailList")

        print("FILES LOADED")
        self.subStateMail = "init"
        self.mailFromBuffer = ""
        self.rcptBuffer = []
        self.dataBuffer = ""
        self.clientDomain = "-"
        self.currentUser = []
Пример #6
0
 def commandREGMAIL(self, argument, module):
     address = CommonFunctions.firstWord(argument)
     addressPass = CommonFunctions.secondWord(argument)
     mailValid = CommonFunctions.mailValidation(address)
     if mailValid == "OK":
         if CommonFunctions.userpassValidate(addressPass):
             hashedPassword, salt = SecurityServer.hashPW(addressPass)
             tmail = Storage.accountEmail(address, hashedPassword, salt)
             Storage.accountAdd(self.accountEmailRegistry, tmail)
             Storage.accountsSave(self.accountEmailRegistry, "Email")
             self.code250(
                 " Email Account Registered Successfuly. Don't forget to add it to your User Account",
                 module)
         else:
             self.code503(
                 " Password must be atleast 6 characters long and CAN contain numbers, letters including the following symbols !@#$%^&*()-=_+,.?",
                 module)
     else:
         self.code501(mailValid, module)
Пример #7
0
def accountsLoad(accountsType):
    accountsRegistry = []
    filename = "accounts" + accountsType
    try:
        f = open(filename, "rb")
    except FileNotFoundError:
        print("404 - Returing Test Variable")
        if accountsType == "User":
            userName = "******"
            userPass = "******"
            hashedPassword, salt = SecurityServer.hashPW(userPass)
            tuser = accountUser(userName, hashedPassword, salt)
            accountAdd(accountsRegistry, tuser)
            #accountsSave(accountsRegistry, "User") # Will only be saved if something get's added.
        else:
            print("Unknown type, returning empty list")
        return accountsRegistry
    else:
        accountsRegistry = pickle.load(f)
        f.close()
    return accountsRegistry
Пример #8
0
def decryptData(data, SecurityServer):
    return SecurityServer.decryptData(data)
Пример #9
0
def sendData(data, module, SecurityServer):
    data = data.encode()
    data = SecurityServer.encryptData(data)
    module._send_data(data)
Пример #10
0
def sendData(
    data, module, SecurityServer
):  # This command is used to send data while not in the KeyExchange state.
    data = data.encode()
    data = SecurityServer.encryptData(data)
    module._send_data(data)