Improvement for AD integration to avoid exception when mulitple users without email are synced to Keycloak DB
This commit is contained in:
parent
56ea29e899
commit
c8321fc96e
1 changed files with 8 additions and 2 deletions
|
@ -51,9 +51,15 @@ public class PicketlinkAuthenticationProvider implements AuthenticationProvider
|
||||||
|
|
||||||
try {
|
try {
|
||||||
User picketlinkUser = BasicModel.getUser(identityManager, username);
|
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())
|
.setName(picketlinkUser.getFirstName(), picketlinkUser.getLastName())
|
||||||
.setEmail(picketlinkUser.getEmail())
|
.setEmail(email)
|
||||||
.setProviderName(getName());
|
.setProviderName(getName());
|
||||||
} catch (IdentityManagementException ie) {
|
} catch (IdentityManagementException ie) {
|
||||||
throw convertIDMException(ie);
|
throw convertIDMException(ie);
|
||||||
|
|
Loading…
Reference in a new issue