public class AccountManager extends Manager
Modifier and Type | Method and Description |
---|---|
void |
changePassword(String newPassword)
Changes the password of the currently logged-in account.
|
void |
createAccount(String username,
String password)
Creates a new account using the specified username and password.
|
void |
createAccount(String username,
String password,
Map<String,String> attributes)
Creates a new account using the specified username, password and account attributes.
|
void |
deleteAccount()
Deletes the currently logged-in account from the server.
|
String |
getAccountAttribute(String name)
Returns the value of a given account attribute or null if the account
attribute wasn't found.
|
Set<String> |
getAccountAttributes()
Returns an unmodifiable collection of the names of the required account attributes.
|
String |
getAccountInstructions()
Returns the instructions for creating a new account, or null if there
are no instructions.
|
static AccountManager |
getInstance(XMPPConnection connection)
Returns the AccountManager instance associated with a given XMPPConnection.
|
void |
sensitiveOperationOverInsecureConnection(boolean allow)
Set to
true to allow sensitive operation over insecure connection. |
static void |
sensitiveOperationOverInsecureConnectionDefault(boolean allow)
The default value used by new account managers for
allowSensitiveOperationOverInsecureConnection . |
boolean |
supportsAccountCreation()
Returns true if the server supports creating new accounts.
|
connection
public static AccountManager getInstance(XMPPConnection connection)
connection
- the connection used to look for the proper ServiceDiscoveryManager.public static void sensitiveOperationOverInsecureConnectionDefault(boolean allow)
allowSensitiveOperationOverInsecureConnection
.allow
- sensitiveOperationOverInsecureConnection(boolean)
public void sensitiveOperationOverInsecureConnection(boolean allow)
true
to allow sensitive operation over insecure connection.
Set to true to allow sensitive operations like account creation or password changes over an insecure (e.g. unencrypted) connections.
allow
- public boolean supportsAccountCreation() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public Set<String> getAccountAttributes() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
Typically, servers require no attributes when creating new accounts, or just the user's email address.
XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public String getAccountAttribute(String name) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
name
- the name of the account attribute to return its value.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public String getAccountInstructions() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public void createAccount(String username, String password) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
username
- the username.password
- the password.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
public void createAccount(String username, String password, Map<String,String> attributes) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
username
- the username.password
- the password.attributes
- the account attributes.XMPPException.XMPPErrorException
- if an error occurs creating the account.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
getAccountAttributes()
public void changePassword(String newPassword) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
IllegalStateException
- if not currently logged-in to the server.XMPPException.XMPPErrorException
- if an error occurs when changing the password.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public void deleteAccount() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
IllegalStateException
- if not currently logged-in to the server.XMPPException.XMPPErrorException
- if an error occurs when deleting the account.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException