diff --git a/authentication/authentication-picketlink/src/main/java/org/keycloak/authentication/picketlink/PicketlinkAuthenticationProvider.java b/authentication/authentication-picketlink/src/main/java/org/keycloak/authentication/picketlink/PicketlinkAuthenticationProvider.java index 615e2c7acf..b2310ede9c 100755 --- a/authentication/authentication-picketlink/src/main/java/org/keycloak/authentication/picketlink/PicketlinkAuthenticationProvider.java +++ b/authentication/authentication-picketlink/src/main/java/org/keycloak/authentication/picketlink/PicketlinkAuthenticationProvider.java @@ -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);