Package net.oauth

Examples of net.oauth.OAuthAccessor


        parameters.put(OAuth.OAUTH_TIMESTAMP, String.valueOf(System.currentTimeMillis() / 1000));
        parameters.put(OAuth.OAUTH_CONSUMER_KEY, consumer.getKey());
       
        OAuthConsumer oAuthConsumer = new OAuthConsumer(null, consumer.getKey(), consumer.getSecret(),
                null);
        OAuthAccessor accessor = new OAuthAccessor(oAuthConsumer);
        return getToken(requestTokenService, accessor, parameters);
    }
View Full Code Here


        parameters.put(OAuth.OAUTH_VERIFIER, verifier);
        parameters.put(OAuth.OAUTH_SIGNATURE_METHOD, "HMAC-SHA1");
       
        OAuthConsumer oAuthConsumer = new OAuthConsumer(null, consumer.getKey(),
                consumer.getSecret(), null);
        OAuthAccessor accessor = new OAuthAccessor(oAuthConsumer);
        accessor.requestToken = requestToken.getToken();
        accessor.tokenSecret = requestToken.getSecret();
        return getToken(accessTokenService, accessor, parameters);
    }
View Full Code Here

        parameters.put(OAuth.OAUTH_NONCE, UUID.randomUUID().toString());
        parameters.put(OAuth.OAUTH_TIMESTAMP, String.valueOf(System.currentTimeMillis() / 1000));
       
        OAuthConsumer oAuthConsumer =
            new OAuthConsumer(null, consumer.getKey(), consumer.getSecret(), null);
        OAuthAccessor accessor = new OAuthAccessor(oAuthConsumer);
        if (accessToken != null) {
            accessor.accessToken = accessToken.getToken();
            accessor.tokenSecret = accessToken.getSecret();
        }
        return doGetAuthorizationHeader(accessor, method, requestURI, parameters);
View Full Code Here

    }

    OAuthConsumer consumer =
        new OAuthConsumer(null, participant.getAddress(), account.asRobot().getConsumerSecret(),
            oauthServiceProvider);
    OAuthAccessor accessor = new OAuthAccessor(consumer);

    processOpsRequest(req, resp, message, accessor, participant);
  }
View Full Code Here

   */
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    OAuthMessage message = new HttpRequestMessage(req, req.getRequestURL().toString());

    OAuthAccessor accessor;
    try {
      message.requireParameters(OAuth.OAUTH_TOKEN);
      accessor = tokenContainer.getAccessTokenAccessor(message.getParameter(OAuth.OAUTH_TOKEN));
    } catch (OAuthProblemException e) {
      LOG.info("No valid OAuth token present", e);
      // Have to set status here manually, cannot use e.getHttpStatusCode
      // because message.requireParameters doesn't set it in the exception.
      resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
      return;
    }
    ParticipantId participant =
        (ParticipantId) accessor.getProperty(DataApiTokenContainer.USER_PROPERTY_NAME);
   
    processOpsRequest(req, resp, message, accessor, participant);
  }
View Full Code Here

   *
   * @param requestToken the request token used for identification.
   * @throws OAuthProblemException if the token does not map to an accessor.
   */
  public OAuthAccessor getRequestTokenAccessor(String requestToken) throws OAuthProblemException {
    OAuthAccessor accessor = requestTokenAccessors.get(requestToken);
    if (accessor == null) {
      OAuthProblemException exception =
          OAuthUtil.newOAuthProblemException(OAuth.Problems.TOKEN_REJECTED);
      exception.setParameter(OAuth.OAUTH_TOKEN, requestToken);
      throw exception;
    }
    return accessor.clone();
  }
View Full Code Here

   *
   * @param accessToken the access token used for identification.
   * @throws OAuthProblemException if the token does not map to an accessor.
   */
  public OAuthAccessor getAccessTokenAccessor(String accessToken) throws OAuthProblemException {
    OAuthAccessor accessor = accessTokenAccessors.get(accessToken);
    if (accessor == null) {
      OAuthProblemException exception =
          OAuthUtil.newOAuthProblemException(OAuth.Problems.TOKEN_REJECTED);
      exception.setParameter(OAuth.OAUTH_TOKEN, accessToken);
      throw exception;
    }
    return accessor.clone();
  }
View Full Code Here

  public OAuthAccessor generateRequestToken(OAuthConsumer consumer) {
    Preconditions.checkNotNull(consumer, "Consumer must not be null");

    // Accessor can be generated up front with a token secret that does not need
    // to be unique.
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    accessor.tokenSecret = generateToken();

    do {
      accessor.requestToken = generateToken();
    } while (requestTokenAccessors.putIfAbsent(accessor.requestToken, accessor) != null);

    return accessor.clone();
  }
View Full Code Here

   */
  public OAuthAccessor authorizeRequestToken(String requestToken, ParticipantId user)
      throws OAuthProblemException {
    Preconditions.checkNotNull(user, "User must not be null");

    OAuthAccessor accessor = getRequestTokenAccessor(requestToken);

    if (accessor.getProperty(USER_PROPERTY_NAME) != null) {
      throw OAuthUtil.newOAuthProblemException(OAuth.Problems.TOKEN_USED);
    }

    accessor.setProperty(USER_PROPERTY_NAME, user);
    requestTokenAccessors.put(requestToken, accessor);

    LOG.info("Authorized request token for " + user);
    return accessor.clone();
  }
View Full Code Here

   * @param requestToken the request token used for identification.
   * @throws OAuthProblemException if the request token does not map to an
   *         accessor or if the token was already used.
   */
  public void rejectRequestToken(String requestToken) throws OAuthProblemException {
    OAuthAccessor accessor = getRequestTokenAccessor(requestToken);

    if (accessor.getProperty(USER_PROPERTY_NAME) != null) {
      throw OAuthUtil.newOAuthProblemException(OAuth.Problems.TOKEN_USED);
    }

    // Can't use remove(String, OAuthAccessor) since equals is not defined.
    requestTokenAccessors.remove(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.