Class AccountManager


  • public class AccountManager
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      AccountManager()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean addAccount​(java.lang.String nickname, java.lang.String username, java.lang.String password)
      Adds an account with the given nickname, username, and password.
      static boolean addAccount​(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp)
      Adds an account with the given nickname, username, password, bank pin, and totp key
      static boolean addAccount​(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp, java.lang.String characterID, java.lang.String sessionID)
      Adds an account with the given nickname, username, password, bank pin, and totp key
      static boolean bulkImportAccounts​(java.io.File file)
      Bulk imports accounts from a file Formats accepted: JSON: {"accounts":[ {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "pin":"1234", "totp":"totp key"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "pin":"1234"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "totp":"totp key"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234"}, {"username":"[email protected]", "password":"password1234", "pin":"1234", "totp":"totp key"}, {"username":"[email protected]", "password":"password1234", "pin":"1234"}, {"username":"[email protected]", "password":"password1234", "totp":"totp key"}, {"username":"[email protected]", "password":"password1234"} ]} order agnostic nickname optional: defaults to username pin optional: defaults to empty totp optional: defaults to empty Colon Delimited: [email protected]:password1234 Account1:[email protected]:password1234 Account1:[email protected]:password1234:1234 Account1:[email protected]:password1234:1234:totp key Account1:[email protected]:password1234::totp key Given only username:password results in nickname defaulting to username
      static boolean containsAccount​(java.lang.String nickname)
      Checks if the client has an account with the supplied nickname
      static boolean containsAccountWithEmail​(java.lang.String email)
      Checks if the client has an account with the supplied email
      static boolean deleteAccount​(java.lang.String nickname)
      Removes the account with the specified nickname from the accounts list.
      static java.lang.String getAccountBankPin()
      Gets the currently selected account's bank pin
      static java.lang.String getAccountHash()
      Hashes the selected account's username, which is allowed in SDN scripts (unlike getUsername)
      static java.lang.String getAccountNickname()
      Gets the currently selected account's nickname
      static java.lang.String getAccountTOTPKey()
      Gets the currently selected account's TOTP key
      static java.lang.String getAccountUsername()  
      static java.util.List<java.lang.String> getAll()
      Gets a list of all account nicknames
      static boolean hasPin​(java.lang.String nickname)
      Checks if the account matching the given nickname has a bank pin value set
      static boolean isBanned​(java.lang.String nickname)
      Checks if the account matching the given nickname is set to banned
      static boolean isLegacyAccount()
      Checks if the current account is a legacy account
      static boolean setAccount​(java.lang.String nickname)
      Sets the currently selected account based on nickname
      static boolean updateAccount​(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp)
      Updates an account based on the given username If an account does not yet exist for this username, a new one will be added
      static boolean updateAccount​(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp, boolean banned)
      Updates an account based on the given username If an account does not yet exist for this username, a new one will be added
      static boolean updateAccount​(java.lang.String nickname, java.lang.String username, java.lang.String password, java.lang.String pin, java.lang.String totp, boolean banned, java.lang.String characterID, java.lang.String sessionID)  
      static boolean updateBanStatus​(java.lang.String nickname, boolean banned)
      Updates the ban status on an account based on the given nickname.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AccountManager

        public AccountManager()
    • Method Detail

      • setAccount

        public static boolean setAccount​(java.lang.String nickname)
        Sets the currently selected account based on nickname
        Parameters:
        nickname - Nickname of the account to select
        Returns:
        True if successfully finds and sets selected account, else false
      • addAccount

        public static boolean addAccount​(java.lang.String nickname,
                                         java.lang.String username,
                                         java.lang.String password,
                                         java.lang.String pin,
                                         java.lang.String totp)
        Adds an account with the given nickname, username, password, bank pin, and totp key
        Parameters:
        nickname - Nickname for the account
        username - Login username for the account
        password - password for the account
        pin - bank pin for the account, empty if no bank pin needed
        totp - totp key for the account, empty if no totp key needed
        Returns:
        False if account username already exists or account nickname already exists, else true if added successfully
      • addAccount

        public static boolean addAccount​(java.lang.String nickname,
                                         java.lang.String username,
                                         java.lang.String password,
                                         java.lang.String pin,
                                         java.lang.String totp,
                                         java.lang.String characterID,
                                         java.lang.String sessionID)
        Adds an account with the given nickname, username, password, bank pin, and totp key
        Parameters:
        nickname - Nickname for the account
        username - Login username for the account
        password - password for the account
        pin - bank pin for the account, empty if no bank pin needed
        totp - totp key for the account, empty if no totp key needed
        characterID - character ID retrieved from the jagex launcher accounts
        sessionID - session ID retrieved from the jagex launcher accounts
        Returns:
        False if account username already exists or account nickname already exists, else true if added successfully
      • updateAccount

        public static boolean updateAccount​(java.lang.String nickname,
                                            java.lang.String username,
                                            java.lang.String password,
                                            java.lang.String pin,
                                            java.lang.String totp)
        Updates an account based on the given username If an account does not yet exist for this username, a new one will be added
        Parameters:
        nickname - nickname for the account
        username - login email for the account
        password - login password for the account
        pin - bank pin for the account, empty if no bank pin needed
        totp - totp key for the account, empty if no totp key needed
        Returns:
      • updateAccount

        public static boolean updateAccount​(java.lang.String nickname,
                                            java.lang.String username,
                                            java.lang.String password,
                                            java.lang.String pin,
                                            java.lang.String totp,
                                            boolean banned)
        Updates an account based on the given username If an account does not yet exist for this username, a new one will be added
        Parameters:
        nickname - nickname for the account
        username - login email for the account
        password - login password for the account
        pin - bank pin for the account, empty if no bank pin needed
        totp - totp key for the account, empty if no totp key needed
        banned - if the account is banned
        Returns:
      • updateAccount

        public static boolean updateAccount​(java.lang.String nickname,
                                            java.lang.String username,
                                            java.lang.String password,
                                            java.lang.String pin,
                                            java.lang.String totp,
                                            boolean banned,
                                            java.lang.String characterID,
                                            java.lang.String sessionID)
      • addAccount

        public static boolean addAccount​(java.lang.String nickname,
                                         java.lang.String username,
                                         java.lang.String password)
        Adds an account with the given nickname, username, and password. Defaults bank pin and totp key to empty
        Parameters:
        nickname - Nickname for the account
        username - Login username for the account
        password - Password for the account
        Returns:
        False if account username already exists or account nickname already exists, else true if added successfully
      • getAccountNickname

        public static java.lang.String getAccountNickname()
        Gets the currently selected account's nickname
        Returns:
        current account nickname or null if no selected account
      • getAccountBankPin

        public static java.lang.String getAccountBankPin()
        Gets the currently selected account's bank pin
        Returns:
        current account bank pin or null if no selected account
      • getAccountTOTPKey

        public static java.lang.String getAccountTOTPKey()
        Gets the currently selected account's TOTP key
        Returns:
        current account TOTP key or null if no selected account
      • isLegacyAccount

        public static boolean isLegacyAccount()
        Checks if the current account is a legacy account
        Returns:
        true if it is or if there is no account set
      • bulkImportAccounts

        public static boolean bulkImportAccounts​(java.io.File file)
        Bulk imports accounts from a file Formats accepted: JSON: {"accounts":[ {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "pin":"1234", "totp":"totp key"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "pin":"1234"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234", "totp":"totp key"}, {"nickname":"Account1", "username":"[email protected]", "password":"password1234"}, {"username":"[email protected]", "password":"password1234", "pin":"1234", "totp":"totp key"}, {"username":"[email protected]", "password":"password1234", "pin":"1234"}, {"username":"[email protected]", "password":"password1234", "totp":"totp key"}, {"username":"[email protected]", "password":"password1234"} ]} order agnostic nickname optional: defaults to username pin optional: defaults to empty totp optional: defaults to empty Colon Delimited: [email protected]:password1234 Account1:[email protected]:password1234 Account1:[email protected]:password1234:1234 Account1:[email protected]:password1234:1234:totp key Account1:[email protected]:password1234::totp key Given only username:password results in nickname defaulting to username
        Parameters:
        file - The file containing the accounts formatted correctly
        Returns:
        true if we are able to read the file, false otherwise
      • deleteAccount

        public static boolean deleteAccount​(java.lang.String nickname)
        Removes the account with the specified nickname from the accounts list.
        Parameters:
        nickname - nickname of account to delete
        Returns:
        True of account successfully deleted
      • containsAccount

        public static boolean containsAccount​(java.lang.String nickname)
        Checks if the client has an account with the supplied nickname
        Parameters:
        nickname - The account's nickname
        Returns:
        true if the client has a matching account, false otherwise
      • containsAccountWithEmail

        public static boolean containsAccountWithEmail​(java.lang.String email)
        Checks if the client has an account with the supplied email
        Parameters:
        email - The account's login email
        Returns:
        true if the client has a matching account, false otherwise
      • getAccountUsername

        public static java.lang.String getAccountUsername()
      • getAccountHash

        public static java.lang.String getAccountHash()
        Hashes the selected account's username, which is allowed in SDN scripts (unlike getUsername)
        Returns:
        A Base64 encoded SHA-256 hash of the player's username if an account is selected, otherwise returns an empty string
      • getAll

        public static java.util.List<java.lang.String> getAll()
        Gets a list of all account nicknames
        Returns:
      • isBanned

        public static boolean isBanned​(java.lang.String nickname)
        Checks if the account matching the given nickname is set to banned
        Parameters:
        nickname - nickname to check account for, case-insensitive
        Returns:
        true if found and banned, else false
      • hasPin

        public static boolean hasPin​(java.lang.String nickname)
        Checks if the account matching the given nickname has a bank pin value set
        Parameters:
        nickname - nickname of the account to check, case-insensitive
        Returns:
        true if account is found and has a not empty bank pin, else false
      • updateBanStatus

        public static boolean updateBanStatus​(java.lang.String nickname,
                                              boolean banned)
        Updates the ban status on an account based on the given nickname.
        Parameters:
        nickname - nickname to match against the saved account, also checks the given nickname against the account username
        banned - True if banned, False if not
        Returns:
        True if successfully sets an account's ban status. False if the account was not found.