class CryptoContainer {

    @WorkerThread
    public static CryptoContainer encrypt(ImmutableList<File> dataFiles,
                                          ImmutableList<Certificate> recipients, File file)
            throws CryptoException {
        try {
            CDOCBuilder builder = CDOCBuilder.defaultVersion();
            for (File dataFile : dataFiles) {
                builder.withDataFile(dataFile);
            }
            for (Certificate recipient : recipients) {
                builder.withRecipient(recipient.x509Certificate());
            }
            builder.buildToFile(file);
            return open(file);
        } catch (DataFileMissingException e) {
            throw new DataFilesEmptyException();
        } catch (RecipientMissingException e) {
            throw new RecipientsEmptyException();
        } catch (Exception e) {
            throw new CryptoException("Encryption failed", e);
        }
    }

}