[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: [iaik-jce] verify() a SignedContent create aNullPointerException



May you provide whole the source sample (and a stack trace output)?

Regards,
Dieter Bratko

-----Ursprüngliche Nachricht-----
Von: iaik-jce-owner@iaik.tu-graz.ac.at
[mailto:iaik-jce-owner@iaik.tu-graz.ac.at]Im Auftrag von Sven Noack
Gesendet: Freitag, 20. Oktober 2000 12:26
An: iaik-jce@iaik.tu-graz.ac.at
Betreff: [iaik-jce] verify() a SignedContent create
aNullPointerException




Hi!

I have a problem...

I create a function in Java wich get a MimeMessage, encrypt and sign this
Message and give back the MimeMessage.

How can I encrypt this Message if it contains only a String? I've tried the
following:

public MimeMessage encrypt(MimeMessage msg)
{
...
Object _content = msg.getDataHandler().getContent();
sc = new SignedContent(false, SignedContent.SIGNED_DATA);

if(_content instanceof MimeMultipart)
{
MimeMultipart sMultipart = new SMimeMultipart();
sMultipart = (SMimeMultipart)_content;
sc.setContent(sMultipart);
multipart = true;
}
else if(_content instanceof String)
{
sc.setText((String)_content);
}
...
sc.setCertificates(signerCertChain);
sc.setSigner((RSAPrivateKey)myPrivateKey,signerCertChain[0]);
...
EncryptedContent ec = new EncryptedContent(sc);
ec.addRecipient(cert, AlgorithmID.rsaEncryption);
...
msg.setContent(ec, ec.getContentType());
ec.setHeaders(msg);
...
return msg;
}

So long so good... But the Problem is to decrypt and verify this Message in
an other function.
How can I do that? I try ...

String _content = (String)sc.getContent();
msg.setText(_content);

... but the ...

signer = sc.verify();

creates a java.lang.NullPointerException.

If I try to create a MimeMultipart Message in place of the
sc.setText(String)_content) in encrypt(msg){...}, for instance:

sc = new SignedContent(false);

MimeMultipart sMultipart = new SMimeMultipart();
MimeBodyPart mbp = new SMimeBodyPart();

mbp.setText((String)_content);

sMultipart.addBodyPart(mbp);

sc.setContent(sMultipart);

... I get the NullPointerException again.

I hope someone can help me.

Sorry for my poor English.

Bye

Sven



--
Mailinglist-archive at
http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content:
UNSUBSCRIBE iaik-jce



--
Mailinglist-archive at
http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content:
UNSUBSCRIBE iaik-jce