final NewExternalUserEntity newUser = new NewExternalUserEntity(); newUser.setEmail(email); newUser.setSource(socialProvider.getId());
final NewExternalUserEntity newUser = new NewExternalUserEntity(); newUser.setEmail(email); newUser.setSource(socialProvider.getId());
@Override public void onApplicationEvent(AuthenticationSuccessEvent event) { final UserDetails details = (UserDetails) event.getAuthentication().getPrincipal(); try { UserEntity registeredUser = userService.findBySource(details.getSource(), details.getSourceId(), false); updateRegisteredUser(registeredUser, details); // Principal username is the technical identifier of the user // Dirty hack because spring security is requiring a username... details.setUsername(registeredUser.getId()); } catch (UserNotFoundException unfe) { final NewExternalUserEntity newUser = new NewExternalUserEntity(); newUser.setSource(details.getSource()); newUser.setSourceId(details.getSourceId()); newUser.setFirstname(details.getFirstname()); newUser.setLastname(details.getLastname()); newUser.setEmail(details.getEmail()); boolean addDefaultRole = false; if (event.getAuthentication().getAuthorities() == null || event.getAuthentication().getAuthorities().isEmpty()) { addDefaultRole = true; } UserEntity createdUser = userService.create(newUser, addDefaultRole); // Principal username is the technical identifier of the user details.setUsername(createdUser.getId()); if (!addDefaultRole) { addRole(RoleScope.MANAGEMENT, createdUser.getId(), event.getAuthentication().getAuthorities()); addRole(RoleScope.PORTAL, createdUser.getId(), event.getAuthentication().getAuthorities()); } } userService.connect(details.getUsername()); }
@Override public void onApplicationEvent(AuthenticationSuccessEvent event) { final UserDetails details = (UserDetails) event.getAuthentication().getPrincipal(); try { UserEntity registeredUser = userService.findBySource(details.getSource(), details.getSourceId(), false); updateRegisteredUser(registeredUser, details); // Principal username is the technical identifier of the user // Dirty hack because spring security is requiring a username... details.setUsername(registeredUser.getId()); } catch (UserNotFoundException unfe) { final NewExternalUserEntity newUser = new NewExternalUserEntity(); newUser.setSource(details.getSource()); newUser.setSourceId(details.getSourceId()); newUser.setFirstname(details.getFirstname()); newUser.setLastname(details.getLastname()); newUser.setEmail(details.getEmail()); boolean addDefaultRole = false; if (event.getAuthentication().getAuthorities() == null || event.getAuthentication().getAuthorities().isEmpty()) { addDefaultRole = true; } UserEntity createdUser = userService.create(newUser, addDefaultRole); // Principal username is the technical identifier of the user details.setUsername(createdUser.getId()); if (!addDefaultRole) { addRole(RoleScope.MANAGEMENT, createdUser.getId(), event.getAuthentication().getAuthorities()); addRole(RoleScope.PORTAL, createdUser.getId(), event.getAuthentication().getAuthorities()); } } userService.connect(details.getUsername()); }
newExternalUserEntity.setSource(IDP_SOURCE_GRAVITEE); newExternalUserEntity.setSourceId(newExternalUserEntity.getEmail());
newExternalUserEntity.setSource(IDP_SOURCE_GRAVITEE); newExternalUserEntity.setSourceId(newExternalUserEntity.getEmail());
newUser.setFirstname(identityUser.getFirstname()); newUser.setLastname(identityUser.getLastname()); newUser.setSource(identityUser.getSource()); newUser.setEmail(identityUser.getEmail()); newUser.setSourceId(identityUser.getSourceId());
newUser.setFirstname(identityUser.getFirstname()); newUser.setLastname(identityUser.getLastname()); newUser.setSource(identityUser.getSource()); newUser.setEmail(identityUser.getEmail()); newUser.setSourceId(identityUser.getSourceId());