Hii,
I am a newbie in java networking.
My problem is, i hv no idea how to generate the pkcs#7formatted signature string within the following code.
My digital signature is imprinted in an e-token.


I am providing the following java code which is used for the connection.

The signature (which is to be generated in pkcs#7 format for a certificate) is hard coded here and the "String ip" is an example I.P. to give u an idea of what I need.




.............
...................
..........................

public static void main(String[] args) {



SSLContext sslcontext = null;
try {
sslcontext = SSLContext.getInstance("SSL");

sslcontext.init(new KeyManager[0],
new TrustManager[] { new DummyTrustManager() },
new SecureRandom());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace(System.err);
} catch (KeyManagementException e) {
e.printStackTrace(System.err);
}

SSLSocketFactory factory = sslcontext.getSocketFactory();

String data="V00501^adsdsfff";
String signature="MIIHvQYJKoZIhvcNAQcCoIIHrjCCB6oCAQExCzA JBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCBaUwggWhMIIEiaADA gECAgI1qDANBgkqhkiG9w0BAQUFADCB0zEk=";
String urlParameters="data=";
try{

urlParameters =urlParameters + URLEncoder.encode(data, "UTF-8") +"&signature=" + URLEncoder.encode(signature, "UTF-8");
}catch(Exception e){

e.printStackTrace();

}

try{
URL url;
HttpsURLConnection connection;
InputStream is = null;


//------------------------


String ip="45.168.64.6";
url = new URL("https://" + ip + "/MIN/BackEnd");
System.out.println("URL "+ip);

connection = (HttpsURLConnection) url.openConnection();

connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");


connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length)) ;
connection.setRequestProperty("Content-Language", "en-US");

connection.setUseCaches (false);
connection.setDoInput(true);
connection.setDoOutput(true);

connection.setSSLSocketFactory(factory);
connection.setHostnameVerifier(new DummyHostnameVerifier());




OutputStream os = connection.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
osw.write(urlParameters);
osw.flush();
osw.close();




is =connection.getInputStream();

BufferedReader in = new BufferedReader(new InputStreamReader(is));

String line = in.readLine();

System.out.println("Output "+line);
is.close();
in.close();

} catch(Exception e){
e.printStackTrace();
}
}

...........
..................



Any kind of sugggestions and helps in this regard are most welcome.

Thanking you all.........looking forward to a solution very soon.