CryptoContainer { @WorkerThread public static CryptoContainer open(File file) throws CryptoException { try ( InputStream dataFilesStream = new FileInputStream(file); InputStream recipientsStream = new FileInputStream(file) ) { ImmutableList.Builder<File> dataFilesBuilder = ImmutableList.builder(); ImmutableList.Builder<Certificate> recipientsBuilder = ImmutableList.builder(); for (String dataFileName : CDOCParser.getDataFileNames(dataFilesStream)) { dataFilesBuilder.add(new File(dataFileName)); } for (Recipient recipient : CDOCParser.getRecipients(recipientsStream)) { recipientsBuilder.add(Certificate .create(ByteString.of(recipient.getCertificate().getEncoded()))); } return create(file, dataFilesBuilder.build(), recipientsBuilder.build(), false); } catch (Exception e) { throw new CryptoException("Can't open crypto container", e); } }  abstract File file(); abstract ImmutableList<File> dataFiles(); abstract ImmutableList<Certificate> recipients(); abstract boolean decrypted(); CryptoContainer decrypt(DecryptToken decryptToken, Certificate authCertificate,
                                   String pin1, File dataFilesDirectory); @WorkerThread static CryptoContainer open(File file); @WorkerThread static CryptoContainer encrypt(ImmutableList<File> dataFiles,
                                          ImmutableList<Certificate> recipients, File file); static boolean isContainerFileName(String fileName); static String createContainerFileName(String fileName);  }
@Test public void open_fileDoesNotExist() throws Exception { exception.expect(CryptoException.class); CryptoContainer.open(new File("does-not-exist.cdoc")); }
@Test public void open_notCdocFile() throws Exception { exception.expect(CryptoException.class); CryptoContainer.open(resource("37101010021_ec.cer")); }