use of org.jivesoftware.smackx.iqregister.packet.Registration in project Smack by igniterealtime.
the class AccountManager method changePassword.
/**
* Changes the password of the currently logged-in account. This operation can only
* be performed after a successful login operation has been completed. Not all servers
* support changing passwords; an XMPPException will be thrown when that is the case.
*
* @param newPassword new password.
*
* @throws IllegalStateException if not currently logged-in to the server.
* @throws XMPPErrorException if an error occurs when changing the password.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public void changePassword(String newPassword) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
throw new IllegalStateException("Changing password over insecure connection.");
}
Map<String, String> map = new HashMap<>();
map.put("username", connection().getUser().getLocalpart().toString());
map.put("password", newPassword);
Registration reg = new Registration(map);
reg.setType(IQ.Type.set);
reg.setTo(connection().getXMPPServiceDomain());
createStanzaCollectorAndSend(reg).nextResultOrThrow();
}
use of org.jivesoftware.smackx.iqregister.packet.Registration in project Smack by igniterealtime.
the class AccountManager method getRegistrationInfo.
/**
* Gets the account registration info from the server.
*
* @throws XMPPErrorException if there was an XMPP error returned.
* @throws NoResponseException if there was no response from the remote entity.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Registration reg = new Registration();
reg.setTo(connection().getXMPPServiceDomain());
info = createStanzaCollectorAndSend(reg).nextResultOrThrow();
}
use of org.jivesoftware.smackx.iqregister.packet.Registration in project Smack by igniterealtime.
the class AccountManager method createAccount.
/**
* Creates a new account using the specified username, password and account attributes.
* The attributes Map must contain only String name/value pairs and must also have values
* for all required attributes.
*
* @param username the username.
* @param password the password.
* @param attributes the account attributes.
* @throws XMPPErrorException if an error occurs creating the account.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
* @see #getAccountAttributes()
*/
public void createAccount(Localpart username, String password, Map<String, String> attributes) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
if (!connection().isSecureConnection() && !allowSensitiveOperationOverInsecureConnection) {
throw new IllegalStateException("Creating account over insecure connection");
}
if (username == null) {
throw new IllegalArgumentException("Username must not be null");
}
if (StringUtils.isNullOrEmpty(password)) {
throw new IllegalArgumentException("Password must not be null");
}
attributes.put("username", username.toString());
attributes.put("password", password);
Registration reg = new Registration(attributes);
reg.setType(IQ.Type.set);
reg.setTo(connection().getXMPPServiceDomain());
createStanzaCollectorAndSend(reg).nextResultOrThrow();
}
use of org.jivesoftware.smackx.iqregister.packet.Registration in project Smack by igniterealtime.
the class MultiUserChat method sendRegistrationForm.
/**
* Sends the completed registration form to the server. After the user successfully submits
* the form, the room may queue the request for review by the room admins or may immediately
* add the user to the member list by changing the user's affiliation from "none" to "member.<p>
*
* If the desired room nickname is already reserved for that room, the room will return a
* "Conflict" error to the user (error code 409). If the room does not support registration,
* it will return a "Service Unavailable" error to the user (error code 503).
*
* @param form the completed registration form.
* @throws XMPPErrorException if an error occurs submitting the registration form. In particular, a
* 409 error can occur if the desired room nickname is already reserved for that room;
* or a 503 error can occur if the room does not support registration.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public void sendRegistrationForm(FillableForm form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Registration reg = new Registration();
reg.setType(IQ.Type.set);
reg.setTo(room);
reg.addExtension(form.getDataFormToSubmit());
connection.sendIqRequestAndWaitForResponse(reg);
}
use of org.jivesoftware.smackx.iqregister.packet.Registration in project Smack by igniterealtime.
the class MultiUserChat method sendRegistrationForm.
/**
* Sends the completed registration form to the server. After the user successfully submits
* the form, the room may queue the request for review by the room admins or may immediately
* add the user to the member list by changing the user's affiliation from "none" to "member.<p>
*
* If the desired room nickname is already reserved for that room, the room will return a
* "Conflict" error to the user (error code 409). If the room does not support registration,
* it will return a "Service Unavailable" error to the user (error code 503).
*
* @param form the completed registration form.
* @throws XMPPErrorException if an error occurs submitting the registration form. In particular, a
* 409 error can occur if the desired room nickname is already reserved for that room;
* or a 503 error can occur if the room does not support registration.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void sendRegistrationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Registration reg = new Registration();
reg.setType(IQ.Type.set);
reg.setTo(room);
reg.addExtension(form.getDataFormToSend());
connection.createStanzaCollectorAndSend(reg).nextResultOrThrow();
}
Aggregations