Package org.encuestame.mvc.validator

Examples of org.encuestame.mvc.validator.ValidateOperations


        log.debug("update profile type:" + type);
        log.debug("update profile data:" + data);
        try {
            final SecurityOperations security = getSecurityService();
            final ValidateOperations operations = new ValidateOperations(security);
            final HashMap<String, Object> listError = new HashMap<String, Object>();
            //filter data
            data = filterValue(data);
            if (type.equals(Profile.EMAIL.toString())) {
                //TODO: review pattern email format validator.
                log.debug("update email");
                final UserAccount account = getSecurityService().getUserAccount(getUserPrincipalUsername());
                if (operations.validateUserEmail(data, account)) {
                    security.updateAccountProfile(Profile.EMAIL, data);
                    setSuccesResponse();
                } else {
                    listError.put(type, getMessage("e_005", request, null));
                }
            } else if(type.equals(Profile.USERNAME.toString())) {
                log.debug("update username");
                final UserAccount account = getSecurityService().getUserAccount(getUserPrincipalUsername());
                if (operations.validateUsername(data, account)) {
                    security.updateAccountProfile(Profile.USERNAME, data);
                    setSuccesResponse(getMessage("settings_config_profile_success", request, null));
                } else {
                    listError.put(type, getMessage("e_018", request, null));
                }
View Full Code Here


            JsonMappingException, IOException {
        try {
            final SecurityOperations security = getSecurityService();
            // get the user account of previous user logged.
            final UserAccount account = getUserAccount();
            final ValidateOperations operations = new ValidateOperations(security);
            final HashMap<String, Object> listError = new HashMap<String, Object>();
            //filter values.
            log.debug("email " +email);
            log.debug("username " +username);
            log.debug("completeName " +completeName);
            log.debug("language " +language);
            log.debug("bio " +bio);
            email = email != null  ? filterValue(email) : null;
            username = username != null ? filterValue(username) : null;
            completeName = completeName != null ? filterValue(completeName) : null;
            language = language != null ? filterValue(language) : language;
            bio = bio != null ? filterValue(bio) : null;
            //valid flag.
            boolean valid = true;
            boolean emailValid = operations.validateUserEmail(email, account);
            log.debug("emailValid " +emailValid);
            if (!emailValid) {
                listError.put("username", getMessage("e_018", request, null));
                valid = false;
            }
            boolean usernameValid = operations.validateUsername(username, account);
            log.debug("usernameValid " +usernameValid);
            if (!usernameValid) {
                listError.put("email", getMessage("e_005", request, null));
               valid = false;
            }
View Full Code Here

            final UserAccountBean userBean = new UserAccountBean();
            userBean.setEmail(email);
            userBean.setUsername(username);
            // get the current user logged
            final UserAccount account = getUserAccount();
            final ValidateOperations cv = new ValidateOperations( getServiceManager().getApplicationServices()
                  .getSecurityService());
            boolean emailValid = cv.validateUserEmail(email, account);
            boolean usernameValid = cv.validateUsername(username, account);
            if (emailValid && usernameValid) {
                getServiceManager().getApplicationServices().getSecurityService().createUser(userBean, getUserPrincipalUsername());
                setSuccesResponse();
            } else {
                setError(getMessage("e_026", request, null), response);
View Full Code Here

            HttpServletResponse response) throws JsonGenerationException,
            JsonMappingException, IOException {
        try {
            final Map<String, Object> jsonResponse = new HashMap<String, Object>();
            final String valueFilteres = filterValue(value);
            final ValidateOperations operations = new ValidateOperations(getSecurityService(), getUserAccount());
            final UserAccount account = getUserAccount();
            if (Profile.findProfile(type).equals(Profile.USERNAME)) {
                if (operations.validateUsername(valueFilteres, account)) {
                    jsonResponse.put("validate", true);
                } else {
                    jsonResponse.put("validate", false);
                }
            } else if (Profile.findProfile(type).equals(Profile.EMAIL)) {
                if (operations.validateUserEmail(valueFilteres, account)) {
                    jsonResponse.put("validate", true);
                } else {
                    jsonResponse.put("validate", false);
                }
            } else {
                setError("invalid params", response);
            }
            log.debug("messages"+ operations.getMessages().toString());
            jsonResponse.put("messages", operations.getMessages());
            setItemResponse(jsonResponse);
        } catch (Exception e) {
            log.error(e);
            setError(e.getMessage(), response);
        }
View Full Code Here

            @RequestParam(value = "email", required = true) String email,
            HttpServletResponse response) throws JsonGenerationException,
            JsonMappingException, IOException {
        try {
            final String valueFilteres = filterValue(email);
            final ValidateOperations cv = new ValidateOperations( getServiceManager().getApplicationServices().getSecurityService());
            boolean existEmail = cv.validateUserEmail(valueFilteres, null);
            if (!existEmail) {
                throw new EnMeExpcetion(getMessage("e_008", request, null));
            }
            getMailService().sendEmailJoinInvitation(valueFilteres, getUserPrincipalUsername());
            //FUTURE: count and limit the number of invitations
View Full Code Here

     * @return
     */
    protected  Map<String, Object> validate(final String context, final String type, String value, final  HttpServletRequest request) {
        value = value == null ? "" : value;
        final Map<String, Object> jsonResponse = new HashMap<String, Object>();
        final ValidateOperations validateOperations = new ValidateOperations(getSecurityService());
        boolean valid = false;
        if ("email".equals(type)) {
            if (value.isEmpty() || value.length() < ValidateOperations.MIN_EMAIL_LENGTH) {
                 log.debug("validate email emtpy");
                jsonResponse.put("msg", getMessage("secure.email.emtpy", request, null));
            } else {
                valid = validateOperations.validateUserEmail(value, null);
                log.debug("validate EMAIL"+valid);
                if (valid) {
                    jsonResponse.put("msg", getMessage("secure.email.valid", request, null));
                } else {
                    jsonResponse.put("msg", getMessage("secure.email.notvalid", request, null));
                }
            }
        } else if("username".equals(type)) {
            valid = validateOperations.validateUsername(value, null);
            if(value.isEmpty() || value.length() < ValidateOperations.MIN_USERNAME_LENGTH) {
                log.debug("validate username emtpy");
                jsonResponse.put("msg", getMessage("secure.username.empty", request, null));
            } else {
                log.debug("validate username NO emtpy");
View Full Code Here

        user.setEmail(filterValue(emailForm));
        user.setPassword(password);
        user.setFullName(filterValue(realName));
        user.setUsername(filterValue(usernameForm));
        final SecurityOperations _service = getSecurityService();
        final ValidateOperations validation = new ValidateOperations(_service);
        if (validation.validateSignUpForm(usernameForm, emailForm, password)) {
            log.debug(" the signup process successfull");
            try {
                _service.singupUser(user, false);
            } catch (Exception e) {
                 RequestSessionMap.getCurrent(req).put("signupError", Boolean.TRUE);
View Full Code Here

        final String email = user.getEmail() == null ? "" : user.getEmail();
        if (!email.isEmpty()) {
                log.debug("email " + email);
                final ReCaptchaResponse reCaptchaResponse = getReCaptcha().checkAnswer(
                        req.getRemoteAddr(), challenge, response);
                final ValidateOperations validation = new ValidateOperations(
                        getSecurityService());
                boolean _isValidEmailFormat = validation.validateEmail(email);
                log.info("EMAIL FORMAT NOT VALID --> " + _isValidEmailFormat);
                if (_isValidEmailFormat) {
                     final UserAccount userValidate = validation.checkifEmailExist(email);
                     if (userValidate == null) {
                         result.rejectValue("email", "secure.email.notvalid", new Object[] { user.getEmail() }, "");
                     }
                     log.info("reCaptchaResponse " + reCaptchaResponse.isValid());
                     //validate reCaptcha
                     validation.validateCaptcha(reCaptchaResponse, result);
                     if(reCaptchaResponse.getErrorMessage() != null) {
                         RequestSessionMap.getCurrent(req).put("resetError", Boolean.TRUE);
                         RequestSessionMap.getCurrent(req).put("resetErrorMessage", reCaptchaResponse.getErrorMessage());
                         log.fatal("reCaptcha Fatal Error: "+reCaptchaResponse.getErrorMessage());
                     }
View Full Code Here

             //security service
             final SecurityOperations securityService = getServiceManager().getApplicationServices().getSecurityService();
             //check if captcha is valid
             final ReCaptchaResponse reCaptchaResponse = getReCaptcha().checkAnswer(req.getRemoteAddr(), challenge, response);
             //validation layer
             final ValidateOperations validation = new ValidateOperations(securityService);
             validation.validateCaptcha(reCaptchaResponse, result);
             log.info("reCaptchaResponse "+reCaptchaResponse.getErrorMessage());
             log.info("reCaptchaResponse "+reCaptchaResponse.isValid());
             log.info("result.hasErrors() "+result.hasErrors());
             if (result.hasErrors()) {
                //build new reCAPTCHA
View Full Code Here

TOP

Related Classes of org.encuestame.mvc.validator.ValidateOperations

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.