Package org.encuestame.persistence.domain.security

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


     * @see org.encuestame.core.service.imp.SecurityOperations#createAdministrationUser(org.encuestame.core.config.AdministratorProfile)
     */
    public UserAccountBean createAdministrationUser(
            final AdministratorProfile administratorProfile) {
        log.debug("----------- create administration user ---------");
        final UserAccount userAccount = new UserAccount();
        try{
            final Account account = this.createDefaultAccount();
            // create directory account.
            // this.createDirectoryAccount(account);
            // create first user account.
            userAccount.setUsername(administratorProfile.getUsername());
            // generate password.
            final String password = this
                    .generateRandomPassword(administratorProfile.getPassword());
            userAccount.setPassword(encodingPassword(password));
            // invite code
            userAccount.setEnjoyDate(Calendar.getInstance().getTime()); // current
                                                                        // date
            userAccount.setAccount(account);
            userAccount.setUserStatus(Boolean.TRUE);
            userAccount.setUserEmail(administratorProfile.getEmail());
            userAccount.setCompleteName(administratorProfile.getUsername());
            getAccountDao().saveOrUpdate(userAccount);
            log.debug("administration user ----> "+userAccount.toString());
            // default permissions.
            final Set<Permission> permissions = new HashSet<Permission>();
            permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_USER));
            permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_ADMIN));
            permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_OWNER));
            permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_PUBLISHER));
            permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_EDITOR));
            this.assingPermission(userAccount, permissions);
            log.debug("administration user ----> Adding Security label");
           
            // create a dashboard by default
            //createDefaultDashboard(userAccount);

            //Disabled auto-autenticate, the administrative user should sign in manually
            //SecurityUtils.authenticate(userAccount);

            if (log.isDebugEnabled()) {
                log.debug("new user " + userAccount.getUsername());
                log.debug("Get Authoritie Name:{ "
                        + SecurityContextHolder.getContext()
                                .getAuthentication().getName());
            }
        } catch (Exception e) {
View Full Code Here


        //create account/
        final Account account = this.createDefaultAccount();
        //create directory account.
        createDirectoryAccount(account);
        //create first user account.
        final UserAccount userAccount = new UserAccount();
        userAccount.setUsername(singUpBean.getUsername());
        //generate password.
        final String password = singUpBean.getPassword() == null ? EnMePasswordUtils
                .createRandomPassword(EnMePasswordUtils.DEFAULT_LENGTH_PASSWORD)
                : singUpBean.getPassword();
        userAccount.setPassword(encodingPassword(password));
        singUpBean.setPassword(password);
        //invite code
        final String inviteCode =  UUID.randomUUID().toString();
        userAccount.setEnjoyDate(Calendar.getInstance().getTime()); //current date
        userAccount.setAccount(account);
        userAccount.setUserStatus(Boolean.TRUE);
        userAccount.setSharedProfile(Boolean.TRUE);
        userAccount.setUserEmail(singUpBean.getEmail());
        userAccount.setCompleteName(singUpBean.getFullName());
        userAccount.setInviteCode(inviteCode); //thinking, maybe create invite code table.
        getAccountDao().saveOrUpdate(userAccount);
        //create global account directory
        if (log.isDebugEnabled()) {
            log.debug("singupUser created user account");
        }
        //default permissions.
        final Set<Permission> permissions = new HashSet<Permission>();
        permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_USER));
        permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_OWNER));
        permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_PUBLISHER));
        permissions.add(getPermissionByName(EnMePermission.ENCUESTAME_EDITOR));
        this.assingPermission(userAccount, permissions);

        if (!disableEmail) { //test proposes.
            //send new password
            if (EnMePlaceHolderConfigurer.getBooleanProperty("application.email.enabled")) {
                //send confirmation account request
                try {
                    getMailService().sendConfirmYourAccountEmail(singUpBean, inviteCode);
                } catch (Exception e) {
                    // ENCUESTAME-602 ????
                    e.printStackTrace();
                }
            }
        }

        if (log.isDebugEnabled()) {
            log.debug("new user "+userAccount.getUsername());
            log.debug("Get Authoritie Name:{ "+SecurityContextHolder.getContext().getAuthentication().getName());
        }
         
        // create a welcome notification
        createNotification(NotificationEnum.WELCOME_SIGNUP,
View Full Code Here

    /**
     *
     */
    @Before
    public void initService() {
        final UserAccount user = createUserAccount("jota", createAccount());
        final Question question = createQuestion("question1", user.getAccount());
        this.tweetPoll = createTweetPollPublicated(true, true, new Date(), user, question);
        final SocialAccount socialAccount = createSocialAccount(
                getProperty("twitter.test.token"),
                getProperty("twitter.test.tokenSecret"),
                user,
View Full Code Here

     *
     * @param username
     * @return
     */
    public Boolean validateUsername(final String username, final UserAccount userLogged) {
        final UserAccount user = getUser(username);
        return this.validateUsername(username, user, userLogged);
    }
View Full Code Here

     * Find a user in the database.
     * @param username user to find
     * @return {@link UserAccount} if exist, if not, return null
     */
    private UserAccount getUser(final String username) {
        final UserAccount user = getSecurityService().findUserByUserName(username);
        return user;
    }
View Full Code Here

     */
    public Boolean validateUserEmail(final String email, final UserAccount userLogged) {
        log.debug("validating email... ->"+email);
        if (this.validateEmail(email)) {
            // try to find a user with the same email
            final UserAccount user = getSecurityService().findUserAccountByEmail(email);
            return this.validateUserEmail(email, user, userLogged);
        } else {
             getMessages().put("email", "email wrong format");
            return false;
        }
View Full Code Here

     * @return
     */
    public UserAccount checkifEmailExist(String email) {
        log.debug("checkifEmailExist email... -> " + email);        //
        email = email == null ? "" : email;
        final UserAccount user = getSecurityService().findUserAccountByEmail(email);
        return user;
    }
View Full Code Here

           final String currentUsername,
           final Integer maxResults,
           final Integer start) throws EnMeNoResultsFoundException {
        log.info("currentUsername "+currentUsername);
        List<UserAccountBean> loadListUsers = new LinkedList<UserAccountBean>();
        final UserAccount userAccount = this.getUserAccount(currentUsername);
        if(userAccount != null){
            final Collection<UserAccount> listUsers = getAccountDao()
                 .retrieveListOwnerUsers(userAccount.getAccount(), start, maxResults);
                log.info("list users " + listUsers.size());
                loadListUsers = ConvertDomainBean.convertCollectionUsersToBean(listUsers);
        }
        return loadListUsers;
    }
View Full Code Here

     * @param loggedUserName
     * @return
     */
    private Boolean validateOwnerGroup(final UserAccount user, final String loggedUserName){
        Boolean validate = Boolean.FALSE;
        final UserAccount owner = getAccountDao().getUserByUsername(loggedUserName);
        if(user != null && owner != null){
            if(user.getAccount().getUid().equals(owner.getAccount().getUid())){
                validate = Boolean.TRUE;
            }
        }
        log.debug("validateOwnerGroup info "+validate);
        return validate;
View Full Code Here

     * @return
     * @throws EnMeNoResultsFoundException
     */
    public UserAccountBean getUserCompleteInfo(final Long userId, final String currentUsername) throws EnMeNoResultsFoundException {
        UserAccountBean userInfo = null;
        final UserAccount user = getAccountDao().getUserAccountById(userId);
        if(this.validateOwnerGroup(user, currentUsername)){
            userInfo =  ConvertDomainBean.convertSecondaryUserToUserBean(user);
            log.debug("getUserCompleteInfo info "+userInfo.getId());
        }
        return userInfo;
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.