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 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 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 boolean setAccount​(java.lang.String nickname)
      Sets the currently selected account based on 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)
        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
      • 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
      • 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