コード例 #1
0
  protected void callHttp() throws IOException {

    if ("POST".equals(this.method.toUpperCase())) {
      String url = HttpClientUtil.getURL(this.reqContent);
      String queryString = HttpClientUtil.getQueryString(this.reqContent);
      byte[] postData = queryString.getBytes(this.charset);
      this.httpPostMethod(url, postData);

      return;
    }

    this.httpGetMethod(this.reqContent);
  }
コード例 #2
0
  protected void callHttps()
      throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException,
          UnrecoverableKeyException, KeyManagementException {

    // caĿ¼
    String caPath = this.caFile.getParent();

    File jksCAFile = new File(caPath + "/" + TenpayHttpClient.JKS_CA_FILENAME);
    if (!jksCAFile.isFile()) {
      X509Certificate cert = (X509Certificate) HttpClientUtil.getCertificate(this.caFile);

      FileOutputStream out = new FileOutputStream(jksCAFile);

      // store jks file
      HttpClientUtil.storeCACert(
          cert, TenpayHttpClient.JKS_CA_ALIAS, TenpayHttpClient.JKS_CA_PASSWORD, out);

      out.close();
    }

    FileInputStream trustStream = new FileInputStream(jksCAFile);
    FileInputStream keyStream = new FileInputStream(this.certFile);

    SSLContext sslContext =
        HttpClientUtil.getSSLContext(
            trustStream, TenpayHttpClient.JKS_CA_PASSWORD, keyStream, this.certPasswd);

    // �ر���
    keyStream.close();
    trustStream.close();

    if ("POST".equals(this.method.toUpperCase())) {
      String url = HttpClientUtil.getURL(this.reqContent);
      String queryString = HttpClientUtil.getQueryString(this.reqContent);
      byte[] postData = queryString.getBytes(this.charset);

      this.httpsPostMethod(url, postData, sslContext);

      return;
    }

    this.httpsGetMethod(this.reqContent, sslContext);
  }