List of usage examples for org.apache.commons.validator.routines EmailValidator getInstance
public static EmailValidator getInstance()
From source file:com.bia.gmailjava.EmailService.java
/** * * @param emails//from ww w . j a v a 2s . c om * @return */ private boolean isValidEmail(String... emails) { if (emails == null) { return false; } for (String email : emails) { if (!EmailValidator.getInstance().isValid(email)) { return false; } } return true; }
From source file:com.formkiq.core.service.formInterceptor.SystemConfigInterceptor.java
@Override public Map<String, String> validateFormJSON(final FormJSON form) { FormJSONField host = findValueByKey(form, "hostname").get(); FormJSONField email = findValueByKey(form, "erroremail").get(); FormJSONField f0 = findValueByKey(form, "assetservicedb").get(); FormJSONField f1 = findValueByKey(form, "assetservices3").get(); Map<String, String> errors = new HashMap<>(); if (isEmpty(f0.getValue()) && isEmpty(f1.getValue())) { errors.put("" + f0.getId(), "Asset Store required"); errors.put("" + f1.getId(), "Asset Store required"); }//www.j a va 2s. c o m if (!EmailValidator.getInstance().isValid(email.getValue())) { errors.put("" + email.getId(), "Invalid Email"); } validateHost(host, errors); return errors; }
From source file:com.google.gerrit.server.account.CreateEmail.java
@Override public Response<EmailInfo> apply(AccountResource rsrc, EmailInput input) throws AuthException, BadRequestException, ResourceConflictException, ResourceNotFoundException, OrmException, EmailException, MethodNotAllowedException, IOException { if (self.get() != rsrc.getUser() && !self.get().getCapabilities().canModifyAccount()) { throw new AuthException("not allowed to add email address"); }//from w w w . j av a 2 s. com if (input == null) { input = new EmailInput(); } if (!EmailValidator.getInstance().isValid(email)) { throw new BadRequestException("invalid email address"); } if (input.noConfirmation && !self.get().getCapabilities().canModifyAccount()) { throw new AuthException("not allowed to use no_confirmation"); } if (!realm.allowsEdit(FieldName.REGISTER_NEW_EMAIL)) { throw new MethodNotAllowedException("realm does not allow adding emails"); } return apply(rsrc.getUser(), input); }
From source file:com.aquest.emailmarketing.web.service.EmailListService.java
/** * Import emailfrom file./* w w w . j ava 2s .c o m*/ * * @param filename the filename * @param separator the separator * @param broadcast_id the broadcast_id * @return the list * @throws IOException Signals that an I/O exception has occurred. */ public List<EmailList> importEmailfromFile(InputStream filename, String separator, String broadcast_id) throws IOException { CSVReader reader = new CSVReader(new InputStreamReader(filename), separator.charAt(0)); boolean isFirstLine = true; boolean valid = true; String[] firstLine = null; String[] nextLine; List<String> notValid = new ArrayList<String>(); List<EmailList> eList = new ArrayList<EmailList>(); Timestamp curTimestamp = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()); System.out.println(broadcast_id); while ((nextLine = reader.readNext()) != null) { if (isFirstLine) { firstLine = nextLine; // print list for (int k = 0; k < firstLine.length; k++) { System.out.println(firstLine[k]); } isFirstLine = false; } else { EmailList emailList = new EmailList(); for (int i = 0; i < firstLine.length; i++) { System.out.println(firstLine.length); // ovo je dirty verzija. napisati kako treba valid = EmailValidator.getInstance().isValid(nextLine[0]); for (int j = 0; j < nextLine.length; j++) { System.out.println(nextLine[j]); } if (valid == true) { if (i == 0) { //DONE: add email address validation emailList.setBroadcast_id(broadcast_id); emailList.setEmail(nextLine[i]); System.out.println("Email: " + nextLine[i]); } else if (i == 1) { emailList.setName1(firstLine[i]); System.out.println("Name1: " + firstLine[i]); emailList.setValue1(nextLine[i]); System.out.println("Value1: " + nextLine[i]); } else if (i == 2) { emailList.setName2(firstLine[i]); emailList.setValue2(nextLine[i]); } else if (i == 3) { emailList.setName3(firstLine[i]); emailList.setValue3(nextLine[i]); } else if (i == 4) { emailList.setName4(firstLine[i]); emailList.setValue4(nextLine[i]); } else if (i == 5) { emailList.setName5(firstLine[i]); emailList.setValue5(nextLine[i]); } else if (i == 6) { emailList.setName6(firstLine[i]); emailList.setValue6(nextLine[i]); } else if (i == 7) { emailList.setName7(firstLine[i]); emailList.setValue7(nextLine[i]); } else if (i == 8) { emailList.setName8(firstLine[i]); emailList.setValue8(nextLine[i]); } else if (i == 9) { emailList.setName9(firstLine[i]); emailList.setValue9(nextLine[i]); } else if (i == 10) { emailList.setName10(firstLine[i]); emailList.setValue10(nextLine[i]); } System.out.println(emailList); emailList.setStatus("READY"); emailList.setProcess_dttm(curTimestamp); } else { notValid.add(nextLine[0]); System.out.println(nextLine[0]); } } if (emailList.getBroadcast_id() != null) { //Save i update ce se raditi u drugoj metodi //emailListDao.saveOrUpdate(emailList); eList.add(emailList); } } } for (EmailList elist : eList) { System.out.println(elist); } reader.close(); return eList; }
From source file:app.comun.ValidadorFormato.java
/** * Valida si un email tiene el formato adecuado * * @param email// www .j a va 2 s . c om * email a validar * @return si es valido */ public Boolean validarEmail(String email) { if (email == null) { return false; } return EmailValidator.getInstance().isValid(email) && email.length() <= 30; }
From source file:com.bia.monitor.service.MonitorService.java
/** * /*from w w w . j av a2 s . c om*/ * @param emails * @return */ private boolean isValidEmail(String email) { if (!EmailValidator.getInstance().isValid(email)) { return false; } return true; }
From source file:com.raven.loginn.service.AccountService.java
public Account loginByEmail(String email, String password) throws Exception { if (GenericValidator.isBlankOrNull(email)) { throw new WarningMessageException("Email bo olamaz"); }//from w w w .j a va 2s . c o m if (!EmailValidator.getInstance().isValid(email)) { throw new WarningMessageException("Email format hatal."); } if (GenericValidator.isBlankOrNull(password)) { throw new WarningMessageException("ifre bo olamaz"); } Account account = findAccountByEmail(email); if (account == null) { throw new WarningMessageException("Bu e-mail ile kaytl kimse bulunamad"); } if (!account.getPassword().equalsIgnoreCase(password)) { throw new WarningMessageException("ifre hatal"); } return account; }
From source file:com.formkiq.core.service.UserServiceImpl.java
@Override public User createUser(final String clientid, final String email, final String password, final UserStatus status, final UserRole role, final String loginToken) throws PreconditionFailedException { if (!this.securityService.isAdmin()) { if (this.systemPropertyService.isInviteOnly() && !UserStatus.INVITE.equals(status)) { throw new PreconditionFailedException("User can only be created via invite"); }/* ww w. j ava2 s . c om*/ } if (!EmailValidator.getInstance().isValid(email)) { throw new PreconditionFailedException("Invalid Email " + email); } if (StringUtils.isEmpty(password)) { throw new PreconditionFailedException("Password required"); } if (status == null) { throw new PreconditionFailedException("UserStatus required"); } if (role == null) { throw new PreconditionFailedException("UserRole required"); } if (this.userDao.findUser(email) != null) { throw new PreconditionFailedException("Email already registered"); } User user = new User(); user.setClientid(clientid); user.setEmail(email); user.setStatus(status); user.setRole(role); setUserPassword(user, password); setUserLoginToken(user, loginToken); user = this.userDao.saveUser(user); return user; }
From source file:net.sourceforge.fenixedu.domain.contacts.EmailAddress.java
private void checkParameters(final String value) { if (!EmailValidator.getInstance().isValid(value)) { throw new DomainException("error.domain.contacts.EmailAddress.invalid.format", value); }/*from www. j av a 2s . c om*/ }
From source file:$.RegistrationAction.java
private void validate(DefaultUser user, String confirmPassword, String captchaChallenge, String captchaResponse) { if (StringUtils.isBlank(user.getUsername())) addFieldError("user.username", getText("message.register.username.notempty")); else if (userManager.getUserByUsername(user.getUsername()) != null) addFieldError("user.username", getText("message.register.username.exist")); if (StringUtils.isBlank(user.getEmail())) addFieldError("user.email", getText("message.register.email.notempty")); else if (!EmailValidator.getInstance().isValid(user.getEmail())) addFieldError("user.email", getText("message.register.email.notvalid")); if (userManager.getUserByEmail(user.getEmail()) != null) addFieldError("user.email", getText("message.register.email.exist")); if (StringUtils.isBlank(user.getPassword())) addFieldError("user.password", getText("message.register.password.notempty")); if (!StringUtils.equals(user.getPassword(), confirmPassword)) addFieldError("confirmPassword", getText("message.register.password.notmatch")); if (recaptchaActive) { ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(request.getRemoteAddr(), captchaChallenge, captchaResponse);//ww w .j av a 2 s .c o m if (!reCaptchaResponse.isValid()) addFieldError("user.reCaptcha", getText("message.register.captcha.wronganswer")); } }