當前位置: 首頁>>代碼示例>>Java>>正文


Java EmailValidator類代碼示例

本文整理匯總了Java中org.apache.commons.validator.routines.EmailValidator的典型用法代碼示例。如果您正苦於以下問題:Java EmailValidator類的具體用法?Java EmailValidator怎麽用?Java EmailValidator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EmailValidator類屬於org.apache.commons.validator.routines包,在下文中一共展示了EmailValidator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateAddress

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
/**
 * Return true if address has valid format
 * @param address String
 * @return boolean
 */
private boolean validateAddress(String address)
{
    boolean result = false;
    
    // Validate the email, allowing for local email addresses
    EmailValidator emailValidator = EmailValidator.getInstance(true);
    if (!validateAddresses || emailValidator.isValid(address))
    {
        result = true;
    }
    else 
    {
        logger.error("Failed to send email to '" + address + "' as the address is incorrectly formatted" );
    }
  
    return result;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:23,代碼來源:MailActionExecuter.java

示例2: verifyFormData

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
@Override
public void verifyFormData(HudsonSecurityRealmRegistration securityRealmRegistration, JSONObject object)
        throws RegistrationException, InvalidSecurityRealmException {
    final String activationCode = BaseFormField.ACTIVATION_CODE.fromJSON(object);
    if (StringUtils.isEmpty(activationCode)) {
        throw new RegistrationException(Messages.RRError_Hudson_ActiviationCodeInvalid());
    }
    final User user = RRHudsonUserProperty.getUserForActivationCode(activationCode);
    final RRHudsonUserProperty hudsonUserProperty = RRHudsonUserProperty.getPropertyForUser(user);
    if (hudsonUserProperty == null) {
        throw new RegistrationException(Messages.RRError_Hudson_ActiviationCodeInvalid());
    }
    if (hudsonUserProperty.getActivated()) {
        throw new RegistrationException(Messages.RRError_Hudson_UserIsActivated());
    }
    final Mailer.UserProperty mailerProperty = user.getProperty(Mailer.UserProperty.class);
    if (mailerProperty == null) {
        throw new RegistrationException(Messages.RRError_Hudson_UserNoEmailAddress());
    }
    final String emailAddress = Utils.fixEmptyString(mailerProperty.getAddress());
    if (!EmailValidator.getInstance().isValid(emailAddress)) {
        throw new RegistrationException(Messages.RRError_Hudson_UserInvalidEmail(emailAddress));
    }
}
 
開發者ID:inFullMobile,項目名稱:restricted-register-plugin,代碼行數:25,代碼來源:ActivationCodeFormValidator.java

示例3: createMessage

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
private MimeMessage createMessage() throws MailException, UnsupportedEncodingException,
        MessagingException {
    final String content = getContent();
    final String replyToAddress = replyTo;

    final MimeMessageBuilder messageBuilder = new MimeMessageBuilder();
    messageBuilder.setSubject(this.subject);
    messageBuilder.setCharset(META_CHARSET);
    messageBuilder.addRecipients(this.recipients);
    if (EmailValidator.getInstance().isValid(replyToAddress)) {
        Utils.logInfo("Reply to address " + replyToAddress);
        messageBuilder.setReplyTo(replyToAddress);
    }
    final MimeMessage message = messageBuilder.buildMimeMessage();
    message.setContent(content, META_CONTENT_TYPE);
    return message;
}
 
開發者ID:inFullMobile,項目名稱:restricted-register-plugin,代碼行數:18,代碼來源:Mail.java

示例4: getErrors

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
@Override
public List<Error> getErrors() {
    List<Error> errors = newArrayList();
    if (isBlank(payload.getUsername())) {
        errors.add(new Error("400", "username"));
    }

    if (isBlank(payload.getEmail())) {
        errors.add(new Error("400", "email"));
    } else if (!EmailValidator.getInstance().isValid(payload.getEmail())) {
        errors.add(new Error("400", "email-bad-syntax"));
    }

    if (isBlank(payload.getPassword())) {
        errors.add(new Error("400", "password"));
    } else {
        if (payload.getPassword().length() < PASSWORD_MIN_LENGTH) {
            errors.add(new Error("400", "password-bad"));
        }
    }
    return errors;
}
 
開發者ID:mbarberot,項目名稱:alterrae-backend,代碼行數:23,代碼來源:UserCreationValidator.java

示例5: validate

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
/**
 * Validate the bean's contents
 * @return {@code true} if the contents are valid; {@code false} otherwise.
 */
private boolean validate() {
	boolean ok = true;
	
	// Email
	if (!EmailValidator.getInstance().isValid(emailAddress)) {
		ok = false;
		setMessage(getComponentID("emailAddress"), "Email is not valid");
	}
	
	// Passwords must match
	if (!password1.equals(password2)) {
		ok = false;
		setMessage(getComponentID("password1"), "Passwords must match");
		setMessage(getComponentID("password2"), "Passwords must match");
	}
	
	return ok;
}
 
開發者ID:BjerknesClimateDataCentre,項目名稱:QuinCe,代碼行數:23,代碼來源:SignupBean.java

示例6: isValidEmail

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
/**
* Is this a valid email the service will recognize
*
* @param email
* @return
*/
private boolean isValidEmail(String email) {

	if (email == null || email.equals("")) {
		return false;
	}

	email = email.trim();
	//must contain @
	if (!email.contains("@")) {
		return false;
	}

	//an email can't contain spaces
	if (email.indexOf(" ") > 0) {
		return false;
	}

	//use commons-validator
	EmailValidator validator = EmailValidator.getInstance();
	return validator.isValid(email);
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:28,代碼來源:UrkundReviewServiceImpl.java

示例7: isValidEmail

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
/**
 * Is this a valid email the service will recognize
 * 
 * @param email
 * @return
 */
private boolean isValidEmail(String email) {

	// TODO: Use a generic Sakai utility class (when a suitable one exists)

	if (email == null || email.equals(""))
		return false;

	email = email.trim();
	// must contain @
	if (email.indexOf("@") == -1)
		return false;

	// an email can't contain spaces
	if (email.indexOf(" ") > 0)
		return false;

	// use commons-validator
	EmailValidator validator = EmailValidator.getInstance();
	if (validator.isValid(email))
		return true;

	return false;
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:30,代碼來源:TurnitinReviewServiceImpl.java

示例8: emailResponsesDo

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
@RequestMapping(value = FULL_PATH + "/view/email/send", method = RequestMethod.GET)
public Request emailResponsesDo(@RequestParam(value = phoneNumber) String inputNumber,
                                @RequestParam String todoUid,
                                @RequestParam(value = userInputParam) String emailAddress) throws URISyntaxException {
    User user = userManager.findByInputNumber(inputNumber, null);
    log.info("User={}",user);
    boolean isEmailValid = EmailValidator.getInstance().isValid(emailAddress);
    if (isEmailValid || user.hasEmailAddress() && emailAddress.length() == 1) {
        final String emailToPass = emailAddress.length() == 1 ? user.getEmailAddress() : emailAddress;
        dataExportBroker.emailTodoResponses(user.getUid(), todoUid, emailToPass);
        USSDMenu menu = new USSDMenu(messageAssembler.getMessage("todo.email.prompt.done", user));
        return menuBuilder(addBackHomeExit(menu, todoUid, user));
    } else {
        String prompt = messageAssembler.getMessage("todo.email.prompt.error", new String[] { emailAddress }, user);
        return menuBuilder(new USSDMenu(prompt, REL_PATH + "/view/email/send?todoUid=" + todoUid));
    }
}
 
開發者ID:grassrootza,項目名稱:grassroot-platform,代碼行數:18,代碼來源:USSDTodoController.java

示例9: User

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
public User(String phoneNumber, String displayName, String emailAddress) {
    if (StringUtils.isEmpty(phoneNumber) && StringUtils.isEmpty(emailAddress)) {
        throw new IllegalArgumentException("Phone number and email address cannot both be null!");
    }
    if (!StringUtils.isEmpty(emailAddress) && !EmailValidator.getInstance().isValid(emailAddress)) {
        throw new IllegalArgumentException("Email address, if provided, must be valid");
    }
    this.uid = UIDGenerator.generateId();
    this.phoneNumber = phoneNumber;
    this.emailAddress = emailAddress;
    this.username = StringUtils.isEmpty(phoneNumber) ? emailAddress : phoneNumber;
    this.displayName = removeUnwantedCharacters(displayName);
    this.languageCode = "en";
    this.messagingPreference = !StringUtils.isEmpty(phoneNumber) ? DeliveryRoute.SMS : DeliveryRoute.EMAIL_GRASSROOT; // as default
    this.createdDateTime = Instant.now();
    this.alertPreference = AlertPreference.NOTIFY_NEW_AND_REMINDERS;
    this.hasUsedFreeTrial = false;
}
 
開發者ID:grassrootza,項目名稱:grassroot-platform,代碼行數:19,代碼來源:User.java

示例10: validateFormInputs

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
@Override
public void validateFormInputs() {
    setErrorMessageAndStepComplete(null);
    if (WatchDogUtils
            .isEmptyOrHasOnlyWhitespaces(getProgrammingExperience())) {
        setErrorMessageAndStepComplete("Please fill in your years of programming experience");
    }

    if (!WatchDogUtils.isEmpty(emailInput.getText())) {
        if (!EmailValidator.getInstance(false)
                .isValid(emailInput.getText())) {
            setErrorMessageAndStepComplete("Your mail address is not valid!");
        }
    }

    if (WatchDogUtils.isEmpty(emailInput.getText())
            && mayContactButton.isSelected()) {
        setErrorMessageAndStepComplete("You can only participate in the lottery if you enter your email address.");
    }

    updateStep();
}
 
開發者ID:TestRoots,項目名稱:watchdog,代碼行數:23,代碼來源:UserRegistrationStep.java

示例11: validateFormInputs

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
@Override
public void validateFormInputs() {
	setErrorMessageAndPageComplete(null);
	if (WatchDogUtils
			.isEmptyOrHasOnlyWhitespaces(getProgrammingExperience())) {
		setErrorMessageAndPageComplete(
				"Please fill in your years of programming experience");
	}

	if (!WatchDogUtils.isEmpty(emailInput.getText())) {
		if (!EmailValidator.getInstance(false)
				.isValid(emailInput.getText())) {
			setErrorMessageAndPageComplete(
					"Your mail address is not valid!");
		}
	}

	if (WatchDogUtils.isEmpty(emailInput.getText())
			&& mayContactButton.getSelection()) {
		setErrorMessageAndPageComplete(
				"You can only participate in the lottery if you enter your email address.");
	}

	getWizard().getContainer().updateButtons();
}
 
開發者ID:TestRoots,項目名稱:watchdog,代碼行數:26,代碼來源:UserRegistrationPage.java

示例12: validate

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
public static void validate(String type, String address, int period,
                            List<Integer> validPeriods) {

    if (type.equals("EMAIL")) {
            if (!EmailValidator.getInstance(true).isValid(address))
                throw Exceptions.unprocessableEntity("Address %s is not of correct format", address);
        }
    if (type.equals("WEBHOOK")) {
        if (!URL_VALIDATOR.isValid(address))
             throw Exceptions.unprocessableEntity("Address %s is not of correct format", address);
        if (period != 0 && !validPeriods.contains(period)){
             throw Exceptions.unprocessableEntity("%d is not a valid period", period);
        }
    }
    if (period != 0 && !type.equals("WEBHOOK")){
           throw Exceptions.unprocessableEntity("Period can not be non zero for %s", type);
    }

}
 
開發者ID:openstack,項目名稱:monasca-api,代碼行數:20,代碼來源:NotificationMethodValidation.java

示例13: validate

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
@Override
public void validate(FacesContext context, UIComponent component,
		Object value) throws ValidatorException {

	if (((String) value).isEmpty()) {
		throwValidatorException();
	}
	else {
		if (UrlValidator.getInstance().isValid((String) value)) {
			return;
		}
		else if (EmailValidator.getInstance().isValid((String) value)) {
			return;
		} else

		{
			throwValidatorException();
		}

	}
}
 
開發者ID:fraunhoferfokus,項目名稱:odp-manage-datasets-portlet,代碼行數:22,代碼來源:EmailOrURLValidator.java

示例14: findEmail

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
@Override
public String findEmail(final String username) {
    final String email = this.jdbcTemplate.queryForObject(passwordManagementProperties.getJdbc().getSqlFindEmail(),
            String.class, username);
    if (StringUtils.isNotBlank(email) && EmailValidator.getInstance().isValid(email)) {
        return email;
    }
    return null;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:10,代碼來源:JdbcPasswordManagementService.java

示例15: findEmail

import org.apache.commons.validator.routines.EmailValidator; //導入依賴的package包/類
@Override
public String findEmail(final String username) {
    try {
        final PasswordManagementProperties.Ldap ldap = passwordManagementProperties.getLdap();
        final SearchFilter filter = Beans.newLdaptiveSearchFilter(ldap.getUserFilter(),
                Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
                Arrays.asList(username));
        LOGGER.debug("Constructed LDAP filter [{}] to locate account email", filter);

        final ConnectionFactory factory = Beans.newLdaptivePooledConnectionFactory(ldap);
        final Response<SearchResult> response = LdapUtils.executeSearchOperation(factory, ldap.getBaseDn(), filter);
        LOGGER.debug("LDAP response to locate account email is [{}]", response);

        if (LdapUtils.containsResultEntry(response)) {
            final LdapEntry entry = response.getResult().getEntry();
            LOGGER.debug("Found LDAP entry [{}] to use for the account email", entry);

            final String attributeName = passwordManagementProperties.getReset().getEmailAttribute();
            final LdapAttribute attr = entry.getAttribute(attributeName);
            if (attr != null) {
                final String email = attr.getStringValue();
                LOGGER.debug("Found email address [{}] for user [{}]. Validating...", email, username);
                if (EmailValidator.getInstance().isValid(email)) {
                    LOGGER.debug("Email address [{}] matches a valid email address", email);
                    return email;
                }
                LOGGER.error("Email [{}] is not a valid address", email);
            } else {
                LOGGER.error("Could not locate an LDAP attribute [{}] for [{}] and base DN [{}]",
                        attributeName, filter.format(), ldap.getBaseDn());
            }
            return null;
        }
        LOGGER.error("Could not locate an LDAP entry for [{}] and base DN [{}]", filter.format(), ldap.getBaseDn());
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    return null;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:40,代碼來源:LdapPasswordManagementService.java


注:本文中的org.apache.commons.validator.routines.EmailValidator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。