Search in sources :

Example 1 with User

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);
    }
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) User(org.shredzone.cilla.core.model.User) CillaServiceException(org.shredzone.cilla.ws.exception.CillaServiceException) Authentication(org.springframework.security.core.Authentication)

Example 2 with User

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);
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) User(org.shredzone.cilla.core.model.User)

Example 3 with 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;
}
Also used : User(org.shredzone.cilla.core.model.User)

Example 4 with User

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);
}
Also used : User(org.shredzone.cilla.core.model.User)

Example 5 with User

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);
}
Also used : User(org.shredzone.cilla.core.model.User) CillaParameterException(org.shredzone.cilla.ws.exception.CillaParameterException)

Aggregations

User (org.shredzone.cilla.core.model.User)10 CillaServiceException (org.shredzone.cilla.ws.exception.CillaServiceException)2 SyndCategory (com.rometools.rome.feed.synd.SyndCategory)1 SyndCategoryImpl (com.rometools.rome.feed.synd.SyndCategoryImpl)1 SyndContent (com.rometools.rome.feed.synd.SyndContent)1 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)1 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)1 SyndLink (com.rometools.rome.feed.synd.SyndLink)1 SyndLinkImpl (com.rometools.rome.feed.synd.SyndLinkImpl)1 SyndPerson (com.rometools.rome.feed.synd.SyndPerson)1 SyndPersonImpl (com.rometools.rome.feed.synd.SyndPersonImpl)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Comment (org.shredzone.cilla.core.model.Comment)1 CommentThread (org.shredzone.cilla.core.model.CommentThread)1 Page (org.shredzone.cilla.core.model.Page)1 FormattedText (org.shredzone.cilla.core.model.embed.FormattedText)1 CillaUserDetails (org.shredzone.cilla.service.security.CillaUserDetails)1 FeedViewInterceptor (org.shredzone.cilla.view.interceptor.FeedViewInterceptor)1