Skip to content

Commit

Permalink
Merge branch 'dataverse-affiliation-refactoring' into dataverse-v4.17…
Browse files Browse the repository at this point in the history
…-SP-bug-fixes
  • Loading branch information
manikon committed Nov 11, 2019
2 parents 13aa386 + b401dde commit 47969ce
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,19 @@ public void validateUserEmail(FacesContext context, UIComponent toValidate, Obje
return;
}

String domain = null;
long count = userEmail.chars().filter(ch -> ch == '.').count();
String topLevelDomain = null;
String domain = userEmail.substring(userEmail.indexOf("@")+1).trim();
long count = domain.chars().filter(ch -> ch == '.').count();
if (count > 1) {
int secondLastIndex = StringUtils.lastIndexOf(userEmail, '.', userEmail.lastIndexOf(".") - 1);
domain = userEmail.substring(secondLastIndex + 1);
int secondLastIndex = StringUtils.lastIndexOf(domain, '.', domain.lastIndexOf(".") - 1);
topLevelDomain = domain.substring(secondLastIndex + 1);
} else {
domain = userEmail.substring(userEmail.indexOf("@") + 1).trim();
topLevelDomain = domain;
}
AffiliationGroup group = affiliationGroupServiceBean.getByEmailDomain(domain);
if (group == null) {
AffiliationGroup group = affiliationGroupServiceBean.getByEmailDomain(topLevelDomain);
String emaildomain = group.getEmaildomain();
List<String> domainValues = Arrays.asList(emaildomain.split("\\s*,\\s*"));
if (group == null || !domainValues.contains(topLevelDomain)) {
((UIInput) toValidate).setValid(true);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_WARN, BundleUtil.getStringFromBundle("user.email.domain.invalid"), null);
context.addMessage(toValidate.getClientId(context), message);
Expand Down

0 comments on commit 47969ce

Please sign in to comment.