java9.0.0
What's Changed
This is a major release and may break your code. Please read the full changelog before upgrading.
- Change to HTTP API: This release changes the underlying protocol used by the SDK from Websockets to HTTP.
- No
connect()needed: Since the SDK now uses HTTP, it is stateless and does not require a connection to be established. - Async API: The SDK now uses a fully async API. All methods now return non-blocking
CompletableFuture's instead. - Sync API: A synchronous API is also available. This is a thin wrapper around the async API. The main difference is that the synchronous API blocks until the result is available and returns the result directly. Also exceptions are thrown directly instead of being wrapped in an
ExecutionExceptionwith an inner exception you have to unwrap. - Method calls: Even though the SDK is now async over HTTP the method signatures are mostly the same. Please take a look at the Java SDK examples.
- Documentation: Please take a look at the method documentation in the
IVaasinterface here.
How to migrate
To scan a file, you previously had to proceed as follows:
var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, new URI(tokenUrl));
var config = new VaasConfig(new URI(vaasUrl));
var vaas = new Vaas(config, authenticator);
vaas.connect();
var verdict = vaas.forFile(Path.of(filePath));
vaas.disconnect();
System.out.printf("File %s was detected as %s", verdict.getSha256(), verdict.getVerdict()));With the new SDK, you can now scan a file like this:
var authenticator = new ClientCredentialsGrantAuthenticator(env.clientId, env.clientSecret, new URI(env.tokenUrl));
var config = new VaasConfig(new URI(env.vaasUrl));
var vaas = new Vaas(config, authenticator);
var verdict = vaas.forFile(Path.of(filePath));
System.out.printf("File %s was sync detected as %s", verdict.getSha256(), verdict.getVerdict());Or with the async API:
var authenticator = new ClientCredentialsGrantAuthenticator(env.clientId, env.clientSecret, new URI(env.tokenUrl));
var config = new VaasConfig(new URI(env.vaasUrl));
var vaas = new Vaas(config, authenticator);
// Take care that exceptions need to be unpacked from ExecutionException or CompletionException
vaas.forFileAsync(file).thenAccept(vaasResult -> {
System.out.printf("\nFile %s was async detected as %s", vaasResult.getSha256(), vaasResult.getVerdict());
}).get();Full Changelog: java8.3.8...java9.0.0