System.err.println("Generating the message failed.");
me.printStackTrace();
return null;
}
PGPSignedMessage message=null;
//**********************************************************************
// Sign the message.
//**********************************************************************
try {
SignedMessageBuilder smb =
SignedMessageBuilder.getInstance("OpenPGP");
smb.init(msg);
smb.addSigner(secretKey, passpharse);
message = (PGPSignedMessage)smb.build();
} catch (NoSuchAlgorithmException nsae) {
System.err.println("Cannot find the OpenPGP SignedMessageBuilder. "+
"This usually means that the Cryptix OpenPGP provider is not "+
"installed correctly.");
nsae.printStackTrace();
return null;
} catch (UnrecoverableKeyException uke) {
System.err.println("Incorrect passphrase.");
uke.printStackTrace();
return null;
} catch (MessageException me) {
System.err.println("Generating the message failed.");
me.printStackTrace();
return null;
}
//**********************************************************************
// Armour the message.
//**********************************************************************
try{
return PGPArmoury.armour(message.getDetachedSignature().getEncoded());
} catch (MessageException me) {
System.err.println("Writing the message failed.");
me.printStackTrace();
return null;
}