Class SMIMEUtil

java.lang.Object
org.bouncycastle.mail.smime.SMIMEUtil

public class SMIMEUtil extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Interface to obfuscate the repetitive constructors so that we could have only one createSafe
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bouncycastle.asn1.cms.IssuerAndSerialNumber
    Return a CMS IssuerAndSerialNumber structure for the passed in X.509 certificate.
    static Object
    If getInputStreamNoMultipartSigned returns PipedInputStream it will lead to resource leak as it will not be closed if not handled safely.
    static int
    Depth of nested multipart content the canonicalisers will descend, from Properties.MIME_MAX_DEPTH - the MIME analogue of the ASN.1 codec's nesting cap.
    static boolean
    isMultipartContent(javax.mail.Part part)
     
    static javax.mail.internet.MimeBodyPart
    toMimeBodyPart(byte[] content)
    return the MimeBodyPart described in the raw bytes provided in content
    static javax.mail.internet.MimeBodyPart
    return the MimeBodyPart described in the input stream content
    toMimeBodyPart(org.bouncycastle.cms.CMSTypedStream content)
    return a file backed MimeBodyPart described in CMSTypedStream content.
    toMimeBodyPart(org.bouncycastle.cms.CMSTypedStream content, File file)
    Return a file based MimeBodyPart represented by content and backed by the file represented by file.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SMIMEUtil

      public SMIMEUtil()
  • Method Details

    • getMaxDepth

      public static int getMaxDepth()
      Depth of nested multipart content the canonicalisers will descend, from Properties.MIME_MAX_DEPTH - the MIME analogue of the ASN.1 codec's nesting cap. Public so the multipart/signed content handler, in a sub-package, applies the same bound to its own recursion over the same content rather than carrying a second default.
      Returns:
      the maximum nesting depth, never negative.
    • isMultipartContent

      public static boolean isMultipartContent(javax.mail.Part part) throws javax.mail.MessagingException
      Throws:
      javax.mail.MessagingException
    • toMimeBodyPart

      public static javax.mail.internet.MimeBodyPart toMimeBodyPart(byte[] content) throws SMIMEException
      return the MimeBodyPart described in the raw bytes provided in content
      Throws:
      SMIMEException
    • toMimeBodyPart

      public static javax.mail.internet.MimeBodyPart toMimeBodyPart(InputStream content) throws SMIMEException
      return the MimeBodyPart described in the input stream content
      Throws:
      SMIMEException
    • toMimeBodyPart

      public static FileBackedMimeBodyPart toMimeBodyPart(org.bouncycastle.cms.CMSTypedStream content) throws SMIMEException
      return a file backed MimeBodyPart described in CMSTypedStream content.
      Throws:
      SMIMEException
    • toMimeBodyPart

      public static FileBackedMimeBodyPart toMimeBodyPart(org.bouncycastle.cms.CMSTypedStream content, File file) throws SMIMEException
      Return a file based MimeBodyPart represented by content and backed by the file represented by file.
      Parameters:
      content - content stream containing body part.
      file - file to store the decoded body part in.
      Returns:
      the decoded body part.
      Throws:
      SMIMEException
    • createIssuerAndSerialNumberFor

      public static org.bouncycastle.asn1.cms.IssuerAndSerialNumber createIssuerAndSerialNumberFor(X509Certificate cert) throws CertificateParsingException
      Return a CMS IssuerAndSerialNumber structure for the passed in X.509 certificate.
      Parameters:
      cert - the X.509 certificate to get the issuer and serial number for.
      Returns:
      an IssuerAndSerialNumber structure representing the certificate.
      Throws:
      CertificateParsingException
    • createSafe

      public static Object createSafe(InputStream sigStream, SMIMEUtil.SafeCreator creator) throws javax.mail.MessagingException, org.bouncycastle.cms.CMSException
      If getInputStreamNoMultipartSigned returns PipedInputStream it will lead to resource leak as it will not be closed if not handled safely. This method will initiate SMIMESigned but if it fails, it will close PipedInputStream
      Throws:
      javax.mail.MessagingException - an error extracting the signature or otherwise processing the message.
      org.bouncycastle.cms.CMSException - if some other problem occurs.