@ParametersAreNonnullByDefault
See: Description
Interface | Description |
---|---|
UnstructuredData |
Class | Description |
---|---|
EncryptionSpec | |
MetaClientPasswordListener | |
UnifiedKmsPasswordListener |
Simplifies usages of
KMSPasswordListener
Since the introduction of KMS into the SecureZIP SDK the KMSPasswordListener requires you to
overwrite two methods. |
UnstructuredDataImpl | |
UnstructuredDataImpl.Builder |
MetaClient metaClient = new NativeMetaClient.Builder()
.appName("UnstructuredEncryptionSample")
.appVersion("9.99.9999")
.deviceName(UUID.randomUUID().toString())
.deviceUniqueId(UUID.randomUUID().toString())
.platform(Platform.LINUX)
.platformVersion("0")
.build();
UnstructuredData unstructuredData = new UnstructuredDataImpl.Builder()
.metaClient(metaClient)
.license("{your license here}")
.build();
File exampleFile = new File("example.zip");
EncryptionSpec spec = new EncryptionSpec();
spec.smartkey = smartkey;
spec.password = "password";
try (OutputStream targetStream = new FileOutputStream(exampleFile)) {
try (ZipArchiveOutputStream archive = unstructuredData.newZipOutputStream(targetStream)) {
unstructuredData.encrypt(archive, spec);
InputStream sourceStream = new ByteArrayInputStream("Hello, world!".getBytes());
ZipArchiveEntry entry = archive.createArchiveEntry(null, "message.txt");
archive.addEntry(entry, sourceStream);
}
}
MetaClient metaClient = new NativeMetaClient.Builder()
.appName("UnstructuredEncryptionSample")
.appVersion("9.99.9999")
.deviceName(UUID.randomUUID().toString())
.deviceUniqueId(UUID.randomUUID().toString())
.platform(Platform.LINUX)
.platformVersion("0")
.build();
UnstructuredData unstructuredData = new UnstructuredDataImpl.Builder()
.metaClient(metaClient)
.license("{your license here}")
.build();
File exampleFile = new File("example.zip");
ZipFile archive = unstructuredData.newZipFile(exampleFile);
ZipArchiveEntry entry = archive.getEntry("message.txt");
try (InputStream entryStream = archive.getInputStream(entry)) {
try (OutputStream targetFile = new FileOutputStream("message.txt")) {
IOUtils.copy(entryStream, targetFile);
}
}
archive.close();