use of gemma.gsec.authentication.UserExistsException in project Gemma by PavlidisLab.
the class UserManagerImpl method createUser.
@Override
@Secured({ "IS_AUTHENTICATED_ANONYMOUSLY", "RUN_AS_ADMIN" })
@Transactional
public void createUser(UserDetails user) {
/*
* UserDetails is not an entity, so this method is not directly managed by the Audit or ACL advice. However, it
* runs in a transaction and calls two service methods which are intercepted. This means it is intercepted
* before the transaction is flushed.
*/
this.validateUserName(user.getUsername());
User u = ubic.gemma.model.common.auditAndSecurity.User.Factory.newInstance();
u.setUserName(user.getUsername());
u.setPassword(user.getPassword());
u.setEnabled(user.isEnabled());
if (user instanceof UserDetailsImpl) {
u.setSignupToken(((UserDetailsImpl) user).getSignupToken());
u.setSignupTokenDatestamp(((UserDetailsImpl) user).getSignupTokenDatestamp());
}
if (user instanceof UserDetailsImpl) {
u.setEmail(((UserDetailsImpl) user).getEmail());
}
try {
u = userService.create(u);
} catch (UserExistsException e) {
throw new RuntimeException(e);
}
// Add the user to the default user group.
UserGroup g = this.loadGroup(AuthorityConstants.USER_GROUP_NAME);
userService.addUserToGroup(g, u);
/*
* We don't log the user in automatically, because we require that new users click a confirmation link in an
* email.
*/
}
Aggregations