Package net.oauth

Examples of net.oauth.OAuthConsumer


    @RequestMapping("/handleTemporaryCredentials")
    public ModelAndView handleRequest(@ModelAttribute(value = "oAuthParams") OAuthParams oAuthParams,
                                      HttpServletResponse response) {

        OAuthServiceProvider provider;
        OAuthConsumer consumer;
        OAuthAccessor accessor;

        OAuthClient client = new OAuthClient(new URLConnectionClient());

        oAuthParams.setErrorMessage(null);
        String temporaryCredentialsEndpointUrl = oAuthParams.getTemporaryCredentialsEndpoint();
        if (temporaryCredentialsEndpointUrl == null || "".equals(temporaryCredentialsEndpointUrl)) {
            oAuthParams.setErrorMessage("Missing temporary credentials endpoint url");
        }
        String clientId = oAuthParams.getClientID();
        if (clientId == null || "".equals(clientId)) {
            oAuthParams.setErrorMessage("Missing client identifier");
        }
        String secret = oAuthParams.getClientSecret();
        if (secret == null || "".equals(secret)) {
            oAuthParams.setErrorMessage("Missing client shared-secret");
        }

        if (oAuthParams.getErrorMessage() == null) {
            provider = new OAuthServiceProvider(temporaryCredentialsEndpointUrl,
                oAuthParams.getResourceOwnerAuthorizationEndpoint(), oAuthParams.getTokenRequestEndpoint());
            consumer = new OAuthConsumer(null, clientId,
                secret,
                provider);
            accessor = new OAuthAccessor(consumer);

            Map<String, String> parameters = new HashMap<String, String>();
View Full Code Here


    byte[] hash = DigestUtils.sha(jsonBody);
    byte[] encodedHash = Base64.encodeBase64(hash, false);
    message.addParameter(OAUTH_BODY_HASH, new String(encodedHash, UTF_8));

    // Add other parameters.
    OAuthConsumer consumer = new OAuthConsumer(null, OAUTH_CONSUMER_KEY_DOMAIN + ":" + consumerKey,
        consumerSecret, null);
    consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    message.addRequiredParameters(accessor);
    LOG.info("Signature base string: " + OAuthSignatureMethod.getBaseString(message));

    // Construct the resulting URL.
View Full Code Here

      throw new IllegalArgumentException("Body hash does not match. Expected: " + encodedHash
          + ", provided: " + message.getParameter(OAUTH_BODY_HASH));
    }

    // Construct validator arguments.
    OAuthConsumer consumer = new OAuthConsumer(null, consumerKey, consumerSecret, null);
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    LOG.info("Signature base string: " + OAuthSignatureMethod.getBaseString(message));
    message.validateMessage(accessor, new SimpleOAuthValidator());
  }
View Full Code Here

      String certificate = certificateProvider.getCertificate(consumerKey);
      if (certificate == null) {
        return false;
      }

      OAuthConsumer consumer = new OAuthConsumer(null, consumerKey, null, null);

      consumer.setProperty(RSA_SHA1.X509_CERTIFICATE, certificate);

      OAuthMessage message = new OAuthMessage(request.getMethod(),
          request.getRequestURL().toString(), getRequestParameters(request));

      OAuthAccessor accessor = new OAuthAccessor(consumer);
View Full Code Here

    for (Map.Entry<String, String> header : headers.entrySet()) {
      message.getHeaders().add(header);
    }

    OAuthConsumer consumer =
      new OAuthConsumer(null, consumerKey, consumerSecret, null);
    consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);

    OAuthAccessor accessor = new OAuthAccessor(consumer);

    return getHttpMessage(message, accessor, body, provider.getSignBodyHash());
  }
View Full Code Here

  private OAuthAccessor getOAuthAccessor() {
    OAuthServiceProvider serviceProvider = new OAuthServiceProvider(
        provider.getRequestTokenUrl(), provider.getAuthorizeUrl(),
        provider.getAccessTokenUrl());

    OAuthConsumer consumer = new OAuthConsumer(null, consumerKey,
        consumerSecret, serviceProvider);
    consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);

    return new OAuthAccessor(consumer);
  }
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.getTokenSecret();
View Full Code Here

    return entry;
  }

  protected OAuthConsumer getConsumer(OAuthMessage message) throws OAuthProblemException {
    String consumerKey = getParameter(message, OAuth.OAUTH_CONSUMER_KEY);
    OAuthConsumer authConsumer = store.getConsumer(consumerKey);
    if (authConsumer == null) {
      throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_UNKNOWN);
    }
    return authConsumer;
  }
View Full Code Here

                                       Client client,
                                       Token token,
                                       OAuthDataProvider provider,
                                       OAuthValidator validator)
        throws Exception {
        OAuthConsumer consumer = new OAuthConsumer(null, client.getConsumerKey(),
            client.getSecretKey(), null);
        OAuthAccessor accessor = new OAuthAccessor(consumer);
        if (token != null) {
            if (token instanceof RequestToken) {
                accessor.requestToken = token.getTokenKey();
View Full Code Here

        String gadgetUri = securityToken.getAppUrl();
        OAuthConsumerStore consumerStore = consumerStoreService.findByUriAndServiceName(gadgetUri, serviceName);
        if (consumerStore == null) {
            return null;
        }
        OAuthConsumer consumer = createOAuthConsumer(provider, consumerStore);
        String callbackUrl = (consumerStore.getCallbackUrl() != null ?
                consumerStore.getCallbackUrl() : defaultCallbackUrl);

        return new ConsumerInfo(consumer, consumerStore.getKeyName(), callbackUrl);
    }
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.