public final 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(Localpart username,
String password)
Creates a new account using the specified username and password.
|
void |
createAccount(Localpart 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.
|
boolean |
isSupported() |
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, getAuthenticatedConnectionOrThrow, schedule
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, InterruptedException
XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public Set<String> getAccountAttributes() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Typically, servers require no attributes when creating new accounts, or just the user's email address.
XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public String getAccountAttribute(String name) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
name
- the name of the account attribute to return its value.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public String getAccountInstructions() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public void createAccount(Localpart username, String password) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
username
- the username.password
- the password.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public void createAccount(Localpart username, String password, Map<String,String> attributes) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
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
InterruptedException
getAccountAttributes()
public void changePassword(String newPassword) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
newPassword
- new password.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
InterruptedException
public void deleteAccount() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
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
InterruptedException
public boolean isSupported() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException