Class AccountDAO

java.lang.Object
marauroa.server.game.db.AccountDAO

public class AccountDAO extends Object
data access object for accounts
Author:
miguel, hendrik
  • Constructor Details

    • AccountDAO

      protected AccountDAO()
      Creates a new AccountDAO
  • Method Details

    • addPlayer

      @Deprecated public void addPlayer(DBTransaction transaction, String username, byte[] passwordHash, String email) throws SQLException
      Deprecated.
      creates an account
      Parameters:
      transaction - DBTransaction
      username - username
      passwordHash - password hash
      email - email-address
      Throws:
      SQLException - in case of an database error
    • addPlayer

      public void addPlayer(DBTransaction transaction, String username, byte[] passwordHash, String email, Timestamp timestamp) throws SQLException
      creates an account
      Parameters:
      transaction - DBTransaction
      username - username
      passwordHash - password hash
      email - email-address
      timestamp - when the account was added
      Throws:
      SQLException - in case of an database error
    • generatePlayer

      public String generatePlayer(String pattern)
      generates an account name based on the specified pattern (uses for automatic testing)
      Parameters:
      pattern -
      Returns:
      account name
    • changeEmail

      public void changeEmail(DBTransaction transaction, String username, String email) throws SQLException
      changes the email-address
      Parameters:
      transaction - DBTransaction
      username - username
      email - new email-address
      Throws:
      SQLException - in case of an database error
    • changePassword

      public void changePassword(DBTransaction transaction, String username, String password) throws SQLException
      changes the password
      Parameters:
      transaction - DBTransaction
      username - username
      password - new password
      Throws:
      SQLException - in case of an database error
    • hasPlayer

      public boolean hasPlayer(DBTransaction transaction, String username) throws SQLException
      checks if this account exists
      Parameters:
      transaction - DBTransaction
      username - username
      Returns:
      true, if the account exists; false otherwise
      Throws:
      SQLException - in case of an database error
    • setAccountStatus

      public void setAccountStatus(DBTransaction transaction, String username, String status) throws SQLException
      sets the status of the account
      Parameters:
      transaction - DBTransaction
      username - username
      status - account status
      Throws:
      SQLException - in case of an database error
    • getAccountStatus

      public String getAccountStatus(DBTransaction transaction, String username) throws SQLException
      gets the status of the account
      Parameters:
      transaction - DBTransaction
      username - username
      Returns:
      account status, or null if no such account exists
      Throws:
      SQLException - in case of an database error
    • getAccountBanMessage

      public String getAccountBanMessage(DBTransaction transaction, String username) throws SQLException
      gets the ban message of the account
      Parameters:
      transaction - DBTransaction
      username - username
      Returns:
      ban message, or null if the account is not banned.
      Throws:
      SQLException - in case of an database error
    • getEmail

      public String getEmail(DBTransaction transaction, String username) throws SQLException
      gets the email-address of the account
      Parameters:
      transaction - DBTransaction
      username - username
      Returns:
      email of account, or null if no such account exists
      Throws:
      SQLException - in case of an database error
    • getDatabasePlayerId

      public int getDatabasePlayerId(DBTransaction transaction, String username) throws SQLException
      gets the id of the account
      Parameters:
      transaction - DBTransaction
      username - username
      Returns:
      id of account, or -1 if no such account exists
      Throws:
      SQLException - in case of an database error
    • verify

      public boolean verify(DBTransaction transaction, SecuredLoginInfo info) throws SQLException
      verifies username and password
      Parameters:
      transaction - DBTransaction
      info - login credentials
      Returns:
      true, on success; false otherwise
      Throws:
      SQLException - in case of an database error
    • verifyPassword

      public boolean verifyPassword(DBTransaction transaction, String username, String password) throws SQLException
      verifies the account username and password
      Parameters:
      transaction - DBTransaction
      username - username
      password - password
      Returns:
      true on success, false if the account does not exists or the password does not match
      Throws:
      SQLException - in case of an database error
    • removePlayer

      public boolean removePlayer(DBTransaction transaction, String username) throws SQLException
      deletes an account from the database
      Parameters:
      transaction - DBTransaction
      username - username
      Returns:
      always true
      Throws:
      SQLException - in case of an database error
    • isAccountCreationLimitReached

      public boolean isAccountCreationLimitReached(DBTransaction transaction, String address) throws SQLException, IOException
      is account creation limit reached for recently created accounts
      Parameters:
      transaction - DBTransaction
      address - ip-address
      Returns:
      true, if too many accounts have been created recently
      Throws:
      SQLException - in case of an database error
      IOException - in case of an input/output error
    • addBan

      public void addBan(DBTransaction transaction, String username, String reason, Timestamp expire) throws SQLException
      adds a ban (which may be temporary)
      Parameters:
      transaction - DBTransaction
      username - username
      reason - Reason for the ban
      expire - timestamp when this ban will expire, may be null
      Throws:
      SQLException - in case of an database error
    • addPlayer

      @Deprecated public void addPlayer(String username, byte[] password, String email) throws SQLException
      Deprecated.
      creates an account
      Parameters:
      username - username
      password - the hashed password's bytearray
      email - email-address
      Throws:
      SQLException - in case of an database error
    • changeEmail

      @Deprecated public void changeEmail(String username, String email) throws SQLException
      Deprecated.
      changes the email-address
      Parameters:
      username - username
      email - new email-address
      Throws:
      SQLException - in case of an database error
    • changePassword

      @Deprecated public void changePassword(String username, String password) throws SQLException
      Deprecated.
      changes the password
      Parameters:
      username - username
      password - new password
      Throws:
      SQLException - in case of an database error
    • hasPlayer

      @Deprecated public boolean hasPlayer(String username) throws SQLException
      Deprecated.
      checks if this account exists
      Parameters:
      username - username
      Returns:
      true, if the account exists; false otherwise
      Throws:
      SQLException - in case of an database error
    • setAccountStatus

      @Deprecated public void setAccountStatus(String username, String status) throws SQLException
      Deprecated.
      sets the status of the account
      Parameters:
      username - username
      status - account status
      Throws:
      SQLException - in case of an database error
    • getAccountStatus

      @Deprecated public String getAccountStatus(String username) throws SQLException
      Deprecated.
      gets the status of the account
      Parameters:
      username - username
      Returns:
      account status, or null if no such account exists
      Throws:
      SQLException - in case of an database error
    • getAccountBanMessage

      @Deprecated public String getAccountBanMessage(String username) throws SQLException
      Deprecated.
      gets the ban message of an account
      Parameters:
      username - username
      Returns:
      account ban message, or null if this account is not banned
      Throws:
      SQLException - in case of an database error
    • getEmail

      @Deprecated public String getEmail(String username) throws SQLException
      Deprecated.
      gets the email-address of the account
      Parameters:
      username - username
      Returns:
      email of account, or null if no such account exists
      Throws:
      SQLException - in case of an database error
    • getDatabasePlayerId

      @Deprecated public int getDatabasePlayerId(String username) throws SQLException
      Deprecated.
      gets the id of the account
      Parameters:
      username - username
      Returns:
      id of account, or -1 if no such account exists
      Throws:
      SQLException - in case of an database error
    • verify

      @Deprecated public boolean verify(SecuredLoginInfo informations) throws SQLException
      Deprecated.
      verifies username and password
      Parameters:
      informations - login credentials
      Returns:
      true, on success; false otherwise
      Throws:
      SQLException - in case of an database error
    • verifyPassword

      @Deprecated public boolean verifyPassword(String username, String password) throws SQLException
      Deprecated.
      verifies the account username and password
      Parameters:
      username - username
      password - password
      Returns:
      true on success, false if the account does not exists or the password does not match
      Throws:
      SQLException - in case of an database error
    • removePlayer

      @Deprecated public boolean removePlayer(String username) throws SQLException
      Deprecated.
      deletes an account from the database
      Parameters:
      username - username
      Returns:
      always true
      Throws:
      SQLException - in case of an database error
    • isAccountCreationLimitReached

      @Deprecated public boolean isAccountCreationLimitReached(String address) throws SQLException, IOException
      Deprecated.
      is account creation limit reached for recently created accounts
      Parameters:
      address - ip-address
      Returns:
      true, if too many accounts have been created recently
      Throws:
      SQLException - in case of an database error
      IOException - in case of an input/output error
    • addBan

      @Deprecated public void addBan(String username, String reason, Timestamp expire) throws SQLException
      Deprecated.
      adds a ban (which may be temporary)
      Parameters:
      username - username
      reason - Reason for the ban
      expire - timestamp when this ban will expire, may be null
      Throws:
      SQLException - in case of an database error