Refine search
protected URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(hostToReplace).build(); }
@Override public URI apply(String path) throws HttpException { String requestedResource = new StringBuilder().append("/rest/namespace/").append(path).toString(); String expires = timeStampProvider.get().toString(); String signature = signString(createStringToSign(requestedResource, expires)); return uriBuilder(provider.get()) .replaceQuery(ImmutableMap.of("uid", creds.get().identity, "expires", expires, "signature", signature)) .appendPath(requestedResource).build(); }
protected URI getURI(String headerValue) { if (headerValue == null) return null; URI toReturn = URI.create(headerValue); if (!"127.0.0.1".equals(toReturn.getHost())) return toReturn; return uriBuilder(toReturn).host(hostToReplace).build(); }
/** * @see HttpRequest#getEndpoint() */ public T replacePath(String path) { checkNotNull(endpoint, "endpoint"); checkNotNull(path, "path"); endpoint = uriBuilder(endpoint).path(path).build(); return self(); }
/** * @see HttpRequest#getEndpoint() */ public T replacePath(String path) { checkNotNull(endpoint, "endpoint"); checkNotNull(path, "path"); endpoint = uriBuilder(endpoint).path(path).build(); return self(); }
/** * @see HttpRequest#getEndpoint() */ public T replacePath(String path) { checkNotNull(endpoint, "endpoint"); checkNotNull(path, "path"); endpoint = uriBuilder(endpoint).path(path).build(); return self(); }
/** * @see HttpRequest#getEndpoint() */ public T replacePath(String path) { checkNotNull(endpoint, "endpoint"); checkNotNull(path, "path"); endpoint = uriBuilder(endpoint).path(path).build(); return self(); }
@SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object arg) { CreateRecord<?> in = CreateRecord.class.cast(checkNotNull(arg, "record to create")); URI path = uriBuilder(request.getEndpoint()) .build(ImmutableMap.<String, Object> builder() .put("type", in.getType()) .put("fqdn", in.getFQDN()).build()); return (R) request.toBuilder() .endpoint(path) .payload(json.toJson(ImmutableMap.of("rdata", in.getRData(), "ttl", in.getTTL()))).build(); } }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.name()).build()).build(); } }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.name()).build()).build(); } }
@Override @SuppressWarnings("unchecked") public <R extends HttpRequest> R bindToRequest(R request, Object payload) { checkNotNull(payload, "hostprefix"); checkArgument(isValid(request.getEndpoint().getHost()), "this is only valid for hostnames: " + request); InternetDomainName name = from(request.getEndpoint().getHost()).child(payload.toString()); return (R) request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).host(name.toString()).build()).build(); } }
@Override public URI apply(String input) { return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get()) .appendPath("/global/networks/").appendPath(input).build(); } };
@Override public URI apply(String input) { return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get()) .appendPath("/global/networks/").appendPath(input).build(); } };
@Override public URI apply(String input) { return Uris.uriBuilder(endpoint.get()).appendPath("/projects/").appendPath(userProject.get()) .appendPath("/zones/").appendPath(input).build(); } };
@Test public void testWhenMatrixOnPath() { assertEquals( uriBuilder("https://api.rimuhosting.com/r").appendPath("orders;include_inactive=N").build(templateParams) .toASCIIString(), "https://api.rimuhosting.com/r/orders;include_inactive=N"); }
@Test public void testWhenUrnInPath() { assertEquals(uriBuilder("https://vcloud/api").appendPath("urn::acme:foo").build(templateParams).toASCIIString(), "https://vcloud/api/urn::acme:foo"); }
public HttpRequest filter(HttpRequest request) throws HttpException { checkNotNull(request, "request must be present"); Multimap<String, String> decodedParams = queryParser().apply(request.getEndpoint().getRawQuery()); addSigningParams(decodedParams); String stringToSign = createStringToSign(request, decodedParams); String signature = sign(stringToSign); addSignature(decodedParams, signature); request = request.toBuilder().endpoint(uriBuilder(request.getEndpoint()).query(decodedParams).build()).build(); utils.logRequest(signatureLog, request, "<<"); return request; }
public void testScheme() { assertEquals(uriBuilder("https://foo.com:8080").scheme("http").toString(), "http://foo.com:8080"); assertEquals(uriBuilder("https://foo.com:8080").scheme("http").build().toString(), "http://foo.com:8080"); assertEquals(uriBuilder("https://api.github.com/repos/user?foo=bar&kung=fu").scheme("http").toString(), "http://api.github.com/repos/user?foo=bar&kung=fu"); assertEquals(uriBuilder("https://api.github.com/repos/user?foo=bar&kung=fu").scheme("http").build().toString(), "http://api.github.com/repos/user?foo=bar&kung=fu"); assertEquals(uriBuilder("https://api.github.com/repos/{user}").scheme("http").toString(), "http://api.github.com/repos/{user}"); assertEquals(uriBuilder("https://api.github.com/repos/{user}").scheme("http").build(templateParams) .toASCIIString(), "http://api.github.com/repos/bob"); }
public void testHost() { assertEquals(uriBuilder("https://foo.com:8080").host("robots").toString(), "https://robots:8080"); assertEquals(uriBuilder("https://foo.com:8080").host("robots").build().toString(), "https://robots:8080"); assertEquals(uriBuilder("https://api.github.com/repos/user?foo=bar&kung=fu").host("robots").toString(), "https://robots/repos/user?foo=bar&kung=fu"); assertEquals(uriBuilder("https://api.github.com/repos/user?foo=bar&kung=fu").host("robots").build().toString(), "https://robots/repos/user?foo=bar&kung=fu"); assertEquals(uriBuilder("https://api.github.com/repos/{user}").host("robots").toString(), "https://robots/repos/{user}"); assertEquals(uriBuilder("https://api.github.com/repos/{user}").host("robots").build(templateParams) .toASCIIString(), "https://robots/repos/bob"); }
public void testAddQuery() { assertEquals(uriBuilder("http://localhost:8080/client/api").addQuery("response", "json").toString(), "http://localhost:8080/client/api?response=json"); assertEquals( uriBuilder(URI.create("http://localhost:8080/client/api")).addQuery("response", "json") .addQuery("command", "queryAsyncJobResult").build().toString(), "http://localhost:8080/client/api?response=json&command=queryAsyncJobResult"); } }