Skip to content

Commit

Permalink
Revert "Added email validation and input/output encodings are loaded …
Browse files Browse the repository at this point in the history
…from the cfg."

This reverts commit 9d40f00.
  • Loading branch information
milanmajchrak committed Apr 25, 2024
1 parent 9d40f00 commit 320652d
Showing 1 changed file with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ protected EPerson findEPerson(Context context, HttpServletRequest request) throw

// 2) Second, look for an email header.
if (eperson == null && emailHeader != null) {
String email = getEmailAcceptedOrNull(findSingleAttribute(request, emailHeader));
String email = findSingleAttribute(request, emailHeader);
if (StringUtils.isEmpty(email) && Objects.nonNull(clarinVerificationToken)) {
email = clarinVerificationToken.getEmail();
}
Expand Down Expand Up @@ -694,7 +694,7 @@ protected EPerson registerNewEPerson(Context context, HttpServletRequest request

// Header values
String netid = Util.formatNetId(findSingleAttribute(request, netidHeader), org);
String email = getEmailAcceptedOrNull(findSingleAttribute(request, emailHeader));
String email = findSingleAttribute(request, emailHeader);
String fname = Headers.updateValueByCharset(findSingleAttribute(request, fnameHeader));
String lname = Headers.updateValueByCharset(findSingleAttribute(request, lnameHeader));

Expand Down Expand Up @@ -816,7 +816,7 @@ protected void updateEPerson(Context context, HttpServletRequest request, EPerso
String lnameHeader = configurationService.getProperty("authentication-shibboleth.lastname-header");

String netid = Util.formatNetId(findSingleAttribute(request, netidHeader), shibheaders.get_idp());
String email = getEmailAcceptedOrNull(findSingleAttribute(request, emailHeader));
String email = findSingleAttribute(request, emailHeader);
String fname = Headers.updateValueByCharset(findSingleAttribute(request, fnameHeader));
String lname = Headers.updateValueByCharset(findSingleAttribute(request, lnameHeader));

Expand Down Expand Up @@ -1171,12 +1171,7 @@ protected String findAttribute(HttpServletRequest request, String name) {

if (!StringUtils.isEmpty(value) && reconvertAttributes) {
try {
String inputEncoding = configurationService.getProperty("shibboleth.name.conversion.inputEncoding",
"ISO-8859-1");
String outputEncoding = configurationService.getProperty("shibboleth.name.conversion.outputEncoding",
"UTF-8");

value = new String(value.getBytes(inputEncoding), outputEncoding);
value = new String(value.getBytes("ISO-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException ex) {
log.warn("Failed to reconvert shibboleth attribute ("
+ name + ").", ex);
Expand Down Expand Up @@ -1329,12 +1324,5 @@ public boolean canChangePassword(Context context, EPerson ePerson, String curren
public boolean areSpecialGroupsApplicable(Context context, HttpServletRequest request) {
return true;
}

public String getEmailAcceptedOrNull(String email) {
if (email == null || email.isEmpty() || email.matches(".*\\s+.*")){ // no whitespaces in mail
return null;
}
return email;
}
}

0 comments on commit 320652d

Please sign in to comment.