Improvement for AD integration to avoid exception when mulitple users without email are synced to Keycloak DB

This commit is contained in:
mposolda 2014-06-19 11:51:20 +02:00
parent 56ea29e899
commit c8321fc96e

View file

@ -51,9 +51,15 @@ public class PicketlinkAuthenticationProvider implements AuthenticationProvider
try {
User picketlinkUser = BasicModel.getUser(identityManager, username);
return picketlinkUser == null ? null : new AuthUser(picketlinkUser.getId(), picketlinkUser.getLoginName(), getName())
if (picketlinkUser == null) {
return null;
}
String email = (picketlinkUser.getEmail() != null && picketlinkUser.getEmail().trim().length() > 0) ? picketlinkUser.getEmail() : null;
return new AuthUser(picketlinkUser.getId(), picketlinkUser.getLoginName(), getName())
.setName(picketlinkUser.getFirstName(), picketlinkUser.getLastName())
.setEmail(picketlinkUser.getEmail())
.setEmail(email)
.setProviderName(getName());
} catch (IdentityManagementException ie) {
throw convertIDMException(ie);