account.setPassword(user.getPassword());
account.setUsername(userName);
// Saving the account to the Directory where the Tooter application belongs.
Directory directory = stormpath.getDirectory();
directory.createAccount(account);
if (user.getGroupUrl() != null && !user.getGroupUrl().isEmpty()) {
account.addGroup(stormpath.getDataStore().getResource(user.getGroupUrl(), Group.class));
}