List of usage examples for org.apache.commons.validator.routines EmailValidator getInstance
public static EmailValidator getInstance()
From source file:de.jost_net.JVereinJUnit.util.CheckerTest.java
@Test public void test08() throws RemoteException { assertTrue(!EmailValidator.getInstance().isValid("willi.wichtig@jvereinde")); }
From source file:com.github.achatain.nopasswordauthentication.app.AppService.java
String create(AppDto appDto) { Preconditions.checkArgument(isNotBlank(appDto.getOwnerEmail()), paramShouldNotBeBlank("ownerEmail")); Preconditions.checkArgument(isNotBlank(appDto.getName()), paramShouldNotBeBlank("name")); Preconditions.checkArgument(isNotBlank(appDto.getCallbackUrl()), paramShouldNotBeBlank("callbackUrl")); Preconditions.checkArgument(EmailValidator.getInstance().isValid(appDto.getOwnerEmail()), invalidEmail(appDto.getOwnerEmail())); // TODO check that this apiToken is not already present in the Datastore (don't forget to hash it before checking) String apiToken = tokenService.generate(); App app = App.builder().withOwnerEmail(appDto.getOwnerEmail()).withName(appDto.getName()) .withCallbackUrl(appDto.getCallbackUrl()).withEmailTemplate(appDto.getEmailTemplate()) .withApiToken(tokenService.hash(apiToken)).withCreatedTimestamp(new Date().getTime()).build(); appRepository.save(app);/*w w w .j a v a 2 s . co m*/ return apiToken; }
From source file:com.vrane.metaGlacier.gui.SNSTopicDialog.java
SNSTopicDialog() { super(Main.frame, true); JPanel mainPanel = new JPanel(new GridLayout(4, 2)); final JTextField topicNameJT = new JTextField(10); final JTextField emailJT = new JTextField(10); final JButton subscribeButton = new JButton("subscribe"); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5)); mainPanel.add(new JLabel("topic name")); mainPanel.add(topicNameJT);/*from w w w.j av a2 s . co m*/ mainPanel.add(new JLabel("email")); mainPanel.add(emailJT); final String metadata_account_email = Main.frame.getMPCUser(); if (metadata_account_email != null) { emailJT.setText(metadata_account_email); } mainPanel.add(new JLabel()); mainPanel.add(subscribeButton); subscribeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { final String email = emailJT.getText(); final String name = topicNameJT.getText(); boolean success = false; if (!EmailValidator.getInstance().isValid(email)) { JOptionPane.showMessageDialog(null, "Invalid email address"); return; } try { success = new SNSTopic().createTopic(name, email); } catch (Exception ex) { LGR.log(Level.SEVERE, null, ex); } if (success) { JOptionPane.showMessageDialog(null, "Please check your email to confirm"); dispose(); return; } JOptionPane.showMessageDialog(null, "Error subscribing"); } }); add(mainPanel); pack(); setLocationRelativeTo(Main.frame); setVisible(true); }
From source file:com.github.angelowolf.implementaciones.ValidacionEmailMaximo.java
@Override public boolean validate(String propiedadAEvaluar) { if (StringUtils.isBlank(propiedadAEvaluar)) { return true; } else {/*from w w w . j a va2s. c o m*/ if (propiedadAEvaluar.length() > this.maximoCaracteres) { return true; } else { EmailValidator validator = EmailValidator.getInstance(); if (!validator.isValid(propiedadAEvaluar)) { return true; } } } return false; }
From source file:de.fhg.fokus.odp.portal.managedatasets.validator.EmailOrURLValidator.java
@Override public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { if (((String) value).isEmpty()) { throwValidatorException();//from ww w .j av a 2 s . c om } else { String[] schemes = { "http", "https", "ftp", "ftps" }; UrlValidator urlValidator = new UrlValidator(schemes); // UrlValidator urlValidator = new UrlValidator(); if (urlValidator.isValid((String) value)) { return; } else if (EmailValidator.getInstance().isValid((String) value)) { return; } else { throwValidatorException(); } } }
From source file:de.jost_net.JVereinJUnit.util.CheckerTest.java
@Test public void test09() throws RemoteException { assertTrue(!EmailValidator.getInstance().isValid("willi.wichtig.@jverein.de")); }
From source file:com.email.SendEmailCalInvite.java
/** * Sends email based off of the section it comes from. This creates a * calendar invite object that is interactive by Outlook. * * @param eml EmailOutInviteModel//from www .j a va 2 s . c o m */ public static void sendCalendarInvite(EmailOutInvitesModel eml) { SystemEmailModel account = null; //Get Account for (SystemEmailModel acc : Global.getSystemEmailParams()) { if (acc.getSection().equals(eml.getSection())) { account = acc; break; } } if (account != null) { //Get parts String FromAddress = account.getEmailAddress(); String[] TOAddressess = ((eml.getToAddress() == null) ? "".split(";") : eml.getToAddress().split(";")); String[] CCAddressess = ((eml.getCcAddress() == null) ? "".split(";") : eml.getCcAddress().split(";")); String emailSubject = ""; BodyPart emailBody = body(eml); BodyPart inviteBody = null; if (eml.getHearingRoomAbv() == null) { emailSubject = eml.getEmailSubject() == null ? (eml.getEmailBody() == null ? eml.getCaseNumber() : eml.getEmailBody()) : eml.getEmailSubject(); inviteBody = responseDueCalObject(eml, account); } else { emailSubject = eml.getEmailSubject() == null ? Subject(eml) : eml.getEmailSubject(); inviteBody = inviteCalObject(eml, account, emailSubject); } //Set Email Parts Authenticator auth = EmailAuthenticator.setEmailAuthenticator(account); Properties properties = EmailProperties.setEmailOutProperties(account); Session session = Session.getInstance(properties, auth); MimeMessage smessage = new MimeMessage(session); Multipart multipart = new MimeMultipart("alternative"); try { smessage.addFrom(new InternetAddress[] { new InternetAddress(FromAddress) }); for (String To : TOAddressess) { if (EmailValidator.getInstance().isValid(To)) { smessage.addRecipient(Message.RecipientType.TO, new InternetAddress(To)); } } for (String Cc : CCAddressess) { if (EmailValidator.getInstance().isValid(Cc)) { smessage.addRecipient(Message.RecipientType.CC, new InternetAddress(Cc)); } } smessage.setSubject(emailSubject); multipart.addBodyPart(emailBody); multipart.addBodyPart(inviteBody); smessage.setContent(multipart); if (Global.isOkToSendEmail()) { Transport.send(smessage); } else { Audit.addAuditEntry("Cal Invite Not Actually Sent: " + eml.getId() + " - " + emailSubject); } EmailOutInvites.deleteEmailEntry(eml.getId()); } catch (AddressException ex) { ExceptionHandler.Handle(ex); } catch (MessagingException ex) { ExceptionHandler.Handle(ex); } } }
From source file:de.jost_net.JVereinJUnit.util.CheckerTest.java
@Test public void test10() throws RemoteException { assertTrue(EmailValidator.getInstance().isValid("jupp.schmitz@kln.de")); }
From source file:com.vrane.metaGlacier.gui.MetaDataSignUpDialog.java
MetaDataSignUpDialog() { super(Main.frame, true); JPanel signUpPanel = new JPanel(new GridLayout(4, 2)); final JTextField nameJT = new JTextField(10); final JTextField emailJT = new JTextField(10); final JTextField emailJT1 = new JTextField(10); final JButton signUpButton = new JButton("Sign up"); signUpPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5)); signUpPanel.add(new JLabel("name (optional)")); signUpPanel.add(nameJT);//from w w w. j a va 2s.c om signUpPanel.add(new JLabel("email")); signUpPanel.add(emailJT); signUpPanel.add(new JLabel("email again")); signUpPanel.add(emailJT1); signUpPanel.add(new JLabel()); signUpPanel.add(signUpButton); signUpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { final String email = emailJT.getText(); final String email1 = emailJT1.getText(); final String name = nameJT.getText(); boolean success = false; if (!email.equals(email1)) { JOptionPane.showMessageDialog(null, "Email addresses do not match"); return; } if (!EmailValidator.getInstance().isValid(email)) { JOptionPane.showMessageDialog(null, "Invalid email address"); return; } try { success = new SignUp().signup(email, name); } catch (SDKException ex) { LGR.log(Level.SEVERE, null, ex); } if (success) { JOptionPane.showMessageDialog(null, "Please check your email to confirm"); dispose(); return; } JOptionPane.showMessageDialog(null, "Error signing up"); } }); add(signUpPanel); pack(); setLocationRelativeTo(Main.frame); setVisible(true); }
From source file:com.infullmobile.jenkins.plugin.restrictedregister.security.hudson.form.ActivationCodeFormValidator.java
@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()); }/*from w w w . java 2 s .co m*/ 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)); } }