Examples of OAuthException


Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

        if (credStore != null) {
          // Find the token for this user
          credStore.remove(getServiceName(), ACCESS_TOKEN_STORE_TYPE, getUserId());
        }
      } catch (CredentialStoreException cse) {
        throw new OAuthException(cse, "Error trying to delete Token.");
      }
    }
  }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

      } finally {
        StreamUtil.close(reader);
      }

    } catch (Exception e) {
      throw new OAuthException(e, "Internal error - getRequestToken failed Exception: ");
    }
    if (responseCode != HttpStatus.SC_OK) {
      String exceptionDetail = buildErrorMessage(responseCode, responseBody);
      if (StringUtil.isNotEmpty(exceptionDetail)) {
        throw new OAuthException(null,
            "HMACOAuth1Handler.java : getRequestTokenFromServer failed." + exceptionDetail);
      }
    } else {
      /*
       * The Response from Twitter contains OAuth request token, OAuth request token secret, and a
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

      } finally {
        StreamUtil.close(reader);
      }

    } catch (Exception e) {
      throw new OAuthException(e, "Internal error - getAccessToken failed Exception: ");
    }
    if (responseCode != HttpStatus.SC_OK) {
      String exceptionDetail = buildErrorMessage(responseCode, responseBody);
      if (exceptionDetail != null) {
        throw new OAuthException(null,
            "HMACOAuth1Handler.java : getAccessTokenFromServer failed. " + exceptionDetail);
      }
    } else {
      /*
       * Response from twitter contains Access Token, Access Token Secret, User Id and Screen Name of
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

    try {
      // generate the complete URL first
      signature = HMACEncryptionUtility.generateHMACSignature(url, method, consumerSecret, tokenSecret,
          treeMap);
    } catch (Exception e) {
      throw new OAuthException(e, "createAuthorizationHeader failed with Exception");
    }

    StringBuilder headerStr = new StringBuilder();
    headerStr.append("OAuth ").append(Configuration.CONSUMER_KEY).append("=\"").append(consumerKey)
        .append("\"");
    headerStr.append(",").append(Configuration.NONCE).append("=\"").append(nonce).append("\"");
    try {
      headerStr.append(",").append(Configuration.SIGNATURE).append("=\"")
          .append(URLEncoder.encode(signature, "UTF-8")).append("\"");
    } catch (UnsupportedEncodingException e1) {
      throw new OAuthException(e1,
          "createAuthorizationHeader failed with UnsupportedEncodingException");
    }
    headerStr.append(",").append(Configuration.SIGNATURE_METHOD).append("=\"")
        .append(getSignatureMethod()).append("\"");
    headerStr.append(",").append(Configuration.TIMESTAMP).append("=\"").append(timeStamp).append("\"");
View Full Code Here

Examples of com.sun.jersey.oauth.server.OAuthException

                throw new WebApplicationException(new Throwable("oauth_token MUST be present."), 400);
            }

            String consKey = params.getConsumerKey();
            if (consKey == null) {
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

            OAuthToken rt = provider.getRequestToken(params.getToken());
            if (rt == null) {
                // token invalid
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

            OAuthConsumer consumer = rt.getConsumer();
            if (consumer == null || !consKey.equals(consumer.getKey())) {
                // token invalid
                throw new OAuthException(Response.Status.BAD_REQUEST, null);

            }

            OAuthSecrets secrets = new OAuthSecrets().consumerSecret(consumer.getSecret()).tokenSecret(rt.getSecret());
            try {
                sigIsOk = OAuthSignature.verify(request, params, secrets);
            } catch (OAuthSignatureException ex) {
                Logger.getLogger(AccessTokenRequest.class.getName()).log(Level.SEVERE, null, ex);
            }

            if (!sigIsOk) {
                // signature invalid
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

            // We're good to go.
            OAuthToken at = provider.newAccessToken(rt, params.getVerifier());
           
            if(at == null) {
                throw new OAuthException(Response.Status.BAD_REQUEST, null);
            }

            // Preparing the response.
            Form resp = new Form();
            resp.putSingle(OAuthParameters.TOKEN, at.getToken());
View Full Code Here

Examples of net.oauth.OAuthException

  }

  public void testDoPostUnauthorizedWhenValidationFails() throws Exception {
    when(req.getHeaders("Authorization")).thenReturn(
        convertRawEnumerationToGeneric(generateOAuthHeader(ROBOT.getAddress())));
    doThrow(new OAuthException("")).when(validator).validateMessage(
        any(OAuthMessage.class), any(OAuthAccessor.class));

    servlet.doPost(req, resp);

    verify(resp).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
View Full Code Here

Examples of net.oauth.OAuthException

  public void testDoRequestTokenUnauthorizedOnOAuthException() throws Exception {
    when(req.getPathInfo()).thenReturn(REQUEST_TOKEN_PATH);
    when(req.getMethod()).thenReturn("GET");

    doThrow(new OAuthException("")).when(validator).validateMessage(
        any(OAuthMessage.class), any(OAuthAccessor.class));

    servlet.doGet(req, resp);

    verify(resp).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
View Full Code Here

Examples of net.oauth.OAuthException

    when(req.getMethod()).thenReturn("GET");

    Map<String, String[]> params = getDoExchangeTokenParams();
    when(req.getParameterMap()).thenReturn(params);

    doThrow(new OAuthException("")).when(validator).validateMessage(
        any(OAuthMessage.class), any(OAuthAccessor.class));

    servlet.doGet(req, resp);

    verify(validator).validateMessage(any(OAuthMessage.class), any(OAuthAccessor.class));
View Full Code Here

Examples of net.oauth.OAuthException

    verify(resp).sendError(eq(HttpServletResponse.SC_UNAUTHORIZED), anyString());
  }

  public void testDoPostUnauthorizedWhenValidationFails() throws Exception {
    doThrow(new OAuthException("")).when(validator).validateMessage(
        any(OAuthMessage.class), any(OAuthAccessor.class));
    Map<String, String[]> params = getOAuthParams();
    when(req.getParameterMap()).thenReturn(params);

    servlet.doPost(req, resp);
View Full Code Here

Examples of net.oauth.OAuthException

                problem.setParameter("oauth_acceptable_signature_methods",
                        acceptable.toString());
            }
            throw problem;
        } catch (InstantiationException e) {
            throw new OAuthException(e);
        } catch (IllegalAccessException e) {
            throw new OAuthException(e);
        }
    }
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.