indexabout

This is a web interface for Eclipse Git repositories. Many projects also use the Gerrit Code Review. For more information about Git, please see the Git Wiki page.

The contents of the Git repositories are made available under the terms and conditions of the Eclipse.org Software User Agreement.

er'>committer
diff options
context:
space:
mode:
authorSidharth Singh2013-02-22 03:59:50 -0500
committerSven Rottstock2013-03-11 06:37:36 -0400
commit182d2c84b2c7f1ab5adcd3e954d909ebe84e5de9 (patch)
tree1e0a380bf8bd37303863e29b15233b71bf5dc2f4
parent72dd28f4905c1ae35905ef6129a1bf9470308863 (diff)
downloadorg.eclipse.stardust.ui.web-182d2c84b2c7f1ab5adcd3e954d909ebe84e5de9.zip
org.eclipse.stardust.ui.web-182d2c84b2c7f1ab5adcd3e954d909ebe84e5de9.tar.gz
org.eclipse.stardust.ui.web-182d2c84b2c7f1ab5adcd3e954d909ebe84e5de9.tar.xz
Jira-ID: CRNT-28062
Merged the changes for email validation to 7.1.1 from 7.0.1 SP27 git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@63181 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/core/EMailAddressValidator.java33
-rw-r--r--views-common/src/main/resources/views-common-messages_de.properties2
2 files changed, 19 insertions, 16 deletions
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/core/EMailAddressValidator.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/core/EMailAddressValidator.java
index eafad68..0371279 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/core/EMailAddressValidator.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/core/EMailAddressValidator.java
@@ -12,16 +12,18 @@ package org.eclipse.stardust.ui.web.viewscommon.core;
import java.util.ArrayList;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
import org.eclipse.stardust.common.StringUtils;
+import org.eclipse.stardust.ui.web.common.log.LogManager;
+import org.eclipse.stardust.ui.web.common.log.Logger;
import org.eclipse.stardust.ui.web.viewscommon.messages.MessagesViewsCommonBean;
@@ -32,6 +34,8 @@ import org.eclipse.stardust.ui.web.viewscommon.messages.MessagesViewsCommonBean;
*/
public class EMailAddressValidator implements Validator
{
+ private static final Logger trace = LogManager.getLogger(EMailAddressValidator.class);
+
public EMailAddressValidator()
{
viewsCommonMessage= MessagesViewsCommonBean.getInstance();
@@ -70,21 +74,20 @@ public class EMailAddressValidator implements Validator
*/
public static boolean validateEmailAddress(String emailAddress)
{
- // Convert to Lower Case so that (or because) in RegEx only lower case can be used
- // (or is used)
- emailAddress = emailAddress.trim().toLowerCase();
-
- // Set the email pattern string
boolean matchFound = false;
- Pattern p = Pattern
- .compile("^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\\.([a-z][a-z|0-9]*(\\.[a-z][a-z|0-9]*)?)$");
-
- // Match the given string with the pattern
- if (StringUtils.isNotEmpty(emailAddress))
+ try
+ {
+ if (StringUtils.isNotEmpty(emailAddress))
+ {
+ // Validate the email address with InternetAddress,confirming RFC822
+ // standard.
+ new InternetAddress(emailAddress).validate();
+ matchFound = true;
+ }
+ }
+ catch (AddressException e)
{
- Matcher m = p.matcher(emailAddress);
- // check whether match is found
- matchFound = m.matches();
+ trace.warn("Email address validation failed :" + e.getLocalizedMessage());
}
return matchFound;
}
diff --git a/views-common/src/main/resources/views-common-messages_de.properties b/views-common/src/main/resources/views-common-messages_de.properties
index 796c337..0d1b106 100644
--- a/views-common/src/main/resources/views-common-messages_de.properties
+++ b/views-common/src/main/resources/views-common-messages_de.properties
@@ -471,7 +471,7 @@ common.tooltip.rightRotation = Rechts Drehen
common.tooltip.leftRotation = Links Drehen
common.tooltip.showOutline = Outline Anzeigen
common.whitespace.error = Leerzeichen nicht erlaubt
-common.invalidFormat.error = in ung\u00FCltigem Format
+common.invalidFormat.error = \u0020 in ung\u00FCltigem Format
common.invalidValue.error = Ung\u00FCltiger Wert
common.process.priority.options.1 = Hoch