Methods Summary |
---|
private javax.crypto.KeyGenerator | createKeyGenerator(java.lang.String algName, java.security.Provider provider)
if (provider != null)
{
return KeyGenerator.getInstance(algName, provider);
}
else
{
return KeyGenerator.getInstance(algName);
}
|
protected javax.crypto.KeyGenerator | createSymmetricKeyGenerator(java.lang.String encryptionOID, java.security.Provider provider)
try
{
return createKeyGenerator(encryptionOID, provider);
}
catch (NoSuchAlgorithmException e)
{
try
{
String algName = (String)BASE_CIPHER_NAMES.get(encryptionOID);
if (algName != null)
{
return createKeyGenerator(algName, provider);
}
}
catch (NoSuchAlgorithmException ex)
{
// ignore
}
if (provider != null)
{
return createSymmetricKeyGenerator(encryptionOID, null);
}
throw e;
}
|
private void | extractHeaders(javax.mail.internet.MimeBodyPart content, javax.mail.internet.MimeMessage message)
Enumeration e = message.getAllHeaders();
while (e.hasMoreElements())
{
Header hdr =(Header)e.nextElement();
content.setHeader(hdr.getName(), hdr.getValue());
}
|
protected javax.mail.internet.MimeBodyPart | makeContentBodyPart(javax.mail.internet.MimeBodyPart content)Make sure we have a valid content body part - setting the headers
with defaults if neccessary.
//
// add the headers to the body part - if they are missing, in
// the event they have already been set the content settings override
// any defaults that might be set.
//
try
{
MimeMessage msg = new MimeMessage((Session)null);
Enumeration e = content.getAllHeaders();
msg.setDataHandler(content.getDataHandler());
while (e.hasMoreElements())
{
Header hdr =(Header)e.nextElement();
msg.setHeader(hdr.getName(), hdr.getValue());
}
msg.saveChanges();
//
// we do this to make sure at least the default headers are
// set in the body part.
//
e = msg.getAllHeaders();
while (e.hasMoreElements())
{
Header hdr =(Header)e.nextElement();
if (Strings.toLowerCase(hdr.getName()).startsWith("content-"))
{
content.setHeader(hdr.getName(), hdr.getValue());
}
}
}
catch (MessagingException e)
{
throw new SMIMEException("exception saving message state.", e);
}
return content;
|
protected javax.mail.internet.MimeBodyPart | makeContentBodyPart(javax.mail.internet.MimeMessage message)extract an appropriate body part from the passed in MimeMessage
MimeBodyPart content = new MimeBodyPart();
//
// add the headers to the body part.
//
try
{
message.removeHeader("Message-Id");
message.removeHeader("Mime-Version");
// JavaMail has a habit of reparsing some content types, if the bodypart is
// a multipart it might be signed, we rebuild the body part using the raw input stream for the message.
try
{
if (message.getContent() instanceof Multipart)
{
content.setContent(message.getRawInputStream(), message.getContentType());
extractHeaders(content, message);
return content;
}
}
catch (MessagingException e)
{
// fall back to usual method below
}
content.setContent(message.getContent(), message.getContentType());
extractHeaders(content, message);
}
catch (MessagingException e)
{
throw new SMIMEException("exception saving message state.", e);
}
catch (IOException e)
{
throw new SMIMEException("exception getting message content.", e);
}
return content;
|
public void | setContentTransferEncoding(java.lang.String encoding)set the content-transfer-encoding for the signature.
this.encoding = encoding;
this.useBase64 = Strings.toLowerCase(encoding).equals("base64");
|