Example usage for org.apache.commons.validator.routines EmailValidator getInstance

List of usage examples for org.apache.commons.validator.routines EmailValidator getInstance

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines EmailValidator getInstance.

Prototype

public static EmailValidator getInstance() 

Source Link

Document

Returns the Singleton instance of this validator.

Usage

From source file:dz.alkhwarizmix.framework.java.services.impl.UserServiceValidator.java

/**
 * {@inheritDoc}/* w  w w.j  av  a 2  s .  co m*/
 */
@Override
public boolean isValidUserId(User user) {
    return (user != null) ? EmailValidator.getInstance().isValid(user.getUserId()) : false;
}

From source file:com.pamarin.income.controller.RegisterAccountCtrl.java

private boolean isEmail() {
    return EmailValidator.getInstance().isValid(getEmail());
}

From source file:com.eby.admin.edit.admin.EditAdminController.java

/**
 * Initializes the controller class.//from  ww  w  .  j av a  2  s.  c om
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    initModel();
    addcbLvl();
    //diajalankan apabila hanya diperlukan
    Platform.runLater(() -> {
        txtEmail.setOnKeyReleased((KeyEvent event) -> {
            validator = EmailValidator.getInstance();
            if (validator.isValid(txtEmail.getText())) {
                //mengubah icon menjadi valid-label jika email valid
                labelEmail.getStyleClass().remove("invalid-label");
                labelEmail.getStyleClass().add("valid-label");
            } else {
                //menguah icon menjadi invalid-label jiak email invalid
                labelEmail.getStyleClass().remove("valid-label");
                labelEmail.getStyleClass().add("invalid-label");
            }
        });
    });
    //nonaktifkan txtNotif
    txtNotif.setVisible(false);
}

From source file:com.github.achatain.nopasswordauthentication.auth.AuthService.java

void request(AuthRequest authRequest) {
    Preconditions.checkArgument(StringUtils.isNotBlank(authRequest.getApiToken()),
            paramShouldNotBeBlank("apiToken"));
    Preconditions.checkArgument(EmailValidator.getInstance().isValid(authRequest.getUserId()),
            invalidEmail(authRequest.getUserId()));

    // 1. Hash the received api token and find the matching app
    App foundApp = appService.findByApiToken(tokenService.hash(authRequest.getApiToken()));
    Preconditions.checkState(foundApp != null, "Unrecognized client application");

    // 2. Create an Auth entity with userEmail | authToken | appId | timestamp
    String authToken = tokenService.generate();

    Auth auth = Auth.create().withAppId(foundApp.getId()).withUserId(authRequest.getUserId())
            .withTimestamp(new Date().getTime()).withToken(tokenService.hash(authToken)).build();
    authRepository.save(auth);//  w  w w.ja  va 2  s . c  om

    // 3. Build the callbackUrl with query params
    String callbackUrl = String.format(CALLBACK_TEMPLATE, foundApp.getCallbackUrl(), auth.getUserId(),
            authToken);

    // 4. Send an email to userEmail containing the callbackUrl
    emailService.sendEmail(foundApp.getId(), foundApp.getOwnerEmail(), foundApp.getName(),
            authRequest.getUserId(), "No password authentication", callbackUrl);
}

From source file:com.infullmobile.jenkins.plugin.restrictedregister.mail.Mail.java

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);
    }/*from   w  w  w.j av  a  2 s  .  c o  m*/
    final MimeMessage message = messageBuilder.buildMimeMessage();
    message.setContent(content, META_CONTENT_TYPE);
    return message;
}

From source file:com.qcadoo.mail.internal.MailServiceImpl.java

public static boolean isValidEmail(final String email) {
    return StringUtils.isNotBlank(email) && EmailValidator.getInstance().isValid(email);
}

From source file:ke.co.tawi.babblesms.server.servlet.admin.account.AddAccount.java

/**
 *
 * @param config// w w  w. j  a v a 2s. c  om
 * @throws ServletException
 */
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    emailValidator = EmailValidator.getInstance();

    accountDAO = AccountDAO.getInstance();

    cacheManager = CacheManager.getInstance();
}

From source file:lydichris.smashbracket.services.UserService.java

private void validateEmail(String email) {
    EmailValidator emailValidator = EmailValidator.getInstance();
    if (!emailValidator.isValid(email)) {
        throw new UserCreationException(UserCreationExceptionEnum.BAD_EMAIL);
    } else {/*from  w w  w . java  2s. c o m*/
        if (userPersistence.checkEmailExists(email)) {
            throw new UserCreationException(UserCreationExceptionEnum.EMAIL_EXISTS);
        }
    }
}

From source file:com.formkiq.core.service.formInterceptor.SetupInterceptor.java

@Override
public Map<String, String> validateFormJSON(final FormJSON form) {

    FormJSONField email = findValueByKey(form, "adminemail").get();
    FormJSONField pwd = findValueByKey(form, "password").get();
    FormJSONField cpwd = findValueByKey(form, "confirmpassword").get();

    Map<String, String> errors = new HashMap<>();

    String pass = pwd.getValue();
    if (pass != null && !pass.equals(cpwd.getValue())) {
        errors.put("" + cpwd.getId(), "Passwords do not match");
    }// ww  w.j  a  va 2  s .c o  m

    if (!EmailValidator.getInstance().isValid(email.getValue())) {
        errors.put("" + email.getId(), "Invalid Email");
    }

    return errors;
}

From source file:business.Klant.java

public void setEmail(String email) {
    EmailValidator emailValidator = EmailValidator.getInstance();
    Scanner input = new Scanner(System.in);

    while (emailValidator.isValid(email) == false) {
        System.out.println("Incorrecte email. Voer uw emailadres opnieuw in");
        email = input.next();//from   w  w  w . j  a v  a  2 s. c  o  m
    }

    this.email = email;
}