if (userOpenId == null) {
return null;
}
User user = MetaProjectManager.getManager().getMetaProject().getUser(userName);
if (user != null) {
UserData userData = AuthenticationUtil.createUserData(UserId.getUserId(userName));
userData.setProperty(OpenIdUtil.REGISTRATION_RESULT_PROP, OpenIdConstants.USER_ALREADY_EXISTS);
return userData;
}
UserData userData = MetaProjectManager.getManager().registerUser(userName, emailId, password);
user = MetaProjectManager.getManager().getMetaProject().getUser(userName);
user.setEmail(emailId);
String openIdPropBase = OpenIdConstants.OPENID_PROPERTY_PREFIX;
for (int index = 1;; index++) {
String opnId = user.getPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX);
if (opnId == null) {
user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX, userOpenId);
user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_ID_SUFFIX, openIdAccName);
user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_PROVIDER_SUFFIX, openIdProvider);
break;
}
}
Log.getLogger().info("User " + userName + " created at: " + new Date() + " with OpenId: " + userOpenId);