Package org.encuestame.persistence.domain.security

Examples of org.encuestame.persistence.domain.security.UserAccount


     * Load Groups by Client
     * @return list of groups
     * @throws EnMeNoResultsFoundException exception
     */
    public List<UnitGroupBean> loadGroups(final String currentUsername) throws EnMeNoResultsFoundException{
        final UserAccount userAccount = getUserAccount(currentUsername);
        final List<UnitGroupBean> groupBeans = new ArrayList<UnitGroupBean>();
        final List<Group> groupsList = getGroupDao().loadGroupsByUser(userAccount.getAccount());
        for (Group groups : groupsList) {
            groupBeans.add(ConvertDomainBean.convertGroupDomainToBean(groups));
        }
        return groupBeans;
    }
View Full Code Here


     * @param username username
     * @return {@link UserAccountBean}
     */
    @Cacheable(cacheName = "searchUserByUsername")
    public UserAccountBean searchUserByUsername(final String username) {
        final UserAccount userDomain = getAccountDao().getUserByUsername(username);
        UserAccountBean user = null;
        if (userDomain != null) {
            user = ConvertDomainBean.convertSecondaryUserToUserBean(userDomain);
        } else {
            log.error("user not found");
View Full Code Here

     * Delete user.
     * @param userBean user to delete
     * @throws EnMeNoResultsFoundException
     */
    public void deleteUser(final UserAccountBean userBean) throws EnMeNoResultsFoundException{
            final UserAccount userDomain = getUserAccount(userBean.getUsername());
                log.info("notify delete account");
                if (EnMePlaceHolderConfigurer.getBooleanProperty("application.email.enabled")) {
                    getMailService().sendDeleteNotification(userBean.getEmail().trim(),
                            getMessageProperties("userMessageDeleteNotification"));
                }
View Full Code Here

     * @param newPassword new password
     * @throws EnMeExpcetion
     */
    public String renewPassword(final UserAccountBean userBean, String newPassword) throws EnMeExpcetion {
        // search user
        final UserAccount userDomain = getUserAccount(userBean.getUsername());
        // validate user and password
        if (userDomain != null && newPassword != null) {
            //set new password
            userDomain.setPassword(EnMePasswordUtils.encryptPassworD(newPassword));
            //TODO: security risk?
            userBean.setPassword(newPassword);
            //if notification is suspended we need retrieve password
            if (EnMePlaceHolderConfigurer.getBooleanProperty("application.email.enabled")) {
                try {
View Full Code Here

     * @param userBean user bean.
     * @throws EnMeExpcetion exception
     */
    public void updateUser(final UserAccountBean userBean){
        log.info("service update user method");
            final UserAccount updateUser = getAccountDao().getUserByUsername(userBean.getUsername());
            log.info("update user, user found: "+updateUser.getUid());
            if (updateUser != null) {
                updateUser.setUserEmail(userBean.getEmail());
                updateUser.setCompleteName(userBean.getName());
                updateUser.setUserStatus(userBean.getStatus());
                log.info("updateing user, user "+updateUser.getUid());
                getAccountDao().saveOrUpdate(updateUser);
            }
    }
View Full Code Here

     * @param userBean {@link UserAccountBean}
     * @throws EnMeExpcetion personalize exception
     * @return if password is not notified  is returned
     */
    public void createUser(final UserAccountBean userBean, final String username) throws EnMeExpcetion {
        final UserAccount userAccount = new UserAccount();
        final Account account = getUserAccount(username).getAccount();
        //validate email and password
        if (userBean.getEmail() != null && userBean.getUsername() != null) {
            userAccount.setUserEmail(userBean.getEmail());
            userAccount.setUsername(userBean.getUsername());
            userAccount.setAccount(account);
        } else {
            throw new EnMeExpcetion("needed email and username to create user");
        }
        String password = null;
        if (userBean.getPassword() != null) {
             password = userBean.getPassword();
             userAccount.setPassword(EnMePasswordUtils.encryptPassworD(password));
        }
        else{
            password = generatePassword();
            userAccount.setPassword(EnMePasswordUtils.encryptPassworD(password));
        }
        //TODO: maybe we need create a table for editor permissions
        userAccount.setCompleteName(userBean.getName() == null ? "" : userBean.getUsername());
        userAccount.setUserStatus(Boolean.TRUE);
        userAccount.setEnjoyDate(Calendar.getInstance().getTime());
            // send to user the password to her emails
            final SignUpBean singUpBean = new SignUpBean();
            singUpBean.setEmail(userBean.getEmail());
            singUpBean.setFullName(userAccount.getCompleteName());
            singUpBean.setUsername(userBean.getUsername());
            singUpBean.setPassword(password);
            final String inviteCode =  UUID.randomUUID().toString();
            userAccount.setInviteCode(inviteCode);
            try {
                getMailService().sendConfirmYourAccountEmail(singUpBean, inviteCode);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            try {
                getMailService().sendPasswordConfirmationEmail(singUpBean);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            // save user
            getAccountDao().saveOrUpdate(userAccount);
            // assing first default group to user
            final UserAccount retrievedUser = getAccountDao().getUserAccountById(userAccount.getUid());
            final Permission permission = getPermissionByName(SecurityService.DEFAULT);
            if (permission != null) {
                final List<Permission> all = getPermissionDao().findAllPermissions();
                log.info("all permission "+all.size());
                log.info("default permission "+permission);
                retrievedUser.getSecUserPermissions().add(permission);
            }
            else{
                log.warn("error assing default permissions");
            }
            log.info("saving user");
View Full Code Here

    public void assignPermission(
            final UserAccountBean userBean,
            final UnitPermission permissionBean)
            throws EnMeExpcetion
   {
        UserAccount userDomain = null;
        Permission permissionDomain = null;
        log.info("userBean found "+userBean.getId());
        log.info("permissionBean found "+permissionBean.getId());
        if (userBean.getId() != null) {
            userDomain = getAccountDao().getUserAccountById(userBean.getId());
            log.info("user found "+userDomain);
        }
        if (permissionBean.getId() != null) {
            permissionDomain = getPermissionDao().getPermissionById(permissionBean.getId());
            log.info("permission found "+permissionDomain);
        }
        if (userDomain != null && permissionDomain != null) {
           log.info("saving permissions");
           log.info("permission selected "+permissionDomain.getPermission());
           log.info("user selected "+userDomain.getUid());
           userDomain.getSecUserPermissions().add(permissionDomain);
           getAccountDao().saveOrUpdate(userDomain);
           log.info("saved permission "+userDomain.getSecUserPermissions().size());
        } else {
            throw new EnMeExpcetion("error adding permission");
        }
    }
View Full Code Here

            final Long userId,
            final String loggedUser,
            final EnMePermission permission,
            final String action)
            throws EnMeExpcetion{
        final UserAccount user = getValidateUser(userId, loggedUser);
        if(user == null){
            throw new EnMeNoResultsFoundException("user not found");
        } else {
            log.debug("Update Permission "+permission.toString());
            if(action.equals("add")){
                user.getSecUserPermissions().add(this.getPermissionByName(permission));
                log.debug("Added Permission "+permission.toString());
            } else if(action.equals("remove")){
                user.getSecUserPermissions().remove(this.getPermissionByName(permission));
                log.debug("Removed Permission "+permission.toString());
            }
            getAccountDao().saveOrUpdate(user);
        }
    }
View Full Code Here

     */
    public void assingGroupFromUser(
            final Long groupId,
            final Long userId,
            final String username) throws EnMeNoResultsFoundException {
        final UserAccount userAccount = getUserAccount(userId); //TODO: I need confirm this user perhaps same group of logged user.
        //search group by group id and owner user id.
        final Group group = getGroupDao().getGroupById(groupId, getUserAccount(username).getAccount());
        if(group == null){
            throw new EnMeNoResultsFoundException("group not found");
        } else {
            //add new group.
            userAccount.setGroup(group);
            getAccountDao().saveOrUpdate(userAccount);
        }
    }
View Full Code Here

     * Change User Status.
     * @param username
     * @throws EnmeFailOperation
     */
    public void changeUserStatus(final String username) throws EnmeFailOperation{
        final UserAccount secondaryUser = getAccountDao().getUserByUsername(username);
        if (secondaryUser != null){
            secondaryUser.setUserStatus(secondaryUser.isUserStatus()== null ? false : ! secondaryUser.isUserStatus());
            getAccountDao().saveOrUpdate(secondaryUser);
        }
        else {
            throw new EnmeFailOperation("Fail Change User Status");
        }
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.security.UserAccount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.