我尝试在Java上为Jira创建自定义邮件处理程序,如果该消息具有签名,则必须验证消息的数字签名。但是我不知道该怎么做。
我有javax.mail.Message message
,如何检查它是否具有签名?
如果消息具有签名以验证这一点,据我所知,我必须像这样:
//create a Signature instance
Signature signature = Signature.getInstance("SHA256withRSA");
//initialize the Signature object for verification which takes a public key
signature.initVerify(publicKey);
//add the received message bytes to the signature object
String body = MailUtils.getBody(message);
byte[] messageBytes = body.getBytes();
signature.update(messageBytes);
//And finally, check the signature
boolean isCorrect = signature.verify(receivedSignature);
但是如何从收到的javax.mail.Message消息中获取算法,publicKey和receiveSignature?