there is no standard API in Java for handling PKCS#7. you have to use a
proprietary API for this purpose.
you may have a look at our IAIK-JCE toolkit. for non-commercial use it is
for free. commercial licenses are available.
you can get an evaluation copy from
http://jce.iaik.tugraz.at/download/evaluation/index.php (first register for
free).
a piece of code creating a SignedData as you need it would look something
like this:
byte[] data = ...;
SignedData signedData = new SignedData(data, SignedData.IMPLICIT);
signedData.setCertificates(new X509Certificate[] { signerCertificate } );
IssuerAndSerialNumber signerIssuerAndSerialNumber = new
IssuerAndSerialNumber(signerCertificate);
SignerInfo signerInfo = new SignerInfo(signerIssuerAndSerialNumber,
AlgorithmID.sha1, signatureKey);
signedData.addSignerInfo(signerInfo);
byte[] encoding = signedData.getEncoded();
regards
Karl Scheibelhofer
--
Karl Scheibelhofer, IAIK - Graz University of Technology
Inffeldgasse 16a, 8010 Graz, Austria
Fax: +43 316 873 5520
http://jce.iaik.tugraz.at/
Visit us at the RSA conference in San Francisco, 14-18 Feb 2005, booth 438
> Can somebody help me? I need to encrypt XML data in PKCS#7 format (version
> 1.5) with .pk7 or another certificate. I want to use java but i m truly
> newbie. PKCS7 must include signed data and certificate of signer,type of
> object is "signedData". After encoding data i want to send it to a remote
> server by using https (post). Thanks for your help!