List of usage examples for org.apache.http.client.utils URIBuilder build
public URI build() throws URISyntaxException
From source file:org.ovirt.engine.sdk4.internal.SsoUtils.java
/** * Construct SSO URL to obtain token from kerberos authentication. * * @param url oVirt engine URL//from w w w . ja va 2s. co m * @return URI to be used to obtain token */ public static URI buildSsoUrlKerberos(String url) { try { URI uri = new URI(url); URIBuilder uriBuilder = new URIBuilder(String.format("%1$s://%2$s/ovirt-engine/sso/oauth/%3$s", uri.getScheme(), uri.getAuthority(), ENTRY_POINT_HTTP)); return uriBuilder.build(); } catch (URISyntaxException ex) { throw new Error("Failed to build SSO authentication URL", ex); } }
From source file:org.ovirt.engine.sdk4.internal.SsoUtils.java
/** * Construct SSO URL to obtain token from username and password. * * @param url oVirt engine URL// w w w .j a v a 2s . c o m * @return URI to be used to obtain token */ public static URI buildSsoUrlBasic(String url) { try { URI uri = new URI(url); URIBuilder uriBuilder = new URIBuilder(String.format("%1$s://%2$s/ovirt-engine/sso/oauth/%3$s", uri.getScheme(), uri.getAuthority(), ENTRY_POINT_TOKEN)); return uriBuilder.build(); } catch (URISyntaxException ex) { throw new Error("Failed to build SSO authentication URL", ex); } }
From source file:com.jkoolcloud.tnt4j.streams.fields.ActivityCacheTest.java
private static URI makeURI() { try {//w w w. j ava 2 s . c om URIBuilder uriBuilder = new URIBuilder("http://localhost"); // NON-NLS uriBuilder.setHost("localhost"); // NON-NLS uriBuilder.setPort(TEST_PORT); URI url = uriBuilder.build(); return url; } catch (Exception e) { return null; } }
From source file:com.vmware.identity.openidconnect.protocol.URIUtils.java
public static URI changePathComponent(URI uri, String path) { Validate.notNull(uri, "uri"); Validate.notEmpty(path, "path"); URIBuilder uriBuilder = new URIBuilder(uri); uriBuilder.setPath(path);/*from ww w .ja v a 2 s . co m*/ try { return uriBuilder.build(); } catch (URISyntaxException e) { throw new IllegalArgumentException("failed to change uri path component", e); } }
From source file:com.vmware.identity.openidconnect.protocol.URIUtils.java
public static URI changeHostComponent(URI uri, String host) { Validate.notNull(uri, "uri"); Validate.notEmpty(host, "host"); URIBuilder uriBuilder = new URIBuilder(uri); uriBuilder.setHost(host);// ww w .j ava 2 s .co m try { return uriBuilder.build(); } catch (URISyntaxException e) { throw new IllegalArgumentException("failed to change uri host component", e); } }
From source file:xyz.cloudbans.client.DefaultClient.java
private static URI buildSafe(URIBuilder builder) { try {/*from w ww . j a v a 2s. c o m*/ return builder.build(); } catch (URISyntaxException e) { throw new RuntimeException("Error occurred while building URI", e); } }
From source file:com.vmware.identity.openidconnect.protocol.URIUtils.java
public static URI changeSchemeComponent(URI uri, String scheme) { Validate.notNull(uri, "uri"); Validate.notEmpty(scheme, "scheme"); URIBuilder uriBuilder = new URIBuilder(uri); uriBuilder.setScheme(scheme);/* ww w.j av a 2s. c o m*/ try { return uriBuilder.build(); } catch (URISyntaxException e) { throw new IllegalArgumentException("failed to change uri scheme component", e); } }
From source file:com.vmware.identity.openidconnect.protocol.URIUtils.java
public static URI appendQueryParameters(URI uri, Map<String, String> parameters) { Validate.notNull(uri, "uri"); Validate.notNull(parameters, "parameters"); List<NameValuePair> pairs = new ArrayList<NameValuePair>(parameters.size()); for (Map.Entry<String, String> entry : parameters.entrySet()) { pairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); }//ww w.j a v a 2s.c om URIBuilder uriBuilder = new URIBuilder(uri); uriBuilder.addParameters(pairs); try { return uriBuilder.build(); } catch (URISyntaxException e) { throw new IllegalArgumentException("failed to add parameters to uri", e); } }
From source file:tech.sirwellington.alchemy.http.AlchemyRequestMapper.java
@Internal static URL expandUrlFromRequest(@Required HttpRequest request) throws URISyntaxException, MalformedURLException { checkThat(request).is(notNullAndHasURL()); if (!request.hasQueryParams()) { return request.getUrl(); } else {/*from w w w . ja v a 2 s . c o m*/ URI uri = request.getUrl().toURI(); URIBuilder uriBuilder = new URIBuilder(uri); request.getQueryParams().forEach(uriBuilder::addParameter); return uriBuilder.build().toURL(); } }
From source file:org.fao.geonet.harvester.wfsfeatures.worker.OwsUtils.java
public static String getGetCapabilitiesUrl(final String wfsUrl, final String version) throws Exception { URIBuilder builder = new URIBuilder(wfsUrl); builder.addParameter("request", "GetCapabilities"); builder.addParameter("service", "WFS"); builder.addParameter("version", version); String url = builder.build().toURL().toString(); return url;//from ww w . j av a 2 s .co m }