Tuesday, September 29, 2020

Wednesday, September 2, 2020

Two way SSL testing in SOAP UI

create JKS with client and server certificates 
give same storepassword and Keypassword





Caused by: java.security.UnrecoverableKeyException: Cannot recover key

for this error if you are trying in standalone java program keep the storepassword and keypassword same 


and set the java system properties



import java.net.URL;

import java.net.URLConnection;

import java.util.Iterator;


import javax.net.ssl.HttpsURLConnection;

import javax.xml.namespace.QName;

import javax.xml.ws.BindingProvider;

import javax.xml.ws.Service;


import com.sap.document.sap.rfc.functions.PRIMASAPPROVIDERHIGH;

import com.sap.document.sap.rfc.functions.PRIMASAPPROVIDERHIGH_Service;


public class HighTest {


public static void main(String[] a) {

String token = "sapprovider" + ":" + "sapora987";

String encodedStr = "Basic c2FwcHJvdmlkZXI6c2Fwb3JhOTg3";


System.out.println("Basic auth token$$$$$$$$$$$$$$$$$$:" + "Basic " + encodedStr);


try {

System.setProperty("javax.net.debug", "ssl");

System.setProperty("javax.net.ssl.keyStore", "D:\\clientsep2.jks");

System.setProperty("javax.net.ssl.keyStorePassword", "sep2pass");    // same as key password

System.setProperty("javax.net.ssl.trustStore", "D:\\clientsep2.jks");

System.setProperty("javax.net.ssl.trustStorePassword", "sep2pass");


URL wsdlprimahigh = new URL(

"https://bchsap009.bcone.com:1443/sap/bc/srt/wsdl/flv_10002A111AD1/srvc_url/sap/bc/srt/rfc/prima/sapprovider_high/001/prima_sapprovider_high/prima_sapprovider_high?sap-client=001");


PRIMASAPPROVIDERHIGH_Service service = new PRIMASAPPROVIDERHIGH_Service(wsdlprimahigh,

new QName("urn:sap-com:document:sap:rfc:functions", "prima_sapprovider_high"));

BindingProvider bp = (BindingProvider) service.getPort(PRIMASAPPROVIDERHIGH.class);


 

String getEndpointReference = bp.getEndpointReference().toString();


int startIndex = getEndpointReference.indexOf("<Address>");

int endIndex = getEndpointReference.indexOf("</Address>", startIndex);


String endpoint = getEndpointReference.substring(startIndex + "<Address>".length(), endIndex);


System.out.println("endpoint -----------" + endpoint);



  //Using Javax.xml.ws.Service directly from Java instead of creating client from wsimport or JAX-WS 

  Service service1 = Service.create(wsdlprimahigh, new

  QName("urn:sap-com:document:sap:rfc:functions", "prima_sapprovider_high"));

  BindingProvider bp1 = (BindingProvider) service1.getPort(ServicePortPrimaHigh.class);

  

  getEndpointReference = bp.getEndpointReference().toString();


startIndex = getEndpointReference.indexOf("<Address>");

endIndex = getEndpointReference.indexOf("</Address>", startIndex);


endpoint = getEndpointReference.substring(startIndex + "<Address>".length(), endIndex);


System.out.println("endpoint -------in java service----" + endpoint);

  

  

} catch (Exception ex) {

System.out.println("exxxxxxxxxxxxxxxxxxxxxx:::::::");

ex.printStackTrace();

}

}

}