*/
public static String isAccountCreationPossible(Connection connection,
String username) {
String errorMessage = null;
Registration registration = null;
try {
registration = XMPPUtil.getRegistrationInfo(username, connection);
} catch (XMPPException e) {
log.error("Server " + connection.getHost()
+ " does not support XEP-0077"
+ " (In-Band Registration) properly:", e);
}
if (registration != null && registration.getError() != null) {
if (registration.getAttributes().containsKey("registered")) {
errorMessage = "Account " + username
+ " already exists on the server.";
} else if (!registration.getAttributes().containsKey("username")) {
if (registration.getInstructions() != null) {
errorMessage = "Registration via Saros not possible.\n\n"
+ "Please follow these instructions:\n"
+ registration.getInstructions();
} else {
errorMessage = "Registration via Saros not possible.\n\n"
+ "Please see the server's web site for\n"
+ "informations for how to create an account.";
}
} else {
errorMessage = "No in-band registration. Please create account on provider's website.";
log.warn("Unknow registration error: "
+ registration.getError().getMessage());
}
}
return errorMessage;
}