Exemple #1
0
    def __init__(self, name, mind, realm):
        # must explicitly call __init__() and pass "self" to initialized parent, if not it becomes create a new instance
        self.mind = mind
        self.realm = realm
        self.name = name
        self.uniqId = id(self)

        result = Accounts.selectBy(username=self.name)
        if (result.count() != 1):
            raise UserGetInfoError("Bad username")
        else:
            self.user = result[0]
            self.user.loginDate = datetime.now()
Exemple #2
0
 def requestAvatarId(self, credentials):
     type = ObjectType.Peer
     name = credentials.username
     
     row = PeersInfo.selectBy(peername = name)
     if row.count() == 0: 
         type = ObjectType.User
         row = Accounts.selectBy(username = name)  
         if row.count() == 0:
             print "Login Failed: username[%s]"%(name)
             return failure.Failure(credError.UnauthorizedLogin("Bad username"))
     peer = row[0]
     return defer.maybeDeferred(credentials.checkPassword, peer.password).addCallback(
         self._checkedPassword, name, peer.role, type)
Exemple #3
0
    def requestAvatarId(self, credentials):
        type = ObjectType.Peer
        name = credentials.username

        row = PeersInfo.selectBy(peername=name)
        if row.count() == 0:
            type = ObjectType.User
            row = Accounts.selectBy(username=name)
            if row.count() == 0:
                print "Login Failed: username[%s]" % (name)
                return failure.Failure(
                    credError.UnauthorizedLogin("Bad username"))
        peer = row[0]
        return defer.maybeDeferred(credentials.checkPassword,
                                   peer.password).addCallback(
                                       self._checkedPassword, name, peer.role,
                                       type)
Exemple #4
0
def main():
    OPTIONS, argv = getOptions('mmolite/config/servers.cfg', 'master server',
                               sys.argv)

    dbconn = MasterDBObject('master.db', 'mmolite/data')

    if OPTIONS.setup:
        print "Setting up Master Server..."

        dbconn.resetDB()
        user = PeersInfo(peername="Master",
                         password="******",
                         role=PeerType.Master)
        user = PeersInfo(peername="Character",
                         password="******",
                         role=PeerType.Character)
        user = PeersInfo(peername="World",
                         password="******",
                         role=PeerType.World)
        user = PeersInfo(peername="Cluster",
                         password="******",
                         role=PeerType.Cluster)
        user = PeersInfo(peername="Zone", password="******", role=PeerType.Zone)
        user = PeersInfo(peername="Client",
                         password="******",
                         role=PeerType.Client)
        user = Accounts(username="******",
                        password="******",
                        role=UserType.Admin)
        print "Successfully"
        return
    else:
        print "Initialize Master Server database..."
        dbconn.startDB()
        Peers.dropTable(ifExists=True)
        Peers.createTable()
        print "Master Server Listening to port: %d" % OPTIONS.master_port

        realm = MasterRealm()
        p = portal.Portal(realm)
        p.registerChecker(MasterPasswordChecker())
        reactor.listenTCP(OPTIONS.master_port, pb.PBServerFactory(p))

        keepAlive(realm)
        reactor.run()
Exemple #5
0
 def perspective_register(self, username, password, role):
     role = role & UserType.GameMaster #  no registration for admin
     if self.perspective_verifyUsername(username):
         newUser = Accounts(username = username, password = password, role = role)
         return True
     return False
Exemple #6
0
 def perspective_verifyUsername(self, username):
     query = Accounts.selectBy(username=username)
     if query.count() > 0: return False
     else: return True