protected void updateProfile() { try { profile = profileService.updateAttributes(profile.getId().toString(), profile.getAttributes()); } catch (ProfileException e) { throw new SocialMediaIntegrationException("Unable to update profile of user '" + profile.getId() + "'", e); } }
protected void updateProfile() { try { profile = profileService.updateAttributes(profile.getId().toString(), profile.getAttributes()); } catch (ProfileException e) { throw new SocialMediaIntegrationException("Unable to update profile of user '" + profile.getId() + "'", e); } }
@Override public Authentication complete(String tenant, String providerId, HttpServletRequest request, Set<String> newUserRoles, Map<String, Object> newUserAttributes, ConnectSupport connectSupport) throws AuthenticationException { if (connectSupport == null) { connectSupport = this.connectSupport; } Connection<?> connection = completeConnection(connectSupport, providerId, request); if (connection != null) { Profile userData = ConnectionUtils.createProfile(connection); Profile profile = getProfile(tenant, userData); if (profile == null) { if (CollectionUtils.isNotEmpty(newUserRoles)) { userData.getRoles().addAll(newUserRoles); } if (MapUtils.isNotEmpty(newUserAttributes)) { userData.getAttributes().putAll(newUserAttributes); } profile = createProfile(tenant, connection, userData); } else { profile = updateProfileConnectionData(tenant, connection, profile); } Authentication auth = authenticationManager.authenticateUser(profile); SecurityUtils.setAuthentication(request, auth); return auth; } else { return null; } }
protected Profile updateProfileConnectionData(String tenant, Connection<?> connection, Profile profile) { try { ConnectionUtils.addConnectionData(profile, connection.createData(), textEncryptor); return profileService.updateAttributes(profile.getId().toString(), profile.getAttributes()); } catch (CryptoException | ProfileException e) { throw new AuthenticationException("Unable to update connection data of user '" + profile.getUsername() + "' of tenant '" + tenant + "'", e); } }
protected Profile createProfile(String tenant, Connection<?> connection, Profile userData) { try { ConnectionUtils.addConnectionData(userData, connection.createData(), textEncryptor); return profileService.createProfile(tenant, userData.getUsername(), null, userData.getEmail(), true, userData.getRoles(), userData.getAttributes(), null); } catch (CryptoException | ProfileException e) { throw new AuthenticationException("Unable to create profile of user '" + userData.getUsername() + "' in tenant '" + tenant + "'", e); } }