}
String email;
if(!hasEmailInShibAttr) email = regWithEmailForm.getEmail();
else email = userMapping.getEMail();
User user = UserManager.getInstance().findUserByEmail(email);
if (user != null) {
// error, email already exists. should actually not happen if OLAT Authenticator has
// been set after removing shibboleth authenticator
getWindowControl().setError(translator.translate("sr.error.emailexists", new String[] {WebappHelper.getMailConfig("mailSupport")}));
mainContainer.setPage(VELOCITY_ROOT + "/register.html");
state = STATE_UNDEFINED;
return;
}
String firstName = userMapping.getFirstName();
String lastName = userMapping.getLastName();
user = UserManager.getInstance().createUser(firstName, lastName, email);
user.setProperty(UserConstants.INSTITUTIONALNAME, userMapping.getInstitutionalName());
if(hasEmailInShibAttr){
user.setProperty(UserConstants.INSTITUTIONALEMAIL, userMapping.getInstitutionalEMail());
}
user.setProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, userMapping.getInstitutionalUserIdentifier());
identity = secMgr.createAndPersistIdentityAndUser(choosenLogin, user, ShibbolethDispatcher.PROVIDER_SHIB, shibbolethUniqueID, null);
SecurityGroup olatUserGroup = secMgr.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
secMgr.addIdentityToSecurityGroup(identity, olatUserGroup);
// tell system that this user did accept the disclaimer
RegistrationManager.getInstance().setHasConfirmedDislaimer(identity);
doLogin(identity, ureq);
return;
} else if (state == STATE_MIGRATED_SHIB_USER) { // ...proceed and migrate user
// create additional authentication
Authentication auth = migrationForm.getAuthentication();
Identity authenticationedIdentity = auth.getIdentity();
Manager secMgr = ManagerFactory.getManager();
secMgr.createAndPersistAuthentication(authenticationedIdentity, ShibbolethDispatcher.PROVIDER_SHIB, shibbolethUniqueID, null);
// update user profile
User user = authenticationedIdentity.getUser();
String s = userMapping.getFirstName();
if (s != null) user.setProperty(UserConstants.FIRSTNAME, s);
s = userMapping.getLastName();
if (s != null) user.setProperty(UserConstants.LASTNAME, s);
s = userMapping.getInstitutionalName();
if (s != null) user.setProperty(UserConstants.INSTITUTIONALNAME, s);
s = userMapping.getInstitutionalEMail();
if (s != null) user.setProperty(UserConstants.INSTITUTIONALEMAIL, s);
s = userMapping.getInstitutionalUserIdentifier();
if (s != null) user.setProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, s);
UserManager.getInstance().updateUser(user);
doLogin(authenticationedIdentity, ureq);
return;
}
} else if (event == Event.CANCELLED_EVENT) {