org.apache.http.client.utils.URIBuilder.getUserInfo()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.apache.http.client.utils.URIBuilder.getUserInfo()方法的一些代码示例,展示了URIBuilder.getUserInfo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URIBuilder.getUserInfo()方法的具体详情如下:
包路径:org.apache.http.client.utils.URIBuilder
类名称:URIBuilder
方法名:getUserInfo

URIBuilder.getUserInfo介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.kapua/kapua-simulator-kura

protected MqttConnectOptions createConnectOptions(final String brokerUrl) {
  try {
    final URIBuilder u = new URIBuilder(brokerUrl);
    final MqttConnectOptions result = new MqttConnectOptions();
    result.setAutomaticReconnect(true);
    final String ui = u.getUserInfo();
    if (ui != null && !ui.isEmpty()) {
      final String[] toks = ui.split("\\:", 2);
      if (toks.length == 2) {
        result.setUserName(toks[0]);
        result.setPassword(toks[1].toCharArray());
      }
    }
    return result;
  } catch (final URISyntaxException e) {
    throw new RuntimeException("Failed to create MQTT options", e);
  }
}

代码示例来源:origin: eclipse/kapua

protected MqttConnectOptions createConnectOptions(final String brokerUrl) {
  try {
    final URIBuilder u = new URIBuilder(brokerUrl);
    final MqttConnectOptions result = new MqttConnectOptions();
    result.setAutomaticReconnect(true);
    final String ui = u.getUserInfo();
    if (ui != null && !ui.isEmpty()) {
      final String[] toks = ui.split("\\:", 2);
      if (toks.length == 2) {
        result.setUserName(toks[0]);
        result.setPassword(toks[1].toCharArray());
      }
    }
    return result;
  } catch (final URISyntaxException e) {
    throw new RuntimeException("Failed to create MQTT options", e);
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * A convenience method that creates a new {@link URI} whose scheme, host, port, path,
 * query are taken from the existing URI, dropping any fragment or user-information.
 * The path is set to "/" if not explicitly specified. The existing URI is returned
 * unmodified if it has no fragment or user-information and has a path.
 *
 * @param uri
 *            original URI.
 * @throws URISyntaxException
 *             If the resulting URI is invalid.
 */
public static URI rewriteURI(final URI uri) throws URISyntaxException {
  Args.notNull(uri, "URI");
  if (uri.isOpaque()) {
    return uri;
  }
  final URIBuilder uribuilder = new URIBuilder(uri);
  if (uribuilder.getUserInfo() != null) {
    uribuilder.setUserInfo(null);
  }
  if (TextUtils.isEmpty(uribuilder.getPath())) {
    uribuilder.setPath("/");
  }
  if (uribuilder.getHost() != null) {
    uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT));
  }
  uribuilder.setFragment(null);
  return uribuilder.build();
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

/**
 * A convenience method that creates a new {@link URI} whose scheme, host, port, path,
 * query are taken from the existing URI, dropping any fragment or user-information.
 * The path is set to "/" if not explicitly specified. The existing URI is returned
 * unmodified if it has no fragment or user-information and has a path.
 *
 * @param uri
 *            original URI.
 * @throws URISyntaxException
 *             If the resulting URI is invalid.
 */
public static URI rewriteURI(final URI uri) throws URISyntaxException {
  Args.notNull(uri, "URI");
  if (uri.isOpaque()) {
    return uri;
  }
  final URIBuilder uribuilder = new URIBuilder(uri);
  if (uribuilder.getUserInfo() != null) {
    uribuilder.setUserInfo(null);
  }
  if (TextUtils.isEmpty(uribuilder.getPath())) {
    uribuilder.setPath("/");
  }
  if (uribuilder.getHost() != null) {
    uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ENGLISH));
  }
  uribuilder.setFragment(null);
  return uribuilder.build();
}

代码示例来源:origin: Nextdoor/bender

/**
 * A convenience method that creates a new {@link URI} whose scheme, host, port, path,
 * query are taken from the existing URI, dropping any fragment or user-information.
 * The path is set to "/" if not explicitly specified. The existing URI is returned
 * unmodified if it has no fragment or user-information and has a path.
 *
 * @param uri
 *            original URI.
 * @throws URISyntaxException
 *             If the resulting URI is invalid.
 */
public static URI rewriteURI(final URI uri) throws URISyntaxException {
  Args.notNull(uri, "URI");
  if (uri.isOpaque()) {
    return uri;
  }
  final URIBuilder uribuilder = new URIBuilder(uri);
  if (uribuilder.getUserInfo() != null) {
    uribuilder.setUserInfo(null);
  }
  if (TextUtils.isEmpty(uribuilder.getPath())) {
    uribuilder.setPath("/");
  }
  if (uribuilder.getHost() != null) {
    uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT));
  }
  uribuilder.setFragment(null);
  return uribuilder.build();
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * A convenience method that creates a new {@link URI} whose scheme, host, port, path,
 * query are taken from the existing URI, dropping any fragment or user-information.
 * The path is set to "/" if not explicitly specified. The existing URI is returned
 * unmodified if it has no fragment or user-information and has a path.
 *
 * @param uri
 *            original URI.
 * @throws URISyntaxException
 *             If the resulting URI is invalid.
 */
public static URI rewriteURI(final URI uri) throws URISyntaxException {
  Args.notNull(uri, "URI");
  if (uri.isOpaque()) {
    return uri;
  }
  final URIBuilder uribuilder = new URIBuilder(uri);
  if (uribuilder.getUserInfo() != null) {
    uribuilder.setUserInfo(null);
  }
  if (TextUtils.isEmpty(uribuilder.getPath())) {
    uribuilder.setPath("/");
  }
  if (uribuilder.getHost() != null) {
    uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT));
  }
  uribuilder.setFragment(null);
  return uribuilder.build();
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * A convenience method that creates a new {@link URI} whose scheme, host, port, path,
 * query are taken from the existing URI, dropping any fragment or user-information.
 * The path is set to "/" if not explicitly specified. The existing URI is returned
 * unmodified if it has no fragment or user-information and has a path.
 *
 * @param uri
 *            original URI.
 * @throws URISyntaxException
 *             If the resulting URI is invalid.
 */
public static URI rewriteURI(final URI uri) throws URISyntaxException {
  Args.notNull(uri, "URI");
  if (uri.isOpaque()) {
    return uri;
  }
  final URIBuilder uribuilder = new URIBuilder(uri);
  if (uribuilder.getUserInfo() != null) {
    uribuilder.setUserInfo(null);
  }
  if (TextUtils.isEmpty(uribuilder.getPath())) {
    uribuilder.setPath("/");
  }
  if (uribuilder.getHost() != null) {
    uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT));
  }
  uribuilder.setFragment(null);
  return uribuilder.build();
}

代码示例来源:origin: org.apache.httpcomponents/httpclient-android

/**
 * A convenience method that creates a new {@link URI} whose scheme, host, port, path,
 * query are taken from the existing URI, dropping any fragment or user-information.
 * The path is set to "/" if not explicitly specified. The existing URI is returned
 * unmodified if it has no fragment or user-information and has a path.
 *
 * @param uri
 *            original URI.
 * @throws URISyntaxException
 *             If the resulting URI is invalid.
 */
public static URI rewriteURI(final URI uri) throws URISyntaxException {
  Args.notNull(uri, "URI");
  if (uri.isOpaque()) {
    return uri;
  }
  final URIBuilder uribuilder = new URIBuilder(uri);
  if (uribuilder.getUserInfo() != null) {
    uribuilder.setUserInfo(null);
  }
  if (TextUtils.isEmpty(uribuilder.getPath())) {
    uribuilder.setPath("/");
  }
  if (uribuilder.getHost() != null) {
    uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ENGLISH));
  }
  uribuilder.setFragment(null);
  return uribuilder.build();
}

代码示例来源:origin: com.hynnet/httpclient

/**
 * A convenience method that creates a new {@link URI} whose scheme, host, port, path,
 * query are taken from the existing URI, dropping any fragment or user-information.
 * The path is set to "/" if not explicitly specified. The existing URI is returned
 * unmodified if it has no fragment or user-information and has a path.
 *
 * @param uri
 *            original URI.
 * @throws URISyntaxException
 *             If the resulting URI is invalid.
 */
public static URI rewriteURI(final URI uri) throws URISyntaxException {
  Args.notNull(uri, "URI");
  if (uri.isOpaque()) {
    return uri;
  }
  final URIBuilder uribuilder = new URIBuilder(uri);
  if (uribuilder.getUserInfo() != null) {
    uribuilder.setUserInfo(null);
  }
  if (TextUtils.isEmpty(uribuilder.getPath())) {
    uribuilder.setPath("/");
  }
  if (uribuilder.getHost() != null) {
    uribuilder.setHost(uribuilder.getHost().toLowerCase(Locale.ROOT));
  }
  uribuilder.setFragment(null);
  return uribuilder.build();
}

相关文章