예제 #1
0
 /**
  * Create new social account.
  *
  * @param socialAccountId
  * @param token
  * @param tokenSecret
  * @param expiresToken
  * @param username
  * @param socialUserProfile
  * @param socialProvider
  * @param userAccount
  * @return
  */
 public SocialAccount createSocialAccount(
     final String socialAccountId,
     final String token,
     final String tokenSecret,
     final String expiresToken,
     final String username,
     final SocialUserProfile socialUserProfile,
     final SocialProvider socialProvider,
     final UserAccount userAccount) {
   final SocialAccount socialAccount = new SocialAccount();
   socialAccount.setAccessToken(token);
   socialAccount.setSecretToken(tokenSecret);
   socialAccount.setAccount(userAccount.getAccount());
   socialAccount.setUserOwner(userAccount);
   socialAccount.setExpires(expiresToken);
   socialAccount.setAccounType(socialProvider);
   socialAccount.setAddedAccount(new Date());
   socialAccount.setVerfied(Boolean.TRUE);
   socialAccount.setSocialAccountName(socialUserProfile.getUsername());
   socialAccount.setType(SocialProvider.getTypeAuth(socialProvider));
   socialAccount.setUpgradedCredentials(new Date());
   socialAccount.setSocialProfileId(socialUserProfile.getId());
   socialAccount.setPublicProfileUrl(socialUserProfile.getProfileUrl());
   socialAccount.setPrictureUrl(socialUserProfile.getProfileImageUrl()); // TODO: repeated
   socialAccount.setProfilePictureUrl(socialUserProfile.getProfileImageUrl());
   socialAccount.setEmail(socialUserProfile.getEmail());
   socialAccount.setProfileThumbnailPictureUrl(socialUserProfile.getProfileImageUrl());
   socialAccount.setRealName(socialUserProfile.getRealName());
   this.saveOrUpdate(socialAccount);
   return socialAccount;
 }
예제 #2
0
 /**
  * Create new social connection
  *
  * @param provider {@link SocialProvider}
  * @param accessGrant {@link AccessGrant}
  * @param socialAccountId social account id.
  * @param userAccount {@link UserAccount}
  * @param providerProfileUrl provider profile url.
  * @return
  */
 public SocialAccount updateSocialAccountConnection(
     final AccessGrant accessGrant, // OAuth2
     final String socialAccountId,
     final SocialAccount currentSocialAccount) {
   log.debug("Add Connection " + accessGrant);
   log.debug("Add Connection " + socialAccountId);
   // reference to social account.
   // connection.setSocialAccount(socialAccount);
   // store oauth provider permissions.
   if (SocialProvider.getTypeAuth(currentSocialAccount.getAccounType()).equals(TypeAuth.OAUTH1)) {
     // OAuth access token.
     // connection.setAccessToken(token.getValue());
     // OAuth1
     // connection.setSecretToken(token.getSecret());
     // TODO: pending OAUTH1.
     log.debug("pending OAUTH1 - OAuth 1 social connection is not available right now.");
   } else if (SocialProvider.getTypeAuth(currentSocialAccount.getAccounType())
       .equals(TypeAuth.OAUTH2)) {
     // OAuth2
     currentSocialAccount.setAccessToken(accessGrant.getAccessToken());
     currentSocialAccount.setRefreshToken(accessGrant.getRefreshToken());
     currentSocialAccount.setExpires(accessGrant.getExpires());
   }
   Assert.assertNotNull(socialAccountId);
   currentSocialAccount.setSocialProfileId(socialAccountId);
   this.saveOrUpdate(currentSocialAccount); // TODO: this seems not save or update properly.
   log.debug("Added Connection:{" + currentSocialAccount.toString());
   return currentSocialAccount;
 }