* @param callback
*/
protected void registerLdapUser(final DynamicForm populatedForm,
final AsyncCallback<Subject> callback) {
final Subject newSubject = UserSessionManager.getSessionSubject();
//insert some required data checking
boolean proceed = true;
String retrieved = populatedForm.getValueAsString(USERNAME);
if ((retrieved == null) || retrieved.isEmpty() || retrieved.equalsIgnoreCase("null")) {
proceed = false;
}
retrieved = populatedForm.getValueAsString(SESSIONID);
if ((retrieved == null) || retrieved.isEmpty() || retrieved.equalsIgnoreCase("null")) {
proceed = false;
}
retrieved = populatedForm.getValueAsString(PASSWORD);
if ((retrieved == null) || retrieved.isEmpty() || retrieved.equalsIgnoreCase("null")) {
proceed = false;
}
newSubject.setName(populatedForm.getValueAsString(USERNAME));
newSubject.setSessionId(Integer.valueOf(populatedForm.getValueAsString(SESSIONID)));
//don't load null values not set or returned from ldap server
retrieved = populatedForm.getValueAsString(FIRST);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
newSubject.setFirstName(populatedForm.getValueAsString(FIRST));
retrieved = populatedForm.getValueAsString(LAST);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
newSubject.setLastName(populatedForm.getValueAsString(LAST));
retrieved = populatedForm.getValueAsString(DEPARTMENT);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
newSubject.setDepartment(populatedForm.getValueAsString(DEPARTMENT));
retrieved = populatedForm.getValueAsString(EMAIL);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
newSubject.setEmailAddress(populatedForm.getValueAsString(EMAIL));
retrieved = populatedForm.getValueAsString(PHONE);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
newSubject.setPhoneNumber(populatedForm.getValueAsString(PHONE));
// newSubject.setSmsAddress(populatedForm.getValueAsString("sms"));
newSubject.setFactive(true);
if (proceed) {
Log.trace("New LDAP user registration details valid for user '" + newSubject.getName() + "'.");
//proceed with LDAP processing request.
//clear out 'isNewUser' flag.
if (newSubject.getUserConfiguration() != null) {
PropertySimple simple = new PropertySimple("isNewUser", null);
newSubject.getUserConfiguration().put(simple);
}
Set<String> prefsChanges = new HashSet<String>();
prefsChanges.add("isNewUser");
GWTServiceLookup.getSubjectService().updateSubjectAndPreferences(newSubject, prefsChanges, new AsyncCallback<Subject>() {
public void onFailure(Throwable caught) {
Log.error("Failed to register LDAP subject '" + newSubject.getName() + "' " + caught.getMessage(),
caught);
//TODO: pass in warning message to Login Dialog.
showLoginDialog(false);
}