Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public int authenticate(Context context,
log.info(LogHelper.getHeader(context,
"type=ldap-login", "type=ldap_but_already_email"));
context.turnOffAuthorisationSystem();
setEpersonAttributes(context, eperson, ldap, Optional.of(netid));
setEpersonAttributes(context, eperson, ldap, Optional.of(netid), email);
ePersonService.update(context, eperson);
context.dispatchEvents();
context.restoreAuthSystemState();
Expand All @@ -339,7 +339,7 @@ public int authenticate(Context context,
try {
context.turnOffAuthorisationSystem();
eperson = ePersonService.create(context);
setEpersonAttributes(context, eperson, ldap, Optional.of(netid));
setEpersonAttributes(context, eperson, ldap, Optional.of(netid), email);
eperson.setCanLogIn(true);
authenticationService.initEPerson(context, request, eperson);
ePersonService.update(context, eperson);
Expand Down Expand Up @@ -382,9 +382,21 @@ public int authenticate(Context context,
*/
private void setEpersonAttributes(Context context, EPerson eperson, SpeakerToLDAP ldap, Optional<String> netid)
throws SQLException {
setEpersonAttributes(context, eperson, ldap, netid, null);
}

/**
* Update eperson's attributes, falling back to the supplied login e-mail when LDAP has none.
*/
private void setEpersonAttributes(Context context, EPerson eperson, SpeakerToLDAP ldap,
Optional<String> netid, String email) throws SQLException {

// Set the e-mail: prefer the LDAP-provided address, otherwise the one the user logged in with,
// so an EPerson is never persisted with a null e-mail.
Comment thread
jr-rk marked this conversation as resolved.
Outdated
if (StringUtils.isNotEmpty(ldap.ldapEmail)) {
eperson.setEmail(ldap.ldapEmail);
} else if (StringUtils.isNotEmpty(email)) {
eperson.setEmail(email);
}
if (StringUtils.isNotEmpty(ldap.ldapGivenName)) {
eperson.setFirstName(context, ldap.ldapGivenName);
Expand Down Expand Up @@ -734,7 +746,7 @@ public String getName() {
*/
private void assignGroups(String dn, ArrayList<String> group, Context context) {
if (StringUtils.isNotBlank(dn)) {
System.out.println("dn:" + dn);
log.info(LogHelper.getHeader(context, "assignGroups", "dn=" + dn));
Comment thread
jr-rk marked this conversation as resolved.
Outdated
int groupmapIndex = 1;
String groupMap = configurationService.getProperty("authentication-ldap.login.groupmap." + groupmapIndex);
boolean cmp;
Expand All @@ -744,6 +756,15 @@ private void assignGroups(String dn, ArrayList<String> group, Context context) {
// outer loop with the DSpace groups
while (groupMap != null) {
String t[] = groupMap.split(":");
if (t.length < 2) {
log.error(LogHelper.getHeader(context, "assignGroups",
"malformed groupmap entry at index " + groupmapIndex + ": " + groupMap +
" - missing ':' separator"));
groupMap = configurationService.getProperty(
"authentication-ldap.login.groupmap." + ++groupmapIndex);
continue;
}
Comment thread
jr-rk marked this conversation as resolved.
Outdated

String ldapSearchString = t[0];
String dspaceGroupName = t[1];

Expand Down
Loading