The Account class represents an account and all of its data.
An account contains data necessary to connect to a local or remote service. The account class stores data as key and value pairs. Several keys are defined in this class as public static final Strings. The keys UID, NAME, DESCRIPTION
, and TYPE
must be defined for all account objects. (DESCRIPTION
is initially set to an empty String). A random UID is generated for an account object if you do not provide a UID when you create it. All other required keys depend on the TYPE key defined for the account, but in general, are optional.
The Account class contains the following two data stores:
- Persistent store – Writes properties to a database, file, or other store when a call to add or update account is made.
- In memory store – Properties only exist in this class. Stores data that is only relevant for a given user session without writing it to disk. Useful for securely handling information such as LTPA cookies.
With the exception of operations made using the AccountsLoginContextService
, changes to the Account object are not made permanent until you make a call to update or add the account.
To create an account, perform the following steps:
- Use the AccountsManagerFactory to access a singleton instance of the platform implementation of the AccountsManager interface.
- Create the account by doing one of the following:
Optional: The Account object returned by the AccountsManager contains all the properties of the account. You can change the properties using the following methods inherited from the com.ibm.rcp.security.auth.AuthProperties class (There are get methods that correspond to each of these set methods):
- To add an account object based on the standard Account class to the persistent store, use the following methods:
where id is either null or set to DEFAULT_ACCOUNT
- To create an account object based on a custom account class, use the following method:
identifies the TYPE
property of the custom account class that you defined using the Accounts extension point. If AccountsManager
cannot find a class that matches the given TYPE
, then it uses the base Account class to create the new account object. The default account TYPE
The UID, NAME, DESCRIPTION, and TYPE properties must have values, but other properties are optional. The UID is assigned by the Accounts API and should never be modified by the user.
Parent topic: Accounts framework