dclController.changeLocale(lcev.getNewLocale());
}
} else if (source == dclController) {
if (event == Event.DONE_EVENT) { // disclaimer accepted...
if (state == STATE_NEW_SHIB_USER) { // ...proceed and create user
Manager secMgr = ManagerFactory.getManager();
String choosenLogin = regForm.getLogin();
// check if login has been taken by another user in the meantime...
Identity identity = secMgr.findIdentityByName(choosenLogin);
if (identity != null) {
getWindowControl().setError(translator.translate("sr.login.meantimetaken"));
mainContainer.setPage(VELOCITY_ROOT + "/register.html");
state = STATE_UNDEFINED;
return;
}
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);