Package net.oauth

Examples of net.oauth.OAuthConsumer


      if (consumerSecret == null)
          return null;

      // null below is for the callbackUrl, which we don't have in the db
      OAuthConsumer consumer = new OAuthConsumer(null, consumerKey, consumerSecret, SERVICE_PROVIDER);

      // Set some properties loosely based on the ModulePrefs of a gadget
      /*for (String key : ImmutableList.of("title", "summary", "description", "thumbnail", "icon")) {
        if (app.has(key))
          consumer.setProperty(key, app.getString(key));
View Full Code Here


        }
        if (cks == null) {
            throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR,
                    "No key for gadget " + securityToken.getAppUrl() + " and service " + serviceName);
        }
        OAuthConsumer consumer = null;
        if (cks.getKeyType() == BasicOAuthStoreConsumerKeyAndSecret.KeyType.RSA_PRIVATE) {
            consumer = new OAuthConsumer(null, cks.getConsumerKey(), null, provider);
            // The oauth.net java code has lots of magic.  By setting this property here, code thousands
            // of lines away knows that the consumerSecret value in the consumer should be treated as
            // an RSA private key and not an HMAC key.
            consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.RSA_SHA1);
            consumer.setProperty(RSA_SHA1.PRIVATE_KEY, cks.getConsumerSecret());
        } else {
            consumer = new OAuthConsumer(null, cks.getConsumerKey(), cks.getConsumerSecret(), provider);
            consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
        }
        String callback = (cks.getCallbackUrl() != null ? cks.getCallbackUrl() : defaultCallbackUrl);
        return new ConsumerInfo(consumer, cks.getKeyName(), callback);
    }
View Full Code Here

      String parameter = propertyName.split("\\.")[1];

      OAuthAccessor accessor = accessors.get(key);
      if (accessor == null) {
        OAuthServiceProvider provider = new OAuthServiceProvider("", "", "");
        OAuthConsumer consumer = new OAuthConsumer("", "", "", provider);
        accessor = new OAuthAccessor(consumer);
        accessors.put(key, accessor);
      }

      if (parameter.equalsIgnoreCase(ACCESS_URL)) {
        OAuthServiceProvider provider = new OAuthServiceProvider(
            accessor.consumer.serviceProvider.requestTokenURL,
            accessor.consumer.serviceProvider.userAuthorizationURL,
            properties.getProperty(propertyName, "").trim());

        OAuthConsumer consumer = new OAuthConsumer("",
            accessor.consumer.consumerKey,
            accessor.consumer.consumerSecret,
            provider);
        OAuthAccessor newAccessor = new OAuthAccessor(consumer);
        copyProperties(newAccessor, accessor);
        accessors.put(key, newAccessor);

      } else if (parameter.equalsIgnoreCase(AUTH_URL)) {
        OAuthServiceProvider provider = new OAuthServiceProvider(
            accessor.consumer.serviceProvider.requestTokenURL,
            properties.getProperty(propertyName, "").trim(),
            accessor.consumer.serviceProvider.accessTokenURL);

        OAuthConsumer consumer = new OAuthConsumer("",
            accessor.consumer.consumerKey,
            accessor.consumer.consumerSecret,
            provider);
        OAuthAccessor newAccessor = new OAuthAccessor(consumer);
        copyProperties(newAccessor, accessor);
        accessors.put(key, newAccessor);


      } else if (parameter.equalsIgnoreCase(REQUEST_URL)) {
        OAuthServiceProvider provider = new OAuthServiceProvider(
            properties.getProperty(propertyName, "").trim(),
            accessor.consumer.serviceProvider.userAuthorizationURL,
            accessor.consumer.serviceProvider.accessTokenURL);

        OAuthConsumer consumer = new OAuthConsumer("",
            accessor.consumer.consumerKey,
            accessor.consumer.consumerSecret,
            provider);
        OAuthAccessor newAccessor = new OAuthAccessor(consumer);
        copyProperties(newAccessor, accessor);
        accessors.put(key, newAccessor);

      } else if (parameter.equalsIgnoreCase(CONSUMER_KEY)) {
        OAuthConsumer consumer = new OAuthConsumer("",
            properties.getProperty(propertyName, "").trim(),
            accessor.consumer.consumerSecret,
            accessor.consumer.serviceProvider);
        OAuthAccessor newAccessor = new OAuthAccessor(consumer);
        copyProperties(newAccessor, accessor);
        accessors.put(key, newAccessor);

      } else if (parameter.equalsIgnoreCase(CONSUMER_SECRET)) {
        OAuthConsumer consumer = new OAuthConsumer("",
            accessor.consumer.consumerKey,
            properties.getProperty(propertyName, "").trim(),
            accessor.consumer.serviceProvider);
        OAuthAccessor newAccessor = new OAuthAccessor(consumer);
        copyProperties(newAccessor, accessor);
View Full Code Here

  public FakeOAuthServiceProvider(TimeSource clock) {
    this.clock = clock;
    OAuthServiceProvider provider = new OAuthServiceProvider(
        REQUEST_TOKEN_URL, APPROVAL_URL, ACCESS_TOKEN_URL);

    signedFetchConsumer = new OAuthConsumer(null, null, null, null);
    signedFetchConsumer.setProperty(RSA_SHA1.X509_CERTIFICATE, CERTIFICATE_TEXT);

    oauthConsumer = new OAuthConsumer(null, CONSUMER_KEY, CONSUMER_SECRET, provider);

    tokenState = Maps.newHashMap();
    validParamLocations = Sets.newHashSet();
    validParamLocations.add(OAuthParamLocation.URI_QUERY);
  }
View Full Code Here

  private HttpResponse handleRequestTokenUrl(HttpRequest request)
      throws Exception {
    MessageInfo info = parseMessage(request);
    String requestConsumer = info.message.getParameter(OAuth.OAUTH_CONSUMER_KEY);
    OAuthConsumer consumer;
    if (CONSUMER_KEY.equals(requestConsumer)) {
      consumer = oauthConsumer;
    } else {
      return makeOAuthProblemReport(
          OAuthConstants.PROBLEM_CONSUMER_KEY_UNKNOWN, "invalid consumer: " + requestConsumer,
View Full Code Here

  private HttpResponse handleResourceUrl(HttpRequest request)
      throws Exception {
    MessageInfo info = parseMessage(request);
    String consumerId = info.message.getParameter("oauth_consumer_key");
    OAuthConsumer consumer;
    if (CONSUMER_KEY.equals(consumerId)) {
      consumer = oauthConsumer;
    } else if ("signedfetch".equals(consumerId)) {
      consumer = signedFetchConsumer;
    } else if ("container.com".equals(consumerId)) {
View Full Code Here

      if (consumerSecret == null)
          return null;

      // null below is for the callbackUrl, which we don't have in the db
      OAuthConsumer consumer = new OAuthConsumer(null, consumerKey, consumerSecret, SERVICE_PROVIDER);

      // Set some properties loosely based on the ModulePrefs of a gadget
      for (String key : ImmutableList.of("title", "summary", "description", "thumbnail", "icon")) {
        if (app.has(key))
          consumer.setProperty(key, app.getString(key));
      }

      return consumer;

    } catch (JSONException e) {
View Full Code Here

    }
    if (cks == null) {
      throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR,
          "No key for gadget " + securityToken.getAppUrl() + " and service " + serviceName);
    }
    OAuthConsumer consumer = null;
    if (cks.getKeyType() == KeyType.RSA_PRIVATE) {
      consumer = new OAuthConsumer(null, cks.getConsumerKey(), null, provider);
      // The oauth.net java code has lots of magic.  By setting this property here, code thousands
      // of lines away knows that the consumerSecret value in the consumer should be treated as
      // an RSA private key and not an HMAC key.
      consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.RSA_SHA1);
      consumer.setProperty(RSA_SHA1.PRIVATE_KEY, cks.getConsumerSecret());
    } else {
      consumer = new OAuthConsumer(null, cks.getConsumerKey(), cks.getConsumerSecret(), provider);
      consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
    }
    String callback = (cks.getCallbackUrl() != null ? cks.getCallbackUrl() : defaultCallbackUrl);
    return new ConsumerInfo(consumer, cks.getKeyName(), callback);
  }
View Full Code Here

    }
    if (xOauthRequestor != null) {
      oauthParams.add(new OAuth.Parameter("xoauth_requestor_id", xOauthRequestor));
    }

    OAuthConsumer consumer = new OAuthConsumer(null, consumerKey, consumerSecret, null);
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    accessor.accessToken = accessToken;
    accessor.tokenSecret = tokenSecret;
    OAuthMessage message = accessor.newRequestMessage(method, target.toString(), oauthParams);
View Full Code Here

  }

  protected SecurityToken verifyMessage(OAuthMessage message)
      throws OAuthProblemException {
    OAuthEntry entry = getOAuthEntry(message);
    OAuthConsumer authConsumer = getConsumer(message);

    OAuthAccessor accessor = new OAuthAccessor(authConsumer);

    if (entry != null) {
      accessor.tokenSecret = entry.tokenSecret;
View Full Code Here

TOP

Related Classes of net.oauth.OAuthConsumer

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.