From a1dab46beabb6a509f42aa9bdcdc294815e9c934 Mon Sep 17 00:00:00 2001 From: Philip Stadermann Date: Mon, 14 Aug 2023 16:11:57 +0200 Subject: [PATCH] Revert "java/105-useshed-usecache-flags (#259)" This reverts commit 5714526e4115261d6de87bf6ef66d88d45a78e2f. --- .../main/java/de/gdata/vaas/SimpleTimer.java | 1 + java/src/main/java/de/gdata/vaas/Vaas.java | 309 ++++++------------ .../de/gdata/vaas/messages/VaasOptions.java | 24 -- .../gdata/vaas/messages/VerdictRequest.java | 40 --- .../vaas/messages/VerdictRequestForUrl.java | 27 +- .../integration/RealApiIntegrationTests.java | 1 + 6 files changed, 108 insertions(+), 294 deletions(-) delete mode 100644 java/src/main/java/de/gdata/vaas/messages/VaasOptions.java diff --git a/java/src/main/java/de/gdata/vaas/SimpleTimer.java b/java/src/main/java/de/gdata/vaas/SimpleTimer.java index 24aea0ef..f9a94528 100644 --- a/java/src/main/java/de/gdata/vaas/SimpleTimer.java +++ b/java/src/main/java/de/gdata/vaas/SimpleTimer.java @@ -2,6 +2,7 @@ import java.time.Duration; import java.time.Instant; +import java.time.temporal.TemporalUnit; import java.util.concurrent.TimeUnit; public class SimpleTimer { diff --git a/java/src/main/java/de/gdata/vaas/Vaas.java b/java/src/main/java/de/gdata/vaas/Vaas.java index 4f214a70..16a77204 100644 --- a/java/src/main/java/de/gdata/vaas/Vaas.java +++ b/java/src/main/java/de/gdata/vaas/Vaas.java @@ -3,7 +3,12 @@ import de.gdata.vaas.exceptions.VaasAuthenticationException; import de.gdata.vaas.exceptions.VaasConnectionClosedException; import de.gdata.vaas.exceptions.VaasInvalidStateException; -import de.gdata.vaas.messages.*; +import de.gdata.vaas.messages.Verdict; +import de.gdata.vaas.messages.VerdictRequest; +import de.gdata.vaas.messages.VerdictRequestAttributes; +import de.gdata.vaas.messages.VerdictRequestForUrl; +import de.gdata.vaas.messages.VerdictResponse; +import de.gdata.vaas.messages.VaasVerdict; import lombok.Getter; import lombok.NonNull; import org.java_websocket.exceptions.WebsocketNotConnectedException; @@ -18,7 +23,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.security.NoSuchAlgorithmException; -import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -32,10 +36,6 @@ public class Vaas { @NonNull private final VaasConfig config; - @Getter - @NonNull - private VaasOptions options; - @Getter @NonNull private final IClientCredentialsGrantAuthenticator clientCredentialsGrantAuthenticator; @@ -45,14 +45,6 @@ public class Vaas { public Vaas(VaasConfig config, IClientCredentialsGrantAuthenticator clientCredentialsGrantAuthenticator) { this.config = config; this.clientCredentialsGrantAuthenticator = clientCredentialsGrantAuthenticator; - this.options = new VaasOptions(); - } - - public Vaas(VaasConfig config, IClientCredentialsGrantAuthenticator clientCredentialsGrantAuthenticator, - VaasOptions options) { - this.config = config; - this.clientCredentialsGrantAuthenticator = clientCredentialsGrantAuthenticator; - this.options = options; } @SuppressWarnings("unchecked") @@ -63,14 +55,13 @@ private static void throwAsUnchecked(Exception exception) /** * Connect and authenticate with the VaaS Backend * - * @throws IOException if an I/O error occurs when getting the - * token from the identity provider - * @throws InterruptedException if the operation is interrupted by - * Thread.interrupt() - * @throws VaasAuthenticationException if the token returned by the identity - * provider is invalid - * @throws TimeoutException if the connection or authentication to - * the VaaS backend takes too long + * @throws IOException if an I/O error occurs when getting the + * token from the identity provider + * @throws InterruptedException if the operation is interrupted by Thread.interrupt() + * @throws VaasAuthenticationException if the token returned by the identity + * provider is invalid + * @throws TimeoutException if the connection or authentication to the VaaS backend + * takes too long */ public void connect() throws IOException, InterruptedException, VaasAuthenticationException, TimeoutException { var timer = new SimpleTimer(connectionTimeoutInMs, TimeUnit.MILLISECONDS); @@ -93,7 +84,7 @@ public void connect() throws IOException, InterruptedException, VaasAuthenticati /** * Disconnect from the Vaas backend * - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() + * @throws InterruptedException if the operation is interrupted by Thread.interrupt() */ public void disconnect() throws InterruptedException { if (this.client != null) { @@ -101,260 +92,159 @@ public void disconnect() throws InterruptedException { } } - /** - * Request verdict for url - * - * @param url the URL to analyze - * @return the Vaas verdict - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out - */ - public VaasVerdict forUrl(URL url) throws VaasInvalidStateException, VaasConnectionClosedException, - ExecutionException, InterruptedException, TimeoutException { - return this.forUrl(url, UUID.randomUUID(), null); - } - - /** - * Request verdict for url - * - * @param url the URL to analyze - * @param verdictRequestAttributes additional attributes for the request - * @return the Vaas verdict - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted - * @throws TimeoutException if the request times out - */ - public VaasVerdict forUrl(URL url, VerdictRequestAttributes verdictRequestAttributes) - throws VaasInvalidStateException, VaasConnectionClosedException, - ExecutionException, InterruptedException, TimeoutException { - return this.forUrl(url, UUID.randomUUID(), verdictRequestAttributes); + private CompletableFuture forUrlAsync(URL url, + VerdictRequestAttributes verdictRequestAttributes) throws VaasConnectionClosedException { + var request = new VerdictRequestForUrl(url, this.client.getSessionId(), verdictRequestAttributes); + return this.forUrlRequestAsync(request); } /** * Request verdict for url * - * @param url the URL to analyze - * @param guid a custom guid + * @param url the URL to analyze * @return the Vaas verdict - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted - * @throws TimeoutException if the request times out + * @throws VaasInvalidStateException - if the connection is in an invalid + * state + * @throws VaasConnectionClosedException - if the connection to the Vaas backend + * is closed + * @throws ExecutionException - if the request fails + * @throws InterruptedException - if the operation is interrupted by Thread.interrupt() + * @throws TimeoutException - if the request times out */ - public VaasVerdict forUrl(URL url, UUID guid) throws VaasInvalidStateException, VaasConnectionClosedException, + public VaasVerdict forUrl(URL url) throws VaasInvalidStateException, VaasConnectionClosedException, ExecutionException, InterruptedException, TimeoutException { - return this.forUrl(url, guid, null); + EnsureClientIsConnectedAndAuthenticated(); + return this.forUrl(url, null); } /** * Request verdict for url * - * @param url the URL to analyze - * @param guid a custom guid - * @param verdictRequestAttributes additional attributes for the request + * @param url the URL to analyze + * @param verdictRequestAttributes - additional attributes for the request * @return the Vaas verdict - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out + * @throws VaasInvalidStateException - if the connection is in an invalid + * state + * @throws VaasConnectionClosedException - if the connection to the Vaas backend + * is closed + * @throws ExecutionException - if the request fails + * @throws InterruptedException - if the operation is interrupted by Thread.interrupt() + * @throws TimeoutException - if the request times out */ - public VaasVerdict forUrl(URL url, UUID guid, VerdictRequestAttributes verdictRequestAttributes) + public VaasVerdict forUrl(URL url, VerdictRequestAttributes verdictRequestAttributes) throws VaasInvalidStateException, VaasConnectionClosedException, ExecutionException, InterruptedException, TimeoutException { EnsureClientIsConnectedAndAuthenticated(); - var verdictResponse = this.forUrlAsync(url, guid, verdictRequestAttributes).get( + var verdictResponse = this.forUrlAsync(url, verdictRequestAttributes).get( this.config.getDefaultTimeout().toMillis(), TimeUnit.MILLISECONDS); return new VaasVerdict(verdictResponse); } - private CompletableFuture forUrlAsync(URL url, UUID guid, - VerdictRequestAttributes verdictRequestAttributes) - throws VaasConnectionClosedException { - var request = new VerdictRequestForUrl(url, this.client.getSessionId(), guid, verdictRequestAttributes, this.options); - return this.forUrlRequestAsync(request); - } - /** * Request verdict for Sha256 - * - * @param sha256 the hashsum to analyze + * * @return the Vaas verdict - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed + * @throws ExecutionException - if the request fails + * @throws InterruptedException - if the operation is interrupted by Thread.interrupt() + * @throws TimeoutException - if the request times out + * @throws VaasInvalidStateException - if the connection is in an invalid + * state + * @throws VaasConnectionClosedException - if the connection to the Vaas backend + * is closed */ public VaasVerdict forSha256(Sha256 sha256) throws ExecutionException, InterruptedException, TimeoutException, VaasInvalidStateException, VaasConnectionClosedException { - return this.forSha256(sha256, UUID.randomUUID(), null); - } - - /** - * Request verdict for Sha256 - * - * @param sha256 the hashsum to analyze - * @param verdictRequestAttributes additional attributes for the request* - * @return the Vaas verdict - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - */ - public VaasVerdict forSha256(Sha256 sha256, VerdictRequestAttributes verdictRequestAttributes) - throws ExecutionException, InterruptedException, TimeoutException, - VaasInvalidStateException, VaasConnectionClosedException { - return this.forSha256(sha256, UUID.randomUUID(), verdictRequestAttributes); - } - - /** - * Request verdict for Sha256 - * - * @param sha256 the hashsum to analyze - * @param guid a custom guid - * @return the Vaas verdict - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - */ - public VaasVerdict forSha256(Sha256 sha256, UUID guid) - throws ExecutionException, InterruptedException, TimeoutException, - VaasInvalidStateException, VaasConnectionClosedException { - return this.forSha256(sha256, guid, null); + EnsureClientIsConnectedAndAuthenticated(); + return this.forSha256(sha256, null); } /** * Request verdict for Sha256 * - * @param sha256 the sha256 to analyze - * @param guid a custom guid - * @param verdictRequestAttributes additional attributes for the request + * @param sha256 the sha256 to analyze + * @param verdictRequestAttributes additional attributes for the request * @return the Vaas verdict - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed + * @throws ExecutionException - if the request fails + * @throws InterruptedException - if the operation is interrupted by Thread.interrupt() + * @throws TimeoutException - if the request times out + * @throws VaasInvalidStateException - if the connection is in an invalid + * state + * @throws VaasConnectionClosedException - if the connection to the Vaas backend + * is closed */ - public VaasVerdict forSha256(Sha256 sha256, UUID guid, VerdictRequestAttributes verdictRequestAttributes) + public VaasVerdict forSha256(Sha256 sha256, VerdictRequestAttributes verdictRequestAttributes) throws ExecutionException, InterruptedException, TimeoutException, VaasInvalidStateException, VaasConnectionClosedException { EnsureClientIsConnectedAndAuthenticated(); - var verdictResponse = this.forSha256Async(sha256, guid, verdictRequestAttributes).get( + var verdictResponse = this.forSha256Async(sha256, verdictRequestAttributes).get( this.config.getDefaultTimeout().toMillis(), TimeUnit.MILLISECONDS); return new VaasVerdict(verdictResponse); } - private CompletableFuture forSha256Async(Sha256 sha256, UUID guid, + private CompletableFuture forSha256Async(Sha256 sha256, VerdictRequestAttributes verdictRequestAttributes) throws VaasConnectionClosedException { - var request = new VerdictRequest(sha256, this.client.getSessionId(), guid, verdictRequestAttributes, this.options); + var request = new VerdictRequest(sha256, this.client.getSessionId(), verdictRequestAttributes); return this.forRequest(request); } /** * Request verdict for File * - * @param file the file to analyze + * @param file the file to analyze * @return the Vaas verdict - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - * @throws IOException if the file can not be read - * @throws NoSuchAlgorithmException if a particular cryptographic algorithm is requested but is not - * available in the environment - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out + * @throws VaasInvalidStateException - if the connection is in an invalid + * state + * @throws VaasConnectionClosedException - if the connection to the Vaas backend + * is closed + * @throws IOException - if the file can not be read + * @throws NoSuchAlgorithmException - if a particular cryptographic + * algorithm is requested but is not + * available in the environment + * @throws ExecutionException - if the request fails + * @throws InterruptedException - if the operation is interrupted by Thread.interrupt() + * @throws TimeoutException - if the request times out */ public VaasVerdict forFile(Path file) throws VaasInvalidStateException, VaasConnectionClosedException, IOException, NoSuchAlgorithmException, ExecutionException, InterruptedException, TimeoutException { - return forFile(file, UUID.randomUUID(), null); + EnsureClientIsConnectedAndAuthenticated(); + return forFile(file, null); } /** * Request verdict for File * - * @param file the file to analyze - * @param verdictRequestAttributes additional attributes for the request + * @param file the file to analyze + * @param verdictRequestAttributes additional attributes for the request * * @return the Vaas verdict - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - * @throws IOException if the file can not be read - * @throws NoSuchAlgorithmException if a particular cryptographic algorithm is requested but is not - * available in the environment - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out + * @throws VaasInvalidStateException - if the connection is in an invalid + * state + * @throws VaasConnectionClosedException - if the connection to the Vaas backend + * is closed + * @throws IOException - if the file can not be read + * @throws NoSuchAlgorithmException - if a particular cryptographic + * algorithm is requested but is not + * available in the environment + * @throws ExecutionException - if the request fails + * @throws InterruptedException - if the operation is interrupted by Thread.interrupt() + * @throws TimeoutException - if the request times out */ public VaasVerdict forFile(Path file, VerdictRequestAttributes verdictRequestAttributes) - throws VaasInvalidStateException, VaasConnectionClosedException, IOException, - NoSuchAlgorithmException, ExecutionException, InterruptedException, TimeoutException { - return forFile(file, UUID.randomUUID(), verdictRequestAttributes); - } - - /** - * Request verdict for File - * - * @param file the file to analyze - * @param guid a custom guid - * @return the Vaas verdict - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - * @throws IOException if the file can not be read - * @throws NoSuchAlgorithmException if a particular cryptographic algorithm is requested but is not - * available in the environment - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out - */ - public VaasVerdict forFile(Path file, UUID guid) - throws VaasInvalidStateException, VaasConnectionClosedException, IOException, - NoSuchAlgorithmException, ExecutionException, InterruptedException, TimeoutException { - return forFile(file, guid, null); - } - - /** - * Request verdict for File - * - * @param file the file to analyze - * @param guid a custom guid - * @param verdictRequestAttributes additional attributes for the request - * @return the Vaas verdict - * @throws VaasInvalidStateException if the connection is in an invalid state - * @throws VaasConnectionClosedException if the connection to the Vaas backend is closed - * @throws IOException if the file can not be read - * @throws NoSuchAlgorithmException if a particular cryptographic algorithm is requested but is not - * available in the environment - * @throws ExecutionException if the request fails - * @throws InterruptedException if the operation is interrupted by Thread.interrupt() - * @throws TimeoutException if the request times out - */ - public VaasVerdict forFile(Path file, UUID guid, VerdictRequestAttributes verdictRequestAttributes) throws VaasInvalidStateException, VaasConnectionClosedException, IOException, NoSuchAlgorithmException, ExecutionException, InterruptedException, TimeoutException { EnsureClientIsConnectedAndAuthenticated(); - var verdictResponse = this.forFileAsync(file, guid, verdictRequestAttributes).get( + var verdictResponse = this.forFileAsync(file, verdictRequestAttributes).get( this.config.getDefaultTimeout().toMillis(), TimeUnit.MILLISECONDS); return new VaasVerdict(verdictResponse); } - private CompletableFuture forFileAsync(Path file, UUID guid, + private CompletableFuture forFileAsync(Path file, VerdictRequestAttributes verdictRequestAttributes) throws NoSuchAlgorithmException, IOException, VaasConnectionClosedException { var sha256 = new Sha256(file); - var verdictRequest = new VerdictRequest(sha256, this.client.getSessionId(), guid, verdictRequestAttributes, this.options); + var verdictRequest = new VerdictRequest(sha256, this.client.getSessionId(), verdictRequestAttributes); return this.forRequest(verdictRequest) .thenCompose(verdictResponse -> { @@ -395,31 +285,32 @@ private CompletableFuture UploadFile(Path file, String url, String authTok }); } - private CompletableFuture forRequest(VerdictRequest verdictRequest) - throws VaasConnectionClosedException { + private CompletableFuture forRequest(VerdictRequest verdictRequest) throws VaasConnectionClosedException { var verdictResponse = this.client.waitForVerdict(verdictRequest.getGuid()); verdictRequest.setSessionId(this.client.getSessionId()); try { this.client.send(verdictRequest.toJson()); - } catch (WebsocketNotConnectedException ignored) { + } + catch (WebsocketNotConnectedException ignored) { throw new VaasConnectionClosedException(); } return verdictResponse; } - private CompletableFuture forUrlRequestAsync(VerdictRequestForUrl verdictRequestForUrl) - throws VaasConnectionClosedException { + private CompletableFuture forUrlRequestAsync(VerdictRequestForUrl verdictRequestForUrl) throws VaasConnectionClosedException { var verdictResponse = this.client.waitForVerdict(verdictRequestForUrl.getGuid()); verdictRequestForUrl.setSessionId(this.client.getSessionId()); try { this.client.send(verdictRequestForUrl.toJson()); - } catch (WebsocketNotConnectedException ignored) { + } + catch (WebsocketNotConnectedException ignored) { throw new VaasConnectionClosedException(); } + return verdictResponse; } diff --git a/java/src/main/java/de/gdata/vaas/messages/VaasOptions.java b/java/src/main/java/de/gdata/vaas/messages/VaasOptions.java deleted file mode 100644 index eb5d7023..00000000 --- a/java/src/main/java/de/gdata/vaas/messages/VaasOptions.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.gdata.vaas.messages; - -import com.beust.jcommander.internal.Nullable; -import com.google.gson.annotations.SerializedName; -import lombok.Getter; -import lombok.Setter; - -public class VaasOptions { - - @Getter - @Setter - @SerializedName("use_hash_lookup") - boolean UseHashLookup; - - @Getter - @Setter - @SerializedName("use_cache") - boolean UseCache; - - public VaasOptions() { - this.UseCache = false; - this.UseHashLookup = true; - } -} diff --git a/java/src/main/java/de/gdata/vaas/messages/VerdictRequest.java b/java/src/main/java/de/gdata/vaas/messages/VerdictRequest.java index ce5ff09e..2f17e9d5 100644 --- a/java/src/main/java/de/gdata/vaas/messages/VerdictRequest.java +++ b/java/src/main/java/de/gdata/vaas/messages/VerdictRequest.java @@ -6,7 +6,6 @@ import lombok.Getter; import lombok.NonNull; import lombok.Setter; -import org.jetbrains.annotations.Nullable; import java.util.UUID; @@ -26,16 +25,6 @@ public class VerdictRequest extends MessageType { @Setter @SerializedName("verdict_request_attributes") VerdictRequestAttributes verdictRequestAttributes; - @Getter - @Setter - @Nullable - @SerializedName("use_hash_lookup") - boolean UseHashLookup; - @Getter - @Setter - @Nullable - @SerializedName("use_cache") - boolean UseCache; public VerdictRequest(Sha256 sha256, String sessionId) { super(Kind.VerdictRequest); @@ -44,40 +33,11 @@ public VerdictRequest(Sha256 sha256, String sessionId) { this.sha256 = sha256.getValue(); } - public VerdictRequest(Sha256 sha256, String sessionId, UUID guid) { - super(Kind.VerdictRequest); - this.sessionId = sessionId; - this.guid = guid.toString(); - this.sha256 = sha256.getValue(); - } - public VerdictRequest(Sha256 sha256, String sessionId, VerdictRequestAttributes verdictRequestAttributes) { this(sha256, sessionId); this.verdictRequestAttributes = verdictRequestAttributes; } - public VerdictRequest(Sha256 sha256, String sessionId, VaasOptions options) { - this(sha256, sessionId); - this.UseCache = options.UseCache; - this.UseHashLookup = options.UseHashLookup; - } - - public VerdictRequest(Sha256 sha256, String sessionId, UUID guid, VerdictRequestAttributes verdictRequestAttributes) { - this(sha256, sessionId, guid); - this.verdictRequestAttributes = verdictRequestAttributes; - } - - public VerdictRequest(Sha256 sha256, String sessionId, UUID guid, VaasOptions options) { - this(sha256, sessionId, guid); - this.UseCache = options.UseCache; - this.UseHashLookup = options.UseHashLookup; - } - - public VerdictRequest(Sha256 sha256, String sessionId, UUID guid, VerdictRequestAttributes verdictRequestAttributes, VaasOptions options) { - this(sha256, sessionId, guid, options); - this.verdictRequestAttributes = verdictRequestAttributes; - } - public String toJson() { return new GsonBuilder().serializeNulls().create().toJson(this); } diff --git a/java/src/main/java/de/gdata/vaas/messages/VerdictRequestForUrl.java b/java/src/main/java/de/gdata/vaas/messages/VerdictRequestForUrl.java index 6f93870f..02be963f 100644 --- a/java/src/main/java/de/gdata/vaas/messages/VerdictRequestForUrl.java +++ b/java/src/main/java/de/gdata/vaas/messages/VerdictRequestForUrl.java @@ -5,7 +5,6 @@ import lombok.Getter; import lombok.NonNull; import lombok.Setter; -import org.jetbrains.annotations.Nullable; import java.net.URL; import java.util.UUID; @@ -27,36 +26,22 @@ public class VerdictRequestForUrl extends MessageType { @SerializedName("verdict_request_attributes") VerdictRequestAttributes verdictRequestAttributes; @Getter - @SerializedName("use_hash_lookup") - transient boolean UseHashLookup; - @Getter + @Setter @SerializedName("use_cache") - boolean UseCache; + boolean useCache = true; - public VerdictRequestForUrl(URL url, String sessionId, UUID guid) { + public VerdictRequestForUrl(URL url, String sessionId) { super(Kind.VerdictRequestForUrl); this.sessionId = sessionId; - this.guid = guid.toString(); + this.guid = UUID.randomUUID().toString(); this.url = url.toString(); } - public VerdictRequestForUrl(URL url, String sessionId, UUID guid, VerdictRequestAttributes verdictRequestAttributes) { - this(url, sessionId, guid); - this.verdictRequestAttributes = verdictRequestAttributes; - } - - public VerdictRequestForUrl(URL url, String sessionId, UUID guid, VaasOptions options) { - this(url, sessionId, guid); - this.UseCache = options.UseCache; - this.UseHashLookup = options.UseHashLookup; - } - - public VerdictRequestForUrl(URL url, String sessionId, UUID guid, VerdictRequestAttributes verdictRequestAttributes, VaasOptions options) { - this(url, sessionId, guid); + public VerdictRequestForUrl(URL url, String sessionId, VerdictRequestAttributes verdictRequestAttributes) { + this(url, sessionId); this.verdictRequestAttributes = verdictRequestAttributes; } - public String toJson() { return new Gson().toJson(this); } diff --git a/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java b/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java index 5535562d..19a69b8e 100644 --- a/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java +++ b/java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java @@ -84,6 +84,7 @@ public String getToken() throws IOException, InterruptedException { var dotenv = Dotenv.configure() .ignoreIfMissing() .load(); + var tokenUrl = dotenv.get("TOKEN_URL"); var vaasUrl = dotenv.get("VAAS_URL"); var config = new VaasConfig(new URI(vaasUrl)); var authenticator = new MockAuthenticator();