URIBuilder b = new URIBuilder("http://example.com"); b.addParameter("t", "search"); b.addParameter("q", "apples"); Url url = b.build().toUrl();
public static String urlWithQuery(String oldUrl, String paramName, String paramValue) throws URISyntaxException { URIBuilder uriBuilder = new URIBuilder(oldUrl); uriBuilder.addParameter(paramName, paramValue); return uriBuilder.toString(); }
public static String addPaginationParam(String url, String paginationParamName, Integer pageNumber) { try { if (pageNumber > 1) { return new URIBuilder(url).addParameter(paginationParamName, String.valueOf(pageNumber)).build().toString(); } } catch (URISyntaxException e) { // If we run into trouble, do nothing - we'll just return the url that we were given. } return url; }
private URI uri(final String path, final Multimap<String, String> query) { checkArgument(path.startsWith("/")); final URIBuilder builder = new URIBuilder() .setScheme("http") .setHost("helios") .setPath(path); for (final Map.Entry<String, String> q : query.entries()) { builder.addParameter(q.getKey(), q.getValue()); } builder.addParameter("user", user); try { return builder.build(); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
public String buildLink(String url, Map<String, String[]> params) { URIBuilder builder; try { builder = new URIBuilder(url); if (params != null) { for (String key : params.keySet()) { String[] paramValues = params.get(key); for (String value : paramValues) { builder.addParameter(key, value); } } } return builder.build().toString(); } catch (URISyntaxException e) { LOG.error("Error creating link for breadcrumb ", e); return url; } }
@Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("response_type", "code"); uriBuilder.addParameter("client_id", clientConfig.getClientId()); uriBuilder.addParameter("scope", Joiner.on(" ").join(clientConfig.getScope())); uriBuilder.addParameter("redirect_uri", redirectUri); uriBuilder.addParameter("nonce", nonce); uriBuilder.addParameter("state", state); // Optional parameters: for (Entry<String, String> option : options.entrySet()) { uriBuilder.addParameter(option.getKey(), option.getValue()); } // if there's a login hint, send it if (!Strings.isNullOrEmpty(loginHint)) { uriBuilder.addParameter("login_hint", loginHint); } return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }
protected String prepareSearchUrl(String type) { URIBuilder url = null; String midUrl = "search/"; try { switch(type) { case "user": midUrl = "profile/"; url = new URIBuilder(this.baseUrl + midUrl + this.query); break; case "question": url = new URIBuilder(this.baseUrl + midUrl); url.addParameter("q", this.query); url.addParameter("type", "question"); break; case "answer": url = new URIBuilder(this.baseUrl + midUrl); url.addParameter("q", this.query); url.addParameter("type", "answer"); break; default: url = new URIBuilder(""); break; } } catch (URISyntaxException e) { DAO.log("Invalid Url: baseUrl = " + this.baseUrl + ", mid-URL = " + midUrl + "query = " + this.query + "type = " + type); } return url.toString(); }
public String getConnectionURI(boolean includeDatabase) throws URISyntaxException { this.setSSLOptions(); URIBuilder uriBuilder = new URIBuilder(); uriBuilder.setScheme("jdbc:mysql"); uriBuilder.setHost(host); uriBuilder.setPort(port); if (database != null && includeDatabase) { uriBuilder.setPath("/" + database); } for (Map.Entry<String, String> jdbcOption : jdbcOptions.entrySet()) { uriBuilder.addParameter(jdbcOption.getKey(), jdbcOption.getValue()); } // added by d8888 2018/09/10, force JDBC to use UTF-8 to support using non-english db, table & column names uriBuilder.addParameter("characterEncoding", "UTF-8"); uriBuilder.addParameter("tinyInt1isBit", "false"); return uriBuilder.build().toString(); }
Object value = param.getValue(); if (value instanceof String) { uriBuilder.addParameter(param.getKey(), (String) value); } else { for (String s : (String[]) value) { uriBuilder.addParameter(param.getKey(), s);
url.addParameter("f", typeMedia); url.addParameter("q", this.query); url.addParameter("vertical", "default"); url.addParameter("src", "typd"); } catch (URISyntaxException e) { DAO.log("Invalid Url: baseUrl = " + this.baseUrl + ", mid-URL = " + midUrl
uriBuilder.addParameter(entry.getKey(), entry.getValue());
protected String prepareSearchUrl(String type) { URIBuilder url = null; String midUrl = "search/"; try { switch (type) { case "search": midUrl = "search/"; url = new URIBuilder(this.baseUrl + midUrl); url.addParameter("search_query", this.query); break; case "video": midUrl = "watch/"; url = new URIBuilder(this.baseUrl + midUrl); url.addParameter("v", this.query); break; case "user": midUrl = "channel/"; url = new URIBuilder(this.baseUrl + midUrl + this.query); break; default: url = new URIBuilder(""); break; } } catch (URISyntaxException e) { DAO.log("Invalid Url: baseUrl = " + this.baseUrl + ", mid-URL = " + midUrl + "query = " + this.query + "type = " + type); return ""; } return url.toString(); }
@Override public IssuerServiceResponse getIssuer(HttpServletRequest request) { // if the issuer is passed in, return that String iss = request.getParameter("iss"); if (!Strings.isNullOrEmpty(iss)) { if (!whitelist.isEmpty() && !whitelist.contains(iss)) { throw new AuthenticationServiceException("Whitelist was nonempty, issuer was not in whitelist: " + iss); } if (blacklist.contains(iss)) { throw new AuthenticationServiceException("Issuer was in blacklist: " + iss); } return new IssuerServiceResponse(iss, request.getParameter("login_hint"), request.getParameter("target_link_uri")); } else { try { // otherwise, need to forward to the account chooser String redirectUri = request.getRequestURL().toString(); URIBuilder builder = new URIBuilder(accountChooserUrl); builder.addParameter("redirect_uri", redirectUri); return new IssuerServiceResponse(builder.build().toString()); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Account Chooser URL is not valid", e); } } }
private static void setLogLevel(final TargetInfo targetInfo, String logName, String level) throws IOException { URIBuilder uriBuilder = new URIBuilder(); uriBuilder.setScheme("http"); uriBuilder.setHost(targetInfo.getHost()); uriBuilder.setPort(targetInfo.getPort()); uriBuilder.setPath(Constants.REST_API_PREFIX + "/" + targetInfo.getRole() + "/" + LOG_LEVEL); uriBuilder.addParameter(LOG_NAME_OPTION_NAME, logName); if (level != null) { uriBuilder.addParameter(LEVEL_OPTION_NAME, level); } HttpUtils.post(uriBuilder.toString(), 5000, new HttpUtils.IProcessInputStream() { @Override public void process(InputStream inputStream) throws IOException { ObjectMapper mapper = new ObjectMapper(); LogInfo logInfo = mapper.readValue(inputStream, LogInfo.class); System.out.println(targetInfo.toString() + logInfo.toString()); } }); }
URI uri = URI.create(redirectURI[0]); URIBuilder uriBuilder = new URIBuilder(uri); uriBuilder.addParameter("error", "access_denied"); uriBuilder.addParameter("error_description", exception.getMessage()); redirectTo = uriBuilder.toString();
+ (Strings.isNullOrEmpty(key.getQuery()) ? "" : "?" + key.getQuery()) ); builder.addParameter("resource", identifier); builder.addParameter("rel", "http://openid.net/specs/connect/1.0/issuer");
URIBuilder uriBuilder = new URIBuilder(url); uriBuilder.addParameter("error", "interaction_required"); if (!Strings.isNullOrEmpty(authRequest.getState())) { uriBuilder.addParameter("state", authRequest.getState()); // copy the state parameter if one was given
.addParameter("user_code", dc.getUserCode()) .build();
uriBuilder.addParameter("request", jwt.serialize());
uriBuilder.addParameter("request", jwt.serialize());