* @param account
* @param password
* @param socialSignIn
*/
public static void socialAuthentication(final SocialAccount accountConnection) {
final UserAccount account = accountConnection.getUserOwner();
log.trace("Register SOCIAL LOGIN USER: " + account.getUsername());
// building granted authorities
final Collection<GrantedAuthority> authorities = ConvertDomainsToSecurityContext
.convertEnMePermission(account.getSecUserPermissions());
// create user detail based on user account.
final EnMeSocialUserAccount details = SecurityUtils.convertUserAccountToUserDetails(accountConnection);
// set the social credentials permission.
details.setSocialCredentials(true);
final SocialAuthenticationToken token = new SocialAuthenticationToken(details, authorities);
token.setProfileId(accountConnection.getSocialProfileId());
token.setProvider(accountConnection.getAccounType());
//clear the context.
SecurityContextHolder.clearContext();
//set new authentication.
SecurityContextHolder.getContext().setAuthentication(token);
if (log.isInfoEnabled()) {
log.info("Username " + account.getUsername() + " is logged at "
+ new Date());
log.debug("created EnMeSocialUserAccount" +details);
}
}