Example #1
0
 /**
  * Returns the instructions for creating a new account, or <tt>null</tt> if there are no
  * instructions. If present, instructions should be displayed to the end-user that will complete
  * the registration process.
  *
  * @return the account creation instructions, or <tt>null</tt> if there are none.
  */
 public String getAccountInstructions() {
   try {
     if (info == null) {
       getRegistrationInfo();
     }
     return info.getInstructions();
   } catch (XMPPException xe) {
     return null;
   }
 }
Example #2
0
 /**
  * Returns the value of a given account attribute or <tt>null</tt> if the account attribute wasn't
  * found.
  *
  * @param name the name of the account attribute to return its value.
  * @return the value of the account attribute or <tt>null</tt> if an account attribute wasn't
  *     found for the requested name.
  */
 public String getAccountAttribute(String name) {
   try {
     if (info == null) {
       getRegistrationInfo();
     }
     return info.getAttributes().get(name);
   } catch (XMPPException xe) {
     xe.printStackTrace();
   }
   return null;
 }
Example #3
0
 /**
  * Returns an unmodifiable collection of the names of the required account attributes. All
  * attributes must be set when creating new accounts. The standard set of possible attributes are
  * as follows:
  *
  * <ul>
  *   <li>name -- the user's name.
  *   <li>first -- the user's first name.
  *   <li>last -- the user's last name.
  *   <li>email -- the user's email address.
  *   <li>city -- the user's city.
  *   <li>state -- the user's state.
  *   <li>zip -- the user's ZIP code.
  *   <li>phone -- the user's phone number.
  *   <li>url -- the user's website.
  *   <li>date -- the date the registration took place.
  *   <li>misc -- other miscellaneous information to associate with the account.
  *   <li>text -- textual information to associate with the account.
  *   <li>remove -- empty flag to remove account.
  * </ul>
  *
  * <p>Typically, servers require no attributes when creating new accounts, or just the user's
  * email address.
  *
  * @return the required account attributes.
  */
 public Collection<String> getAccountAttributes() {
   try {
     if (info == null) {
       getRegistrationInfo();
     }
     Map<String, String> attributes = info.getAttributes();
     if (attributes != null) {
       return Collections.unmodifiableSet(attributes.keySet());
     }
   } catch (XMPPException xe) {
     xe.printStackTrace();
   }
   return Collections.emptySet();
 }
Example #4
0
 /**
  * Returns true if the server supports creating new accounts. Many servers require that you not be
  * currently authenticated when creating new accounts, so the safest behavior is to only create
  * new accounts before having logged in to a server.
  *
  * @return true if the server support creating new accounts.
  */
 public boolean supportsAccountCreation() {
   // Check if we already know that the server supports creating new accounts
   if (accountCreationSupported) {
     return true;
   }
   // No information is known yet (e.g. no stream feature was received from the server
   // indicating that it supports creating new accounts) so send an IQ packet as a way
   // to discover if this feature is supported
   try {
     if (info == null) {
       getRegistrationInfo();
       accountCreationSupported = info.getType() != IQ.Type.ERROR;
     }
     return accountCreationSupported;
   } catch (XMPPException xe) {
     return false;
   }
 }