示例#1
0
  /**
   * Legacy URI parser. Used in parsing template from provider.xml Example string:
   * "eas+ssl+trustallcerts://user:password@server/domain:123"
   *
   * <p>Note that the use of client certificate is specified in the URI, a secure connection type
   * must be used.
   */
  public static void setHostAuthFromString(HostAuth auth, String uriString)
      throws URISyntaxException {
    URI uri = new URI(uriString);
    String path = uri.getPath();
    String domain = null;
    if (!TextUtils.isEmpty(path)) {
      // Strip off the leading slash that begins the path.
      domain = path.substring(1);
    }
    auth.mDomain = domain;
    auth.setLogin(uri.getUserInfo());

    String scheme = uri.getScheme();
    auth.setConnection(scheme, uri.getHost(), uri.getPort());
  }
示例#2
0
  /** Legacy code for setting connection values from a "scheme" (see above) */
  public void setConnection(String scheme, String host, int port) {
    String[] schemeParts = scheme.split("\\+");
    String protocol = schemeParts[0];
    String clientCertAlias = null;
    int flags = getSchemeFlags(scheme);

    // Example scheme: "eas+ssl+trustallcerts" or "eas+tls+trustallcerts+client-cert-alias"
    if (schemeParts.length > 3) {
      clientCertAlias = schemeParts[3];
    } else if (schemeParts.length > 2) {
      if (!SCHEME_TRUST_ALL_CERTS.equals(schemeParts[2])) {
        mClientCertAlias = schemeParts[2];
      }
    }

    setConnection(protocol, host, port, flags, clientCertAlias);
  }
示例#3
0
 public void setConnection(String protocol, String address, int port, int flags) {
   setConnection(protocol, address, port, flags, null);
 }