Examples of OAuth1Token


Examples of org.encuestame.utils.oauth.OAuth1Token

     */
    public OAuth1Token getAccessToken(
            final String verifier,
            final WebRequest request) throws EnMeOAuthSecurityException{
        log.debug("Verifier "+verifier);
        final OAuth1Token accessToken = getoAuth1RestTemplate()
        .exchangeForAccessToken(new AuthorizedRequestToken(
                extractCachedRequestToken(request), verifier));
        return accessToken;
    }
View Full Code Here

Examples of org.encuestame.utils.oauth.OAuth1Token

     * @param request
     * @return
     */
    private OAuth1Token extractCachedRequestToken(
            WebRequest request) {
        OAuth1Token requestToken = (OAuth1Token) request
                .getAttribute(OAuthUtils.OAUTH_TOKEN_ATTRIBUTE, WebRequest.SCOPE_SESSION);
        request.removeAttribute(OAuthUtils.OAUTH_TOKEN_ATTRIBUTE, WebRequest.SCOPE_SESSION);
        log.debug("requestToken "+requestToken.toString());
        return requestToken;
    }
View Full Code Here

Examples of org.encuestame.utils.oauth.OAuth1Token

     * @throws EnMeNoResultsFoundException
     */
    @Test
    public void testisConnected() throws EnMeNoResultsFoundException{
        final UserAccount account = createUserAccount("jota", this.account);
        final OAuth1Token token = new OAuth1Token("token", "secret");
        //final AccountConnection ac = createConnection("TWITTER", token, "12345", account.getUid() , "ur");
        //final AccountConnection exAc = getAccountDao().getAccountConnection(ac.getUserAccout().getUid(), "TWITTER");
        //assertNotNull(exAc);
        //assertEquals("Should be equals", ac.getAccountConnectionId(), exAc.getAccountConnectionId());
//        final boolean conected = getAccountDao().isConnected(account.getUid(), "TWITTER");
View Full Code Here

Examples of org.encuestame.utils.oauth.OAuth1Token

     * @throws EnMeNoResultsFoundException
     */
    public OAuth1Token getAccessToken(String accountId, SocialProvider provider) throws EnMeNoResultsFoundException {
        final SocialAccount ac = this.getAccountConnection(accountId, provider);
        if (ac != null) {
            final OAuth1Token oAuthToken = new OAuth1Token(ac.getAccessToken(),
                    ac.getSecretToken());
            return oAuthToken;
        } else {
            throw new EnMeNoResultsFoundException("connection not found");
        }
View Full Code Here

Examples of org.glassfish.jersey.server.oauth1.OAuth1Token

        String consKey = params.getConsumerKey();
        if (consKey == null) {
            throw new OAuth1Exception(Response.Status.BAD_REQUEST, null);
        }

        OAuth1Token rt = provider.getRequestToken(params.getToken());
        if (rt == null) {
            // token invalid
            throw new OAuth1Exception(Response.Status.BAD_REQUEST, null);
        }

        OAuth1Consumer consumer = rt.getConsumer();
        if (consumer == null || !consKey.equals(consumer.getKey())) {
            // token invalid
            throw new OAuth1Exception(Response.Status.BAD_REQUEST, null);

        }

        OAuth1Secrets secrets = new OAuth1Secrets().consumerSecret(consumer.getSecret()).tokenSecret(rt.getSecret());
        try {
            sigIsOk = oAuth1Signature.verify(request, params, secrets);
        } catch (OAuth1SignatureException ex) {
            Logger.getLogger(AccessTokenResource.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (!sigIsOk) {
            // signature invalid
            throw new OAuth1Exception(Response.Status.BAD_REQUEST, null);
        }

        // We're good to go.
        OAuth1Token at = provider.newAccessToken(rt, params.getVerifier());

        if (at == null) {
            throw new OAuth1Exception(Response.Status.BAD_REQUEST, null);
        }

        // Preparing the response.
        Form resp = new Form();
        resp.param(OAuth1Parameters.TOKEN, at.getToken());
        resp.param(OAuth1Parameters.TOKEN_SECRET, at.getSecret());
        resp.asMap().putAll(at.getAttributes());
        return Response.ok(resp).build();
    }
View Full Code Here

Examples of org.glassfish.jersey.server.oauth1.OAuth1Token

        MultivaluedMap<String, String> parameters = new MultivaluedHashMap<String, String>();
        for (String n : request.getParameterNames()) {
            parameters.put(n, request.getParameterValues(n));
        }

        OAuth1Token rt = provider.newRequestToken(consKey, params.getCallback(), parameters);

        Form resp = new Form();
        resp.param(OAuth1Parameters.TOKEN, rt.getToken());
        resp.param(OAuth1Parameters.TOKEN_SECRET, rt.getSecret());
        resp.param(OAuth1Parameters.CALLBACK_CONFIRMED, "true");
        return Response.ok(resp).build();
    }
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.