Source:
private void validateEncryptedFileWithHeaderValues(final SupportedCipherDetails cipherDetails) throws IOException, DecoderException { final String cipherName = cipherDetails.getCipherId().replaceAll(SEPARATOR,"-"); final SecretKey secretKey = generateSecretKey(cipherDetails); final String filePath = "test-data/ciphertext/" + cipherName + ".ciphertext"; final URL encryptedFileURL = getClass().getClassLoader().getResource(filePath); MantaHttpHeaders getResponseHttpHeaders = new MantaHttpHeaders(); populateHeaderValuesFromResources(getResponseHttpHeaders,cipherDetails); final long cipherTextSize = getResponseHttpHeaders.getContentLength(); final byte[] actualBytes; try (final InputStream encryptedStream = encryptedFileURL.openStream(); final BoundedInputStream bin = new BoundedInputStream(encryptedStream, cipherTextSize)) { actualBytes = IOUtils.toByteArray(bin); } final MantaObjectResponse objectResponse = new MantaObjectResponse(filePath, getResponseHttpHeaders); try (final InputStream sourceBytes = new ByteArrayInputStream(actualBytes); final EofSensorInputStream eofSensorInputStream = new EofSensorInputStream(sourceBytes,null); final MantaObjectInputStream objectStream = new MantaObjectInputStream( objectResponse, Mockito.mock(CloseableHttpResponse.class), eofSensorInputStream); final MantaEncryptedObjectInputStream decryptingStream = new MantaEncryptedObjectInputStream( objectStream, cipherDetails, secretKey, true); final ByteArrayOutputStream decrypted = new ByteArrayOutputStream()) { IOUtils.copy(decryptingStream, decrypted); validateDecryptingByteArrayForCipher(expectedContent, decrypted.toByteArray(), cipherName); } }

Target:
private void validateEncryptedFileWithHeaderValues(final SupportedCipherDetails cipherDetails) throws IOException, DecoderException { final String cipherName = cipherDetails.getCipherId().replaceAll("/","-"); final SecretKey secretKey = generateSecretKey(cipherDetails); final String filePath = "test-data/ciphertext/" + cipherName + ".ciphertext"; final URL encryptedFileURL = getClass().getClassLoader().getResource(filePath); MantaHttpHeaders getResponseHttpHeaders = new MantaHttpHeaders(); populateHeaderValuesFromResources(getResponseHttpHeaders,cipherDetails); final long cipherTextSize = getResponseHttpHeaders.getContentLength(); final byte[] actualBytes; try (final InputStream encryptedStream = encryptedFileURL.openStream(); final BoundedInputStream bin = new BoundedInputStream(encryptedStream, cipherTextSize)) { actualBytes = IOUtils.toByteArray(bin); } final MantaObjectResponse objectResponse = new MantaObjectResponse(filePath, getResponseHttpHeaders); try (final InputStream sourceBytes = new ByteArrayInputStream(actualBytes); final EofSensorInputStream eofSensorInputStream = new EofSensorInputStream(sourceBytes,null); final MantaObjectInputStream objectStream = new MantaObjectInputStream( objectResponse, Mockito.mock(CloseableHttpResponse.class), eofSensorInputStream); final MantaEncryptedObjectInputStream decryptingStream = new MantaEncryptedObjectInputStream( objectStream, cipherDetails, secretKey, true); final ByteArrayOutputStream decrypted = new ByteArrayOutputStream()) { IOUtils.copy(decryptingStream, decrypted); validateDecryptingByteArrayForCipher(expectedContent, decrypted.toByteArray(), cipherName); } }