Package org.encuestame.persistence.domain.security

Examples of org.encuestame.persistence.domain.security.SocialAccount


     */
    public String connectSignInAccount(final SocialSignInOperations social) throws EnMeExpcetion {
        // first, we check if this social account already exist as previous connection.
        log.info("Sign In with Social Account");
        //if user account is previously connected
        SocialAccount socialAccount = social.isConnected(social.getSocialUserProfile().getId());
        if (socialAccount != null) {
            log.info("Connecting: Exist previously connection");
            //if exist, we update credentials on account connect store.
            social.reConnect(social.getSocialUserProfile().getId(), social.getAccessGrant(), socialAccount);
            //getAccountDao().saveOrUpdate(connection.getSocialAccount());
            getAccountDao().saveOrUpdate(socialAccount);
            SecurityUtils.socialAuthentication(socialAccount); //TODO: only with OWNER UserAccount.
            return PathUtil.DASHBOARD_REDIRECT;
        } else {
            //if user has been never connected, we check if the user exist with the social account email.
            log.info("Connecting: Creating new connection");
            //get email from social profile.
            final String email = this.convertSocialConnectedAccountToBean(social.getSocialUserProfile()).getEmail();
            log.info("sign in social account email -->"+email);
            String redirectPath =  "signin/provider/register";
            Assert.notNull(email);
            //user account by email
            final UserAccount accountEmail = getAccountDao().getUserByEmail(email);
            //if the user account is new, we create new account.
            if (accountEmail == null) {
                log.debug("This email ["+email+"] never has been used.");
                //create fist connection and social account.
                final SocialAccount accountConnection = this.signUpSocial(
                        social.getSocialUserProfile(), social.getAccessGrant(),
                        social.getProvider(), null);
                SecurityUtils.socialAuthentication(accountConnection);
            } else {
                //if user exist, we create new account connection
                final SocialAccount accountConnection = addNewSocialAccount(
                        social.getAccessGrant().getAccessToken(),
                        social.getAccessGrant().getRefreshToken(),
                        social.getAccessGrant().getExpires(),
                        social.getSocialUserProfile(),
                        social.getProvider(),
View Full Code Here


            accountEmail = getSecurityOperations().singupUser(this.convertSocialConnectedAccountToBean(profile), false);
        } else {
            //use the current account.
            accountEmail = account;
        }
        final SocialAccount accountConnection = addNewSocialAccount(
                accessGrant.getAccessToken(),
                accessGrant.getRefreshToken(),
                accessGrant.getExpires(),
                profile,
                provider,
View Full Code Here

    tp2.getHashTags().add(this.tag);
    getTweetPoll().saveOrUpdate(tp2);

    assertNotNull(tp2);

    final SocialAccount socialAccount = createDefaultSettedSocialAccount(this.userAcc);
    assertNotNull(socialAccount);
    final String tweetContent = "Tweet content text";

    final TweetPollSavedPublishedStatus tpSaved2 = createTweetPollSavedPublishedStatus(
        tp2, " ", socialAccount, tweetContent);
View Full Code Here

                        apiKey, consumerSecret, accessToken.getValue(),
                        accessToken.getSecret());
                IdentiCaProfile profile = apiOperations.getUserProfile();
                log.debug("identica profile "+profile.toString());
                SocialUserProfile profileAPI = apiOperations.getProfile();
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider,
                        String.valueOf(profile.getId()));
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profileAPI,
                            socialProvider, getUserAccount());
                } else {
                    log.warn("This account already exist");
                    throw new EnMeExistPreviousConnectionException(getMessage("social.repeated.account"));
                }
            } else if (socialProvider.equals(SocialProvider.LINKEDIN)) {
                LinkedInAPIOperations apiOperations = new LinkedInAPITemplate(
                        apiKey, consumerSecret, accessToken.getValue(),
                        accessToken.getSecret());
                LinkedInProfile profile = apiOperations.getUserProfile();
                SocialUserProfile profileAPI = apiOperations.getProfile();
                log.debug("linkedin profile "+profile.toString());
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, profile.getId());
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profileAPI,
                            socialProvider, getUserAccount());
                } else {
                    log.warn("This account already exist");
                    throw new EnMeExistPreviousConnectionException(getMessage("social.repeated.account"));
                }
            } else if (socialProvider.equals(SocialProvider.TWITTER)) {
                TwitterAPIOperations operations = new TwitterAPITemplate(consumerSecret, apiKey, accessToken.getValue(),
                        accessToken.getSecret());
                SocialUserProfile profile = operations.getProfile();
                log.debug("twitter profile "+profile.toString());
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, profile.getId());
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profile,
                            socialProvider, getUserAccount());
                } else {
                    log.warn("This account already exist");
                    throw new EnMeExistPreviousConnectionException(getMessage("social.repeated.account"));
                }
                //FUTURE - Issues with OAuth1 request.
            } else if (socialProvider.equals(SocialProvider.YAHOO)) {
                //FUTURE - Only valid on defined domain.
                log.debug("Yahoo provider is disabled");
               
            } else if (socialProvider.equals(SocialProvider.PLURK)) {
              PlurkAPIOperations  apiOperations = new PlurkAPITemplate(
                        apiKey, consumerSecret, accessToken.getValue(),
                        accessToken.getSecret());
                SocialUserProfile profile = apiOperations.getProfile();
                log.debug("plurk profile " + profile.toString());
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, profile.getId());
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profile,
                            socialProvider, getUserAccount());
                } else {
                    log.warn("This account already exist");
                    throw new EnMeExistPreviousConnectionException(getMessage("social.repeated.account"));
                }
            } else if (socialProvider.equals(SocialProvider.TUMBLR)) {
              TumblrAPIOperations apiOperations = new TumblrAPITemplate(
                        apiKey, consumerSecret, accessToken.getValue(),
                        accessToken.getSecret());
                SocialUserProfile profile = apiOperations.getProfile();
                log.debug("linkedin profile "+profile.toString());
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, profile.getId());
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profile,
                            socialProvider, getUserAccount());
                } else {
View Full Code Here

    public String checkOAuth2SocialAccount(final SocialProvider socialProvider,
            final AccessGrant accessGrant) throws Exception {
        String actionToDo = "";
        if (socialProvider.equals(SocialProvider.FACEBOOK)) {
            final FacebookAPIOperations facebookAPIOperations = new FacebookAPITemplate(accessGrant.getAccessToken());
            final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, facebookAPIOperations.getProfile().getId(), facebookAPIOperations.getProfile().getUsername());
            if (socialAccount == null) {
                  getSecurityService().addNewSocialAccount(
                          accessGrant.getAccessToken(), accessGrant.getRefreshToken(), accessGrant.getExpires(),
                          facebookAPIOperations.getProfile(),
                          socialProvider, getUserAccount());
View Full Code Here

     */
    public void changeStateSocialAccount(
            final Long accountId,
            final String action) throws EnMeNoResultsFoundException, IllegalSocialActionException{
        final UserAccount userAccount = getUserAccount(getUserPrincipalUsername());
        final SocialAccount social = getAccountDao().getSocialAccount(accountId, userAccount.getAccount());
        if (log.isDebugEnabled()) {
          log.debug("changeStateSocialAccount account");
          log.debug("changeStateSocialAccount account accountId "+accountId);
          log.debug("changeStateSocialAccount account action "+action);
        }
        if (social == null) {
            throw new EnMeNoResultsFoundException("social accout not found");
        }
        if ("default".equals(action)) {
           social.setDefaultSelected(!social.getDefaultSelected());
           getAccountDao().saveOrUpdate(social);
        } else if("remove".equals(action)) {
            getAccountDao().delete(social);
        } else {
            throw new IllegalSocialActionException();
View Full Code Here

    @Before
    public void initService() {
        final UserAccount user = createUserAccount("jota", createAccount());
        final Question question = createQuestion("question1", user.getAccount());
        this.tweetPoll = createTweetPollPublicated(true, true, new Date(), user, question);
        final SocialAccount socialAccount = createSocialAccount(
                getProperty("twitter.test.token"),
                getProperty("twitter.test.tokenSecret"),
                user,
                getProperty("twitter.test.account"), Boolean.FALSE, SocialProvider.TWITTER);
        createTweetPollSavedPublishedStatus(tweetPoll, "12345", socialAccount, "hi @encuestame !!");
View Full Code Here

        getSurveyDaoImp().saveOrUpdate(mySurvey);

        // 3- Create TweetPollSavedPublishedStatus -- Create Social network link.

        //Total Usage by Social Networks
        final SocialAccount socialAccount = createDefaultSettedSocialAccount(getSpringSecurityLoggedUserAccount());
        assertNotNull(socialAccount);
        final String tweetContent = "Tweet content text";
        final TweetPollSavedPublishedStatus tpSaved = createTweetPollSavedPublishedStatus(
                myTweetPoll, " ", socialAccount, tweetContent);
View Full Code Here

     * @return
     * @throws EnMeExpcetion
     */
    public SocialAccount isConnected(final String profileId) throws EnMeExpcetion {
        Assert.notNull(profileId);
        SocialAccount social = null;
        try {
            log.debug("Is connected exist? "+profileId);
            //check if this user is previously connected
            social = this.findAccountByConnection(profileId);
        } catch (EnMeExpcetion e) {
View Full Code Here

     * @throws EnMeNoResultsFoundException
     */
    private SocialAccount getSocialAccountsbyId(
            final Long socialAccountId, final String username)
            throws EnMeNoResultsFoundException {
        final SocialAccount socialAccount = getAccountDao().getSocialAccount(
                socialAccountId, getAccount(username));
        if (socialAccount == null) {
            throw new EnMeNoResultsFoundException("Social Account id not valid");
        }
        return socialAccount;
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.security.SocialAccount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.