Examples of OAuthMessage


Examples of net.oauth.OAuthMessage

      }
    }

    HttpRequest signed = sanitizeAndSign(request, msgParams, true);

    OAuthMessage reply = sendOAuthMessage(signed);

    accessor.accessToken = OAuthUtil.getParameter(reply, OAuth.OAUTH_TOKEN);
    accessor.tokenSecret = OAuthUtil.getParameter(reply, OAuth.OAUTH_TOKEN_SECRET);
    accessorInfo.setSessionHandle(OAuthUtil.getParameter(reply,
        OAuthConstants.OAUTH_SESSION_HANDLE));
View Full Code Here

Examples of net.oauth.OAuthMessage

   * @param response
   * @throws OAuthProtocolException
   */
  private void checkForProtocolProblem(HttpResponse response) throws OAuthProtocolException {
    if (isFullOAuthError(response)) {
      OAuthMessage message = parseAuthHeader(null, response);
      if (OAuthUtil.getParameter(message, OAuthProblemException.OAUTH_PROBLEM) != null) {
        // SP reported extended error information
        throw new OAuthProtocolException(message);
      }
      // No extended information, guess based on HTTP response code.
View Full Code Here

Examples of net.oauth.OAuthMessage

    }

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

    List<Map.Entry<String, String>> entryList = OAuthRequest.selectOAuthParams(message);

    switch (paramLocationEnum) {
      case AUTH_HEADER:
        request.addHeader("Authorization", OAuthRequest.getAuthorizationHeader(entryList));
        break;

      case POST_BODY:
        if (!OAuth.isFormEncoded(contentType)) {
          throw new RuntimeException(
              "OAuth param location can only be post_body if post body if of " +
                  "type x-www-form-urlencoded");
        }
        String oauthData = OAuthUtil.formEncode(message.getParameters());
        request.setPostBody(CharsetUtil.getUtf8Bytes(oauthData));
        break;

      case URI_QUERY:
        request.setUri(Uri.parse(OAuthUtil.addParameters(request.getUri().toString(),
View Full Code Here

Examples of net.oauth.OAuthMessage

      return new HttpResponseBuilder()
          .setHttpStatusCode(rc)
          .setResponseString("some vague error")
          .create();
    }
    OAuthMessage msg = new OAuthMessage(null, null, null);
    msg.addParameter("oauth_problem", code);
    msg.addParameter("oauth_problem_advice", text);   
    return new HttpResponseBuilder()
        .setHttpStatusCode(HttpResponse.SC_FORBIDDEN)
        .addHeader("WWW-Authenticate", msg.getAuthorizationHeader("realm"))
        .create();
  }
View Full Code Here

Examples of net.oauth.OAuthMessage

        }
      }
    }
   
    // Return the lot
    info.message = new OAuthMessage(method, parsed.getLocation(), params);
   
    // Check for trusted parameters
    if (checkTrustedParams) {
      if (!"foo".equals(OAuthUtil.getParameter(info.message, "oauth_magic"))) {
        throw new RuntimeException("no oauth_trusted=foo parameter");
View Full Code Here

Examples of net.oauth.OAuthMessage

    }
   
    private static String doGetAuthorizationHeader(OAuthAccessor accessor,
            String method, String requestURI, Map<String, String> parameters) {
        try {
            OAuthMessage msg = accessor.newRequestMessage(method, requestURI, parameters.entrySet());
            StringBuilder sb = new StringBuilder();
            sb.append(msg.getAuthorizationHeader(null));
            for (Map.Entry<String, String> entry : parameters.entrySet()) {
                if (!entry.getKey().startsWith("oauth_")) {
                    sb.append(", ");
                    sb.append(OAuth.percentEncode(entry.getKey())).append("=\"");
                    sb.append(OAuth.percentEncode(entry.getValue())).append('"');
View Full Code Here

Examples of net.oauth.OAuthMessage

  /**
   * Entry point for the Active Api Calls.
   */
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    OAuthMessage message = new HttpRequestMessage(req, req.getRequestURL().toString());
    // OAuth %-escapes the @ in the username so we need to decode it.
    String username = OAuth.decodePercent(message.getConsumerKey());

    ParticipantId participant;
    try {
      participant = ParticipantId.of(username);
    } catch (InvalidParticipantAddress e) {
View Full Code Here

Examples of net.oauth.OAuthMessage

  /**
   * Entry point for the Data API Calls.
   */
  @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());
View Full Code Here

Examples of net.oauth.OAuthMessage

  /**
   * Handles the request to get a new unauthorized request token.
   */
  private void doRequestToken(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    OAuthMessage message = new HttpRequestMessage(req, req.getRequestURL().toString());

    // Anyone can generate a request token.
    OAuthConsumer consumer =
        new OAuthConsumer("", ANONYMOUS_TOKEN, ANONYMOUS_TOKEN_SECRET, serviceProvider);
    OAuthAccessor accessor = new OAuthAccessor(consumer);
View Full Code Here

Examples of net.oauth.OAuthMessage

   */
  private void doAuthorizeToken(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    // Check if the OAuth parameters are present, even if we don't use them
    // during a GET request.
    OAuthMessage message = new HttpRequestMessage(req, req.getRequestURL().toString());
    try {
      message.requireParameters(OAuth.OAUTH_CALLBACK, OAuth.OAUTH_TOKEN);
    } catch (OAuthProblemException e) {
      LOG.info("Parameter absent", e);
      resp.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
      return;
    }

    // Check if the user is logged in, else redirect to login.
    ParticipantId user = sessionManager.getLoggedInUser(req.getSession(false));
    if (user == null) {
      resp.sendRedirect(sessionManager.getLoginUrl(
          DATA_API_OAUTH_PATH + authorizeTokenPath + "?" + req.getQueryString()));
      return;
    }

    // Check if the request token is valid, note that this doesn't hold after
    // the call to the container since the token might time out.
    try {
      tokenContainer.getRequestTokenAccessor(message.getToken());
    } catch (OAuthProblemException e) {
      LOG.info("Trying to load a non existing token for authorization", e);
      resp.sendError(e.getHttpStatusCode(), e.getMessage());
      return;
    }
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.