use of org.shredzone.cilla.core.model.User in project cilla by shred.
the class CillaUserDetailsManager method changePassword.
@Override
public void changePassword(String oldPassword, String newPassword) {
Authentication currentUser = SecurityContextHolder.getContext().getAuthentication();
if (currentUser == null) {
throw new AccessDeniedException("No user is logged in");
}
String username = currentUser.getName();
User user = userDao.fetchByLogin(username);
if (user == null) {
throw new AccessDeniedException("User without account");
}
try {
userService.changePassword(user, oldPassword, newPassword);
} catch (CillaServiceException ex) {
throw new AccessDeniedException("Could not change password", ex);
}
}
use of org.shredzone.cilla.core.model.User in project cilla by shred.
the class CillaUserDetailsManager method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
User user = userDao.fetchByLogin(username);
if (user == null) {
throw new UsernameNotFoundException(username);
}
log.debug("Successfully logged in: {}", user.getLogin());
return new CillaUserDetails(user);
}
use of org.shredzone.cilla.core.model.User in project cilla by shred.
the class CommentThreadServiceImpl method assembleThreadedComment.
/**
* Assembles a {@link CommentModel} instance for a {@link Comment}.
*
* @param comment
* {@link Comment} to assemble
* @return Assembled {@link CommentModel}
*/
private CommentModel assembleThreadedComment(Comment comment) {
CommentModel pc = new CommentModel();
pc.setId(comment.getId());
pc.setName(comment.getName());
pc.setUrl(comment.getUrl());
pc.setCreation(comment.getCreation());
pc.setText(textFormatter.format(comment.getText()).toString());
String mail = comment.getMail();
User creator = comment.getCreator();
if (creator != null) {
pc.setCreatorId(creator.getId());
mail = creator.getMail();
}
if (mail != null) {
pc.setMail(mail);
pc.setMailhash(computeMailHash(mail));
}
return pc;
}
use of org.shredzone.cilla.core.model.User in project cilla by shred.
the class UserServiceImpl method deleteUser.
@Override
public void deleteUser(User user) {
// Do not use merge, to avoid involuntary changes to the database entity
User attached = userDao.fetch(user.getId());
userDao.delete(attached);
}
use of org.shredzone.cilla.core.model.User in project cilla by shred.
the class UserServiceImpl method changeLogin.
@Override
public void changeLogin(User user, String newLogin) throws CillaServiceException {
if (newLogin == null || newLogin.isEmpty()) {
throw new CillaParameterException("new login name must not be empty");
}
User check = userDao.fetchByLogin(newLogin);
if (check != null && !check.equals(user)) {
throw new CillaParameterException("login name '" + newLogin + "' is already used");
}
user.setLogin(newLogin);
}
Aggregations