private OAuthParamLocation getStoreLocation(Location location, OAuthResponseParams responseParams) throws OAuthRequestException { switch(location) { case HEADER: return OAuthParamLocation.AUTH_HEADER; case URL: return OAuthParamLocation.URI_QUERY; case BODY: return OAuthParamLocation.POST_BODY; } throw new OAuthRequestException(OAuthError.UNKNOWN_PARAMETER_LOCATION); }
private OAuthParamLocation getStoreLocation(Location location, OAuthResponseParams responseParams) throws OAuthRequestException { switch(location) { case HEADER: return OAuthParamLocation.AUTH_HEADER; case URL: return OAuthParamLocation.URI_QUERY; case BODY: return OAuthParamLocation.POST_BODY; } throw new OAuthRequestException(OAuthError.UNKNOWN_PARAMETER_LOCATION); }
private OAuthParamLocation getStoreLocation(Location location, OAuthResponseParams responseParams) throws OAuthRequestException { switch(location) { case HEADER: return OAuthParamLocation.AUTH_HEADER; case URL: return OAuthParamLocation.URI_QUERY; case BODY: return OAuthParamLocation.POST_BODY; } throw new OAuthRequestException(OAuthError.UNKNOWN_PARAMETER_LOCATION); }
private HttpMethod getStoreMethod(Method method, OAuthResponseParams responseParams) throws OAuthRequestException { switch(method) { case GET: return HttpMethod.GET; case POST: return HttpMethod.POST; } throw new OAuthRequestException(OAuthError.UNSUPPORTED_HTTP_METHOD, method.toString()); }
private HttpMethod getStoreMethod(Method method, OAuthResponseParams responseParams) throws OAuthRequestException { switch(method) { case GET: return HttpMethod.GET; case POST: return HttpMethod.POST; } throw new OAuthRequestException(OAuthError.UNSUPPORTED_HTTP_METHOD, method.toString()); }
private GadgetSpec findSpec(final SecurityToken securityToken, final OAuthArguments arguments, OAuthResponseParams responseParams) throws OAuthRequestException { try { GadgetContext context = new OAuthGadgetContext(securityToken, arguments); return specFactory.getGadgetSpec(context); } catch (IllegalArgumentException e) { throw new OAuthRequestException(OAuthError.UNKNOWN_PROBLEM, "Could not fetch gadget spec, gadget URI invalid.", e); } catch (GadgetException e) { throw new OAuthRequestException(OAuthError.UNKNOWN_PROBLEM, "Could not fetch gadget spec", e); } }
private GadgetSpec findSpec(final SecurityToken securityToken, final OAuthArguments arguments, OAuthResponseParams responseParams) throws OAuthRequestException { try { GadgetContext context = new OAuthGadgetContext(securityToken, arguments); return specFactory.getGadgetSpec(context); } catch (IllegalArgumentException e) { throw new OAuthRequestException(OAuthError.UNKNOWN_PROBLEM, "Could not fetch gadget spec, gadget URI invalid.", e); } catch (GadgetException e) { throw new OAuthRequestException(OAuthError.UNKNOWN_PROBLEM, "Could not fetch gadget spec", e); } }
private GadgetSpec findSpec(final SecurityToken securityToken, final OAuthArguments arguments, OAuthResponseParams responseParams) throws OAuthRequestException { try { GadgetContext context = new OAuthGadgetContext(securityToken, arguments); return specFactory.getGadgetSpec(context); } catch (IllegalArgumentException e) { throw new OAuthRequestException(OAuthError.UNKNOWN_PROBLEM, "Could not fetch gadget spec, gadget URI invalid.", e); } catch (GadgetException e) { throw new OAuthRequestException(OAuthError.UNKNOWN_PROBLEM, "Could not fetch gadget spec", e); } }
private HttpMethod getStoreMethod(Method method, OAuthResponseParams responseParams) throws OAuthRequestException { switch(method) { case GET: return HttpMethod.GET; case POST: return HttpMethod.POST; } throw new OAuthRequestException(OAuthError.UNSUPPORTED_HTTP_METHOD, method.toString()); }
private HttpResponse fetchFromServer(HttpRequest request) throws OAuthRequestException { HttpResponse response = null; try { response = fetcher.fetch(request); if (response == null) { throw new OAuthRequestException(OAuthError.MISSING_SERVER_RESPONSE); } return response; } catch (GadgetException e) { throw new OAuthRequestException(OAuthError.MISSING_SERVER_RESPONSE, "", e); } finally { responseParams.addRequestTrace(request, response); } }
private HttpResponse fetchFromServer(HttpRequest request) throws OAuthRequestException { HttpResponse response = null; try { response = fetcher.fetch(request); if (response == null) { throw new OAuthRequestException(OAuthError.MISSING_SERVER_RESPONSE); } return response; } catch (GadgetException e) { throw new OAuthRequestException(OAuthError.MISSING_SERVER_RESPONSE, "", e); } finally { responseParams.addRequestTrace(request, response); } }
/** * Store an access token for the given user/gadget/service/token name */ public void storeTokenKeyAndSecret(SecurityToken securityToken, ConsumerInfo consumerInfo, OAuthArguments arguments, TokenInfo tokenInfo, OAuthResponseParams responseParams) throws OAuthRequestException { try { store.setTokenInfo(securityToken, consumerInfo, arguments.getServiceName(), arguments.getTokenName(), tokenInfo); } catch (GadgetException e) { throw new OAuthRequestException(OAuthError.UNKNOWN_PROBLEM, "Unable to store access token", e); } }
/** * Store an access token for the given user/gadget/service/token name */ public void storeTokenKeyAndSecret(SecurityToken securityToken, ConsumerInfo consumerInfo, OAuthArguments arguments, TokenInfo tokenInfo, OAuthResponseParams responseParams) throws OAuthRequestException { try { store.setTokenInfo(securityToken, consumerInfo, arguments.getServiceName(), arguments.getTokenName(), tokenInfo); } catch (GadgetException e) { throw new OAuthRequestException(OAuthError.UNKNOWN_PROBLEM, "Unable to store access token", e); } }
@Test public void testNullSafe() { params.addRequestTrace(null, null); new OAuthRequestException("error", "errorText"); params.logDetailedWarning("org.apache.shindig.gadgets.oauth.OAuthResponseParamsTest","testNullSafe","wow"); params.logDetailedWarning("org.apache.shindig.gadgets.oauth.OAuthResponseParamsTest","testNullSafe","new runtime", new RuntimeException()); }
private HttpRequest createRequestTokenRequest(OAuthAccessor accessor) throws OAuthRequestException { if (accessor.consumer.serviceProvider.requestTokenURL == null) { throw new OAuthRequestException(OAuthError.BAD_OAUTH_TOKEN_URL, "request token"); } HttpRequest request = new HttpRequest( Uri.parse(accessor.consumer.serviceProvider.requestTokenURL)); request.setMethod(accessorInfo.getHttpMethod().toString()); if (accessorInfo.getHttpMethod() == HttpMethod.POST) { request.setHeader("Content-Type", OAuth.FORM_ENCODED); } return request; }
@Test public void testNullSafe() { params.addRequestTrace(null, null); new OAuthRequestException("error", "errorText"); params.logDetailedWarning("wow"); params.logDetailedWarning("new runtime", new RuntimeException()); }
@Test public void testNullSafe() { params.addRequestTrace(null, null); new OAuthRequestException("error", "errorText"); params.logDetailedWarning("org.apache.shindig.gadgets.oauth.OAuthResponseParamsTest","testNullSafe","wow"); params.logDetailedWarning("org.apache.shindig.gadgets.oauth.OAuthResponseParamsTest","testNullSafe","new runtime", new RuntimeException()); }
private HttpRequest createRequestTokenRequest(OAuthAccessor accessor) throws OAuthRequestException { if (accessor.consumer.serviceProvider.requestTokenURL == null) { throw new OAuthRequestException(OAuthError.BAD_OAUTH_TOKEN_URL, "request token"); } HttpRequest request = new HttpRequest( Uri.parse(accessor.consumer.serviceProvider.requestTokenURL)); request.setMethod(accessorInfo.getHttpMethod().toString()); if (accessorInfo.getHttpMethod() == HttpMethod.POST) { request.setHeader("Content-Type", OAuth.FORM_ENCODED); } return request; }
private HttpRequest createRequestTokenRequest(OAuthAccessor accessor) throws OAuthRequestException { if (accessor.consumer.serviceProvider.requestTokenURL == null) { throw new OAuthRequestException(OAuthError.BAD_OAUTH_TOKEN_URL, "request token"); } HttpRequest request = new HttpRequest( Uri.parse(accessor.consumer.serviceProvider.requestTokenURL)); request.setMethod(accessorInfo.getHttpMethod().toString()); if (accessorInfo.getHttpMethod() == HttpMethod.POST) { request.setHeader("Content-Type", OAuth.FORM_ENCODED); } request.setSecurityToken( new AnonymousSecurityToken( "", 0L, this.realRequest.getSecurityToken().getAppUrl())); return request; }
@Test public void testException() { HttpRequest req = new HttpRequest(Uri.parse("http://www")); HttpResponse ok = new HttpResponseBuilder().setHttpStatusCode(200).create(); params.addRequestTrace(req, ok); OAuthRequestException e = new OAuthRequestException("error", "errorText"); checkStringContains(e.toString(), "[error,errorText]"); params.addRequestTrace(null, null); Throwable cause = new RuntimeException(); e = new OAuthRequestException(OAuthError.UNAUTHENTICATED, "errorText", cause); checkStringContains(e.toString(), "[UNAUTHENTICATED,Unauthenticated OAuth fetch]"); assertEquals(cause, e.getCause()); }