Examples of TwitterLoginInformation


Examples of in.partake.session.TwitterLoginInformation

    public TwitterLoginInformation createLoginInformation(String redirectURL) throws TwitterException {
        Twitter twitter = new TwitterFactory(conf).getInstance();
        String callbackURL = PartakeConfiguration.toppath() + "/auth/verifyForTwitter";
        RequestToken requestToken = twitter.getOAuthRequestToken(callbackURL);

        return new TwitterLoginInformation(twitter, requestToken, redirectURL);
    }
View Full Code Here

Examples of in.partake.session.TwitterLoginInformation

        if (StringUtils.isBlank(verifier))
            return renderInvalid(UserErrorCode.INVALID_OAUTH_VERIFIER);

        String sessionId = session().get(Constants.Session.ID_KEY);
        assert sessionId != null;
        TwitterLoginInformation loginInformation =
                (TwitterLoginInformation) Cache.get(Constants.Cache.TWITTER_LOGIN_KEY_PREFIX + sessionId);
        if (loginInformation == null)
            return renderInvalid(UserErrorCode.UNEXPECTED_REQUEST);
        Cache.set(Constants.Cache.TWITTER_LOGIN_KEY_PREFIX + sessionId, null);

        MessageCode messageCode = null;
        try {
            ITwitterService twitterService = PartakeApp.getTwitterService();
            UserTwitterLink linkage = twitterService.createTwitterLinkageFromLoginInformation(loginInformation, verifier);

            UserEx user = new VerifyForTwitterActionTransaction(linkage).execute();
            session().put(Constants.Session.USER_ID_KEY, user.getId());

            messageCode = MessageCode.MESSAGE_AUTH_LOGIN;
        } catch (TwitterException e) {
            return renderError(ServerErrorCode.TWITTER_OAUTH_ERROR, e);
        }

        String redirectURL = loginInformation.getRedirectURL();
        if (StringUtils.isEmpty(redirectURL))
            return renderRedirect("/", messageCode);

        // If the redirect page is the error page, we do not want to show it. Showing the top page is better.
        // TODO(mayah): We should not put these values here.
View Full Code Here

Examples of in.partake.session.TwitterLoginInformation

    public Result doExecute() throws DAOException {
        try {
            ITwitterService twitterService = PartakeApp.getTwitterService();
            String redirectURL = getParameter("redirectURL");
            TwitterLoginInformation info = twitterService.createLoginInformation(redirectURL);

            String sessionId = session().get(Constants.Session.ID_KEY);
            assert sessionId != null;
            Cache.set(Constants.Cache.TWITTER_LOGIN_KEY_PREFIX + sessionId, info, LOGIN_TIMEOUT_SEC);

            return renderRedirect(info.getAuthenticationURL());
        } catch (TwitterException e) {
            return renderError(ServerErrorCode.TWITTER_OAUTH_ERROR, e);
        }

    }
View Full Code Here

Examples of in.partake.session.TwitterLoginInformation

    @Override
    protected ITwitterService createTwitterService() throws Exception {
        ITwitterService twitterService = mock(ITwitterService.class);

        TwitterLoginInformation mockInfo = mock(TwitterLoginInformation.class);
        Mockito.doReturn(mockInfo).when(twitterService).createLoginInformation(Mockito.anyString());
        Mockito.doReturn(mockInfo).when(twitterService).createLoginInformation(null);
        Mockito.doThrow(new TwitterException("MockException")).when(twitterService).createLoginInformation("http://www.example.com/throwException");

        UserTwitterLink twitterLinkage = new UserTwitterLink(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.