-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #676 from GDATASoftwareAG/java/http_api
Java/http api
- Loading branch information
Showing
61 changed files
with
2,989 additions
and
2,085 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,17 +20,18 @@ java { | |
dependencies { | ||
implementation 'org.projectlombok:lombok:1.18.36' | ||
implementation 'com.google.code.gson:gson:2.11.0' | ||
implementation 'org.java-websocket:Java-WebSocket:1.6.0' | ||
implementation 'org.jetbrains:annotations:26.0.1' | ||
implementation 'io.github.cdimascio:dotenv-java:3.1.0' | ||
implementation 'com.ibm.async:asyncutil:0.1.0' | ||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2' | ||
testImplementation 'org.testng:testng:7.10.2' | ||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.4' | ||
testImplementation 'org.slf4j:slf4j-simple:2.0.16' | ||
|
||
testImplementation 'org.mockito:mockito-core:5.14.2' | ||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.3' | ||
testImplementation 'com.amazonaws:aws-java-sdk-s3:1.12.780' | ||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.4' | ||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.4' | ||
|
||
|
||
compileOnly 'org.projectlombok:lombok:1.18.36' | ||
annotationProcessor 'org.projectlombok:lombok:1.18.36' | ||
|
||
|
@@ -41,13 +42,13 @@ dependencies { | |
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events "passed", "skipped", "failed" | ||
events "passed", "skipped", "failed" | ||
|
||
showExceptions true | ||
exceptionFormat "full" | ||
showCauses true | ||
showStackTraces true | ||
showStandardStreams true | ||
showExceptions true | ||
exceptionFormat "full" | ||
showCauses true | ||
showStackTraces true | ||
showStandardStreams true | ||
} | ||
} | ||
|
||
|
@@ -69,6 +70,8 @@ tasks.register('testWithoutErrorLogProducer', Test) { | |
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from components.java | ||
|
||
pom { | ||
name = 'G DATA VaaS' | ||
description = 'Verdict-as-a-Service (VaaS) is a service that provides a platform for scanning files for malware and other threats. It allows easy integration in your application. With a few lines of code, you can start scanning files for malware.' | ||
|
@@ -90,22 +93,50 @@ publishing { | |
connection = 'scm:git:[email protected]:GDATASoftwareAG/vaas.git' | ||
url = 'https://github.com/GDATASoftwareAG/vaas' | ||
} | ||
|
||
from components.java | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
def signingKey = findProperty("signingKey") | ||
def signingPassword = findProperty("signingPassword") | ||
useInMemoryPgpKeys(signingKey, signingPassword) | ||
sign publishing.publications.mavenJava | ||
def isReleaseBuild = project.gradle.taskGraph.hasTask("publishToMavenCentral") | ||
|
||
if (isReleaseBuild && findProperty("signingKey") && findProperty("signingPassword")) { | ||
useInMemoryPgpKeys(findProperty("signingKey"), findProperty("signingPassword")) | ||
sign publishing.publications.mavenJava | ||
} else { | ||
logger.lifecycle("Skipping signing as this is not a release build or no signing credentials are provided.") | ||
} | ||
} | ||
|
||
|
||
repositories { | ||
// Veröffentlichung in ein internes lokales Verzeichnis (nur optional) | ||
maven { | ||
url = layout.buildDirectory.dir('repos/releases') | ||
} | ||
|
||
// Maven Central | ||
maven { | ||
name = "mavenCentral" | ||
url = "https://repo.maven.apache.org/maven2" | ||
credentials { | ||
username = findProperty("mavenCentralUsername") ?: "" | ||
password = findProperty("mavenCentralPassword") ?: "" | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.register('publishToLocalMaven') { | ||
group = 'publishing' | ||
description = 'Publish the library to the local Maven repository (~/.m2/repository).' | ||
|
||
dependsOn 'publishMavenJavaPublicationToMavenLocal' | ||
} | ||
|
||
tasks.register('publishToMavenCentral') { | ||
group = 'publishing' | ||
description = 'Publish the library to Maven Central.' | ||
|
||
dependsOn 'publishMavenJavaPublicationToMavenRepository' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
You need to set a .env file with the following variables: | ||
|
||
``` | ||
VAAS_URL=https://gateway.staging.vaas.gdatasecurity.de | ||
TOKEN_URL=https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token | ||
CLIENT_ID=YOUR_CLIENT_ID | ||
CLIENT_SECRET=YOUR_CLIENT_SECRET | ||
VAAS_USER_NAME=YOUR_USER_NAME | ||
VAAS_PASSWORD=YOUR_PASSWORD | ||
VAAS_CLIENT_ID=vaas-customer | ||
``` | ||
|
||
## How to run the project | ||
|
||
You should use the published Maven package. | ||
If you want to run the examples locally you need to publish a local Maven package with the given gradle task: | ||
|
||
```gradle | ||
tasks.register('publishToLocalMaven') { | ||
group = 'publishing' | ||
description = 'Publish the library to the local Maven repository (~/.m2/repository).' | ||
dependsOn 'publishMavenJavaPublicationToMavenLocal' | ||
} | ||
``` | ||
|
||
You can find the task in the projects root located in `java/build.gradle`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package de.gdata.vaasexample; | ||
|
||
import de.gdata.vaas.*; | ||
import de.gdata.vaas.authentication.*; | ||
|
||
import java.net.URI; | ||
import java.nio.file.Path; | ||
|
||
public class Config { | ||
public static void main(String[] args) throws Exception { | ||
var env = new Environment(); | ||
|
||
var timeoutInMs = 5000; | ||
var useCache = false; | ||
var useHashLookup = false; | ||
var config = new VaasConfig(timeoutInMs, | ||
useCache, | ||
useHashLookup, | ||
new URI(env.vaasUrl)); | ||
|
||
var authenticator = new ClientCredentialsGrantAuthenticator(env.clientId, env.clientSecret, new URI(env.tokenUrl)); | ||
var vaas = new Vaas(config, authenticator); | ||
|
||
var file = Path.of(Environment.getenv("SCAN_PATH")); | ||
var verdict = vaas.forFile(file); | ||
|
||
System.out.printf("File %s was sync detected as %s", verdict.getSha256(), verdict.getVerdict()); | ||
|
||
vaas.forFileAsync(file).thenAccept(vaasResult -> { | ||
System.out.printf("\nFile %s was async detected as %s", verdict.getSha256(), verdict.getVerdict()); | ||
}).get(); | ||
} | ||
} |
Oops, something went wrong.