Package net.oauth

Examples of net.oauth.OAuthAccessor


    this.client = client;
  }

  public OAuthAccessor getRequestToken(OAuthAccessor accessor)
      throws IOException, OAuthException, URISyntaxException {
    OAuthAccessor accessorCopy = new OAuthAccessor(accessor.consumer);

    OAuthMessage response = client.invoke(accessor,
        accessor.consumer.serviceProvider.requestTokenURL,
        OAuth.newList("scope", accessor.getProperty("scope").toString()));
    log.info("Successfully got OAuth request token");
View Full Code Here


    return accessor;
  }

  public OAuthAccessor getAccessToken(OAuthAccessor accessor)
      throws IOException, OAuthException, URISyntaxException {
    OAuthAccessor accessorCopy = new OAuthAccessor(accessor.consumer);

    OAuthMessage response = client.invoke(accessor,
        accessor.consumer.serviceProvider.accessTokenURL,
        OAuth.newList("oauth_token", accessor.requestToken,
            "scope", accessor.getProperty("scope").toString()));
View Full Code Here

    while (propertyNames.hasMoreElements()) {
      String propertyName = propertyNames.nextElement();
      String key = propertyName.split("\\.")[0];
      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);
        accessors.put(key, newAccessor);

      } else if (parameter.equalsIgnoreCase(SCOPE)) {
        accessor.setProperty(SCOPE,
View Full Code Here

    newAccessor.setProperty(OAUTH_TEST_ENDPOINT, accessor.getProperty(OAUTH_TEST_ENDPOINT));
  }

  public OAuthAccessor getOAuthAccessor(String providerKey)
      throws ProviderInfoNotFoundException {
    OAuthAccessor result = accessors.get(providerKey);

    if (result == null) {
      throw new ProviderInfoNotFoundException(
          "no such provider: " + providerKey);
    } else {
View Full Code Here

      return copyAccessor(result);
    }
  }

  private OAuthAccessor copyAccessor(OAuthAccessor accessor) {
      OAuthAccessor result = new OAuthAccessor(accessor.consumer);
      result.setProperty("scope", accessor.getProperty("scope"));
      return result;
  }
View Full Code Here

      if (extra != null) {
        return makeOAuthProblemReport(OAuthConstants.PROBLEM_PARAMETER_REJECTED, extra,
            HttpResponse.SC_BAD_REQUEST);
      }
    }
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    validateMessage(accessor, info, true);
    String requestToken = Crypto.getRandomString(16);
    String requestTokenSecret = Crypto.getRandomString(16);
    String callbackUrl = info.message.getParameter(OAuth.OAUTH_CALLBACK);
    tokenState.put(
View Full Code Here

        return makeOAuthProblemReport(OAuthConstants.PROBLEM_PARAMETER_REJECTED,
            extra, HttpResponse.SC_BAD_REQUEST);
      }
    }

    OAuthAccessor accessor = new OAuthAccessor(oauthConsumer);
    accessor.requestToken = requestToken;
    accessor.tokenSecret = state.tokenSecret;
    validateMessage(accessor, info, true);

    if (state.getState() == State.APPROVED_UNCLAIMED) {
View Full Code Here

      consumer = signedFetchConsumer;
    } else {
      return makeOAuthProblemReport(OAuthConstants.PROBLEM_PARAMETER_MISSING,
          "oauth_consumer_key not found", HttpResponse.SC_BAD_REQUEST);
    }
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    String responseBody = null;
    if (throttled) {
      return makeOAuthProblemReport(
          OAuthConstants.PROBLEM_CONSUMER_KEY_REFUSED, "exceeded quota", HttpResponse.SC_FORBIDDEN);
    }
View Full Code Here

    helper.requestUxIcon(true);

    if (YES_STRING.equals(req.getParameter("oauth"))) {
      try {
        OAuthAccessor accessor = providerStore.getOAuthAccessor("google");
        helper.requestOauthAuthorization(accessor.consumer.consumerKey,
            "http://www.google.com/m8/feeds/");
      } catch (ProviderInfoNotFoundException e) {
        log("could not find provider info for Google", e);
        // we'll just ignore the OAuth request and proceed without it.
View Full Code Here

    String accessToken = NO_TOKEN;
    String accessTokenSecret = NO_TOKEN;
    if (!NO_TOKEN.equals(requestToken)) {
      // Try getting an acess token from this request token.
      try {
        OAuthAccessor accessor = providerStore.getOAuthAccessor("google");

        OAuthMessage response = oauthClient.invoke(accessor,
            accessor.consumer.serviceProvider.accessTokenURL,
            OAuth.newList(OAuth.OAUTH_TOKEN, requestToken));
View Full Code Here

TOP

Related Classes of net.oauth.OAuthAccessor

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.