Examples of OAuthParameters

@author Kristoffer Gronowski

Examples of com.google.gdata.client.authn.oauth.OAuthParameters

     * @param accessTokenSecret OAuth access token secret.
     * @return list of names of a user's public and private calendars.
     */
    public List<String> getCalendarNames(String accessToken, String accessTokenSecret) throws Exception {
        CalendarService calendarService = new CalendarService("apache-camel-2.3");
        OAuthParameters params = getOAuthParams(accessToken, accessTokenSecret);
        calendarService.setOAuthCredentials(params, new OAuthHmacSha1Signer());
        URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/");
        CalendarFeed resultFeed = calendarService.getFeed(feedUrl, CalendarFeed.class);

        ArrayList<String> result = new ArrayList<String>();
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.OAuthParameters

        }
        return result;
    }
   
    private OAuthParameters getOAuthParams(String accessToken, String accessTokenSecret) {
        OAuthParameters params = new OAuthParameters();
        params.setOAuthConsumerKey(credentials.getProperty("consumer.key"));
        params.setOAuthConsumerSecret(credentials.getProperty("consumer.secret"));
        params.setOAuthToken(accessToken);
        params.setOAuthTokenSecret(accessTokenSecret);
        return params;
    }
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.OAuthParameters

     * @param accessTokenSecret OAuth access token secret.
     * @return list of names of a user's public and private calendars.
     */
    public List<String> getCalendarNames(String accessToken, String accessTokenSecret) throws Exception {
        CalendarService calendarService = new CalendarService("apache-camel-2.3");
        OAuthParameters params = getOAuthParams(accessToken, accessTokenSecret);
        calendarService.setOAuthCredentials(params, new OAuthHmacSha1Signer());
        URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/");
        CalendarFeed resultFeed = calendarService.getFeed(feedUrl, CalendarFeed.class);

        List<String> result = new ArrayList<String>();
View Full Code Here

Examples of com.google.gdata.client.authn.oauth.OAuthParameters

        }
        return result;
    }
   
    private OAuthParameters getOAuthParams(String accessToken, String accessTokenSecret) {
        OAuthParameters params = new OAuthParameters();
        params.setOAuthConsumerKey(credentials.getProperty("consumer.key"));
        params.setOAuthConsumerSecret(credentials.getProperty("consumer.secret"));
        params.setOAuthToken(accessToken);
        params.setOAuthTokenSecret(accessTokenSecret);
        return params;
    }
View Full Code Here

Examples of com.sun.jersey.oauth.signature.OAuthParameters

        };

        // create a new OAuth client filter passing the needed info as well as the AuthHandler
        OAuthClientFilter filter = new OAuthClientFilter(
                client.getProviders(),
                new OAuthParameters().consumerKey(PROPERTIES.getProperty(PROPERTY_CONSUMER_KEY))
                    .token(PROPERTIES.getProperty(PROPERTY_TOKEN)),
                new OAuthSecrets().consumerSecret(PROPERTIES.getProperty(PROPERTY_CONSUMER_SECRET))
                    .tokenSecret(PROPERTIES.getProperty(PROPERTY_TOKEN_SECRET)),
                "http://twitter.com/oauth/request_token",
                "http://twitter.com/oauth/access_token",
View Full Code Here

Examples of com.sun.jersey.oauth.signature.OAuthParameters

      }
    }
    else if (oAuthConsumerKey != null && oAuthConsumerSecret != null && oAuthSignatureMethod != null) {
      if (this.client == null) {
        Client c = new Client();
        OAuthParameters params = new OAuthParameters()
          .signatureMethod(oAuthSignatureMethod)
          .consumerKey(oAuthConsumerKey)
          .version("1.1");

        OAuthSecrets secrets = new OAuthSecrets()
View Full Code Here

Examples of com.sun.jersey.oauth.signature.OAuthParameters

    @Produces(MediaType.APPLICATION_FORM_URLENCODED)
    public Response postAccessTokenRequest(@Context HttpContext hc, @Context Request req) {
        try {
            boolean sigIsOk = false;
            OAuthServerRequest request = new OAuthServerRequest(hc.getRequest());
            OAuthParameters params = new OAuthParameters();
            params.readRequest(request);

            if (params.getToken() == null) {
                throw new WebApplicationException(new Throwable("oauth_token MUST be present."), 400);
            }

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

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

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

            }

            OAuthSecrets secrets = new OAuthSecrets().consumerSecret(consumer.getSecret()).tokenSecret(rt.getSecret());
            try {
                sigIsOk = OAuthSignature.verify(request, params, secrets);
            } catch (OAuthSignatureException ex) {
                Logger.getLogger(AccessTokenRequest.class.getName()).log(Level.SEVERE, null, ex);
            }

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

            // We're good to go.
            OAuthToken at = provider.newAccessToken(rt, params.getVerifier());
           
            if(at == null) {
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }
View Full Code Here

Examples of com.sun.jersey.oauth.signature.OAuthParameters

    @Consumes("application/x-www-form-urlencoded")
    @Produces("application/x-www-form-urlencoded")
    public Response postReqTokenRequest() {
        try {
            OAuthServerRequest request = new OAuthServerRequest(hc.getRequest());
            OAuthParameters params = new OAuthParameters();
            params.readRequest(request);

            String tok = params.getToken();
            if ((tok != null) && (!tok.contentEquals(""))) {
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

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

            OAuthConsumer consumer = provider.getConsumer(consKey);
            if (consumer == null) {
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }
            OAuthSecrets secrets = new OAuthSecrets().consumerSecret(consumer.getSecret()).tokenSecret("");

            boolean sigIsOk = false;
            try {
                sigIsOk = OAuthSignature.verify(request, params, secrets);
            } catch (OAuthSignatureException ex) {
                Logger.getLogger(RequestTokenRequest.class.getName()).log(Level.SEVERE, null, ex);
            }

            if (!sigIsOk) {
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

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

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

            Form resp = new Form();
            resp.putSingle(OAuthParameters.TOKEN, rt.getToken());
            resp.putSingle(OAuthParameters.TOKEN_SECRET, rt.getSecret());
            resp.putSingle(OAuthParameters.CALLBACK_CONFIRMED, "true");
View Full Code Here

Examples of com.sun.jersey.oauth.signature.OAuthParameters

        return request;
    }

    private OAuthSecurityContext getSecurityContext(ContainerRequest request) throws OAuthException {
        OAuthServerRequest osr = new OAuthServerRequest(request);
        OAuthParameters params = new OAuthParameters().readRequest(osr);

        // apparently not signed with any OAuth parameters; unauthorized
        if (params.size() == 0) {
            throw newUnauthorizedException();
        }

        // get required OAuth parameters
        String consumerKey = requiredOAuthParam(params.getConsumerKey());
        String token = params.getToken();
        String timestamp = requiredOAuthParam(params.getTimestamp());
        String nonce = requiredOAuthParam(params.getNonce());

        // enforce other supported and required OAuth parameters
        requiredOAuthParam(params.getSignature());
        supportedOAuthParam(params.getVersion(), versions);

        // retrieve secret for consumer key
        OAuthConsumer consumer = provider.getConsumer(consumerKey);
        if (consumer == null) {
            throw newUnauthorizedException();
View Full Code Here

Examples of com.sun.jersey.oauth.signature.OAuthParameters

   */
  private void setAccess(String accessToken, String accessSecret){
    this.accessToken = accessToken;
    this.accessSecret = accessSecret;
    if (accessToken != null && accessSecret != null){
      OAuthParameters params = new OAuthParameters().consumerKey(CONSUMER_KEY)
        .signatureMethod("HMAC-SHA1").version("1.1").token(accessToken);
      OAuthSecrets secrets = new OAuthSecrets().consumerSecret(CONSUMER_SECRET)
        .tokenSecret(accessSecret);
      oAuthFilter = new OAuthClientFilter(client.getProviders(), params, secrets);
      service.addFilter(oAuthFilter);
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.