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:br.com.itw.qopsearch.api.security.ScaAuthenticationProvider.java

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    String login = authentication.getName().trim().toLowerCase();
    //        String password = authentication.getCredentials().toString();

    //        byte[] decodedBytes = Base64.decode(password.getBytes());
    //        String decodedPasswd = new String(decodedBytes, Charset.forName("UTF-8"));

    if (EmailValidator.getInstance().isValid(login)) {
        //        if (ValidarEmail.validate(login) && login.split("\\@")[0].equals(decodedPasswd)) {
        List<GrantedAuthority> grantedAuths = new ArrayList<>();
        grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER"));
        Authentication auth = new UsernamePasswordAuthenticationToken(login, null, grantedAuths);
        return auth;
    } else {/*www  .j  ava2 s.c om*/
        return null;
    }
}

From source file:de.jost_net.JVereinJUnit.util.CheckerTest.java

@Test
public void test05() throws RemoteException {
    assertTrue(!EmailValidator.getInstance().isValid("willi wichtig@jverein.de"));
}

From source file:de.fhg.fokus.odp.portal.managedatasets.validator.ODPEmailValidator.java

@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {

    if (!EmailValidator.getInstance().isValid((String) value)) {
        LiferayFacesContext lfc = LiferayFacesContext.getInstance();
        PortletRequest request = (PortletRequest) lfc.getExternalContext().getRequest();

        FacesMessage msg = new FacesMessage(LanguageUtil.get(request.getLocale(), "od.email.invalid.error"),
                LanguageUtil.get(request.getLocale(), "od.email.invalid.error"));
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(msg);
    }/* w w  w . j  ava 2 s.c  o  m*/

}

From source file:de.jost_net.JVerein.gui.control.listener.EMailListener.java

@Override
public void handleEvent(Event event) {
    if (event == null) {
        return;/*from  w ww.j a va 2 s .c o  m*/
    }
    if (event.type != SWT.FocusOut) {
        return;
    }
    String em = (String) email.getValue();
    if (em == null || em.length() == 0) {
        return;
    }
    if (!EmailValidator.getInstance().isValid(em)) {
        GUI.getStatusBar().setErrorText("Mailadresse ist ungltig");
    }
}

From source file:com.raven.loginn.service.AccountService.java

public Account findAccountByEmail(String email) throws Exception {
    if (GenericValidator.isBlankOrNull(email)) {
        throw new WarningMessageException("E-mail bo olamaz");
    }// w  w  w  .  j av  a2  s  . c  o  m
    if (!EmailValidator.getInstance().isValid(email)) {
        throw new WarningMessageException("E-mail hatal");
    }
    return accountDao.findAccountByEmail(email);
}

From source file:de.jost_net.JVereinJUnit.util.CheckerTest.java

@Test
public void test06() throws RemoteException {
    assertTrue(!EmailValidator.getInstance().isValid("willi@wichtig@jverein.de"));
}

From source file:io.github.benas.randombeans.randomizers.EmailRandomizerTest.java

@Test
public void generatedEmailsShouldBeValid() {
    String randomValue = randomizer.getRandomValue();

    boolean isValidEmail = EmailValidator.getInstance().isValid(randomValue);
    assertThat(isValidEmail).isTrue();//  w  w  w  .j a  v a2  s  .c  o  m
}

From source file:edu.gmu.isa681.server.core.Validator.java

License:asdf

/**
 * Checks whether the given email address is valid, by 1) checking if the given address is empty and 2) using 
 * Apache Commons EmailValidator to check the validity of the address.
 * @param email/*from www  .j  a  va 2  s . co m*/
 * @return List of validation errors, if any. If the give email address is valid, returns an empty list.
 */
public static List<String> validateEmail(final String email) {
    List<String> errors = new ArrayList<String>();

    if (isEmpty(email)) {
        errors.add("Email required");
    }

    if (!EmailValidator.getInstance().isValid(email)) {
        errors.add("Invalid email address");
    }

    return errors;
}

From source file:de.jost_net.JVereinJUnit.util.CheckerTest.java

@Test
public void test07() throws RemoteException {
    assertTrue(!EmailValidator.getInstance().isValid("willi.wichtig.jverein.de"));
}

From source file:com.quinsoft.zeidon.domains.EmailAddressDomain.java

@Override
public void validateInternalValue(Task task, AttributeDef attributeDef, Object internalValue)
        throws InvalidAttributeValueException {
    String string = checkNullString(internalValue);

    String[] temp;//from w  w  w  . j av a2  s .  c  o m
    String delims = "[;,]+";

    // Eliminate any blank spaces in email.
    string = string.replaceAll("\\s+", "");

    // It is valid for the email address to be more than one address separated by "," or ";" so account for that.
    temp = string.split(delims);
    for (int i = 0; i < temp.length; i++) {
        if (!EmailValidator.getInstance().isValid(temp[i]))
            throw new InvalidAttributeValueException(attributeDef, string,
                    "Value must be a valid email address");
    }

    super.validateInternalValue(task, attributeDef, internalValue);
}