IntegrityPreservingUriEncryption implements SymmetricPathEncryptionService { @Override @SneakyThrows public Uri decrypt(AuthPathEncryptionSecretKey pathEncryptionSecretKey, Uri bucketPath) { validateArgs(pathEncryptionSecretKey, bucketPath); validateUriIsRelative(bucketPath); bucketPath = AES_SIV.asUriRoot().relativize(bucketPath); return processURIparts( pathEncryptionSecretKey, bucketPath, decryptAndDecode ); } @Inject  IntegrityPreservingUriEncryption(PathEncryptorDecryptor pathEncryptorDecryptor); @Override @SneakyThrows Uri encrypt(AuthPathEncryptionSecretKey pathEncryptionSecretKey, Uri bucketPath); @Override @SneakyThrows Uri decrypt(AuthPathEncryptionSecretKey pathEncryptionSecretKey, Uri bucketPath);  }
@Test void testFailEncryptPathWithBrokenEncryptedPath() { AuthPathEncryptionSecretKey pathEncryptionSecretKey = pathEncryptionSecretKey(); assertThrows(BadPaddingException.class, () -> symmetricPathEncryptionService.decrypt(pathEncryptionSecretKey, new Uri(URI.create("bRQiW8qLNPEy5tO7shfV0w==/k0HooCVlmhHkQFw8mc==")))); }
@Test void testFailEncryptPathWithTextPath() { AuthPathEncryptionSecretKey pathEncryptionSecretKey = pathEncryptionSecretKey(); assertThrows( IllegalBlockSizeException.class, () -> symmetricPathEncryptionService.decrypt(pathEncryptionSecretKey, new Uri("simple/text/path/")) ); }