
***********************************************************************************************************************
public String SendReceive(String pathURL) throws IOException,
      KeyManagementException, NoSuchAlgorithmException
  {
  String headerFieldKeys = "", headerFieldValues = "", content = "";
  try
  {
      // Create a URL for the desired page
      Vector tokenizedURL = tokenizePostURL(pathURL);
      if (tokenizedURL == null ||
          ( (String) tokenizedURL.elementAt(0)).equals(""))
        throw new IOException(
            "Bad URL in post method simulator when trying to connect to merchant site. Requested URL : " +
            pathURL);
      URL url = new URL(pathURL);
      TrustManager[] trustAllCerts = new TrustManager[]
      {
          new X509TrustManager()
          {
             public java.security.cert.X509Certificate[] getAcceptedIssuers()
             {
                return null;
             }
             public void
checkClientTrusted(java.security.cert.X509Certificate[] certs, String
authType)
             {
             }
             public void
checkServerTrusted(java.security.cert.X509Certificate[] certs, String
authType)
             {
             }
          }
      } ;
// Install the all-trusting trust manager // When you do this, you mean that you trust to certs. In our system it makes no problem!

      SSLContext sc = SSLContext.getInstance("SSL");
      sc.init(null, trustAllCerts, new java.security.SecureRandom());
      HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

// We override this method to ignor the warnings of HostNameVerifier action.
      javax.net.ssl.HostnameVerifier hv = new javax.net.ssl.HostnameVerifier()
      {
        public boolean verify(String urlHostname, SSLSession ssls)
        {
          System.out.println("WARNING: Hostname is not matched for cert.");
          return true;
        }
      };

      javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(hv);

      HttpsURLConnection https_conn = (HttpsURLConnection) url.openConnection();

      https_conn.setRequestMethod("POST");
      https_conn.setRequestProperty("Content-type", "text/plain");
      https_conn.setDoOutput(true);
      https_conn.setDoInput(true);
      https_conn.setUseCaches(false);
      OutputStreamWriter out = new
OutputStreamWriter(https_conn.getOutputStream());
      out.flush();
      out.close();

      // Read all the text returned by the server
      BufferedReader in = new BufferedReader(new InputStreamReader(https_conn.
          getInputStream()));
      String str;
      while ( (str = in.readLine()) != null)
      {
        content += str;
      }
      in.close();
    }
    catch (MalformedURLException e) {
      throw new IOException(
          "Exception in communicating with merchant in URL Simulator because of : \n" +
          e.getLocalizedMessage());
    }
    catch (IOException e) {
      throw new IOException(
          "Exception in communicating with merchant in URL Simulator because of : \n" +
          e.getLocalizedMessage());
    }
    return content;
  }
***********************************************************************************************************************


