diff --git a/dotnet/examples/VaasExample/Program.cs b/dotnet/examples/VaasExample/Program.cs index fef278c5..78c889d7 100644 --- a/dotnet/examples/VaasExample/Program.cs +++ b/dotnet/examples/VaasExample/Program.cs @@ -37,9 +37,12 @@ private static async Task FileScan() { Url = VaasUrl, }; - // If you got username + password - var authenticator = new ResourceOwnerPasswordGrantAuthenticator(ClientIdForResourceOwnerPasswordGrant, UserName, Password, TokenUrl); - // else if you got client id and client secret + // If you got a username and password from us, you can use the ResourceOwnerPasswordAuthenticator like this + var authenticator = new ResourceOwnerPasswordGrantAuthenticator("vaas-customer", UserName, Password, TokenUrl); + // You may use self registration and create a new username and password for the + // ResourceOwnerPasswordAuthenticator by yourself like the example above on https://vaas.gdata.de/login + + // Else if you got a client id and client secret from us, you can use the ClientCredentialsGrantAuthenticator like this // var authenticator = new ClientCredentialsGrantAuthenticator( // ClientId, // ClientSecret, diff --git a/java/examples/VaasExample/build.gradle b/java/examples/VaasExample/build.gradle index 596b7e25..0853bf60 100644 --- a/java/examples/VaasExample/build.gradle +++ b/java/examples/VaasExample/build.gradle @@ -11,7 +11,7 @@ repositories { dependencies { implementation 'org.slf4j:slf4j-nop:2.0.7' - implementation 'de.gdata:vaas:5.2.0' + implementation 'de.gdata:vaas:6.1.0' } task fileScan(type: JavaExec) { diff --git a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Authentication.java b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Authentication.java new file mode 100644 index 00000000..fa8e3d09 --- /dev/null +++ b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Authentication.java @@ -0,0 +1,52 @@ +package de.gdata.vaasexample; + +import de.gdata.vaas.ClientCredentialsGrantAuthenticator; +import de.gdata.vaas.ResourceOwnerPasswordGrantAuthenticator; +import de.gdata.vaas.Vaas; +import de.gdata.vaas.VaasConfig; +import de.gdata.vaas.messages.VerdictRequestAttributes; +import java.net.URI; +import java.nio.file.Path; + + +public class Authentication { + public static void main(String[] args) throws Exception { + var clientId = System.getenv("CLIENT_ID"); + var clientSecret = System.getenv("CLIENT_SECRET"); + var userName = System.getenv("VAAS_USER_NAME"); + var password = System.getenv("VAAS_PASSWORD"); + var scanPath = System.getenv("SCAN_PATH"); + var tokenUrl = System.getenv("TOKEN_URL"); + if (tokenUrl == null) { tokenUrl = "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"; } + var vaasUrl = System.getenv("VAAS_URL"); + if (vaasUrl == null) { vaasUrl = "wss://gateway.production.vaas.gdatasecurity.de"; } + + // If you got a username and password from us, you can use the ResourceOwnerPasswordAuthenticator like this + var authenticator = new ResourceOwnerPasswordGrantAuthenticator( + "vaas-customer", + userName, + password, + new URI(tokenUrl) + ); + // You may use self registration and create a new username and password for the + // ResourceOwnerPasswordAuthenticator by yourself like the example above on https://vaas.gdata.de/login + + // Else if you got a client id and client secret from us, you can use the ClientCredentialsGrantAuthenticator like this + // 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 file = Path.of(scanPath); + var verdictRequestAttributes = new VerdictRequestAttributes(); + verdictRequestAttributes.setTenantId("fileTenant"); + var verdict = vaas.forFile(file, verdictRequestAttributes); + vaas.disconnect(); + System.out.printf("File %s was detected as %s", verdict.getSha256(), verdict.getVerdict()); + } +} \ No newline at end of file diff --git a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Main.java b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Main.java index aa50076e..df97bac9 100644 --- a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Main.java +++ b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/Main.java @@ -22,7 +22,7 @@ public static void main(String[] args) throws Exception { vaasUrl = "wss://gateway.production.vaas.gdatasecurity.de"; } - var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, tokenUrl); + var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, new URI(tokenUrl)); var config = new VaasConfig( new URI(vaasUrl)); var vaas = new Vaas(config, authenticator); diff --git a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/UrlScan.java b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/UrlScan.java index 39ce78e9..b32e7ac7 100644 --- a/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/UrlScan.java +++ b/java/examples/VaasExample/src/main/java/de/gdata/vaasexample/UrlScan.java @@ -21,7 +21,7 @@ public static void main(String[] args) throws Exception { vaasUrl = "wss://gateway.production.vaas.gdatasecurity.de"; } - var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, tokenUrl); + var authenticator = new ClientCredentialsGrantAuthenticator(clientId, clientSecret, new URI(tokenUrl)); var config = new VaasConfig(new URI(vaasUrl)); var vaas = new Vaas(config, authenticator); vaas.connect(); diff --git a/php/examples/VaasExample/AuthenticationExamples.php b/php/examples/VaasExample/AuthenticationExamples.php index 56ee740e..93dc8a2c 100644 --- a/php/examples/VaasExample/AuthenticationExamples.php +++ b/php/examples/VaasExample/AuthenticationExamples.php @@ -14,14 +14,14 @@ // If you got a username and password from us, you can use the ResourceOwnerPasswordAuthenticator like this if ($USE_RESOURCE_OWNER_PASSWORD_GRANT_AUTHENTICATOR){ $authenticator = new ResourceOwnerPasswordGrantAuthenticator( - getenv("VAAS_CLIENT_ID"), + "vaas-customer", getenv("VAAS_USER_NAME"), getenv("VAAS_PASSWORD"), getenv("TOKEN_URL") ); } -// If you got a client id with a link you may use self registration and create a new username and password for the -// ResourceOwnerPasswordAuthenticator by yourself like the example above. +// You may use self registration and create a new username and password for the +// ResourceOwnerPasswordAuthenticator by yourself like the example above on https://vaas.gdata.de/login // If you got a client id and client secret from us, you can use the ClientCredentialsGrantAuthenticator like this else{ diff --git a/python/examples/VaasExample/authentication_example.py b/python/examples/VaasExample/authentication_example.py index aca29521..d979086b 100644 --- a/python/examples/VaasExample/authentication_example.py +++ b/python/examples/VaasExample/authentication_example.py @@ -16,15 +16,15 @@ async def main(): # If you got a username and password from us, you can use the ResourceOwnerPasswordAuthenticator like this if USE_RESOURCE_OWNER_PASSWORD_GRANT_AUTHENTICATOR: authenticator = ResourceOwnerPasswordGrantAuthenticator( - os.getenv("VAAS_CLIENT_ID"), + "vaas-customer", os.getenv("VAAS_USER_NAME"), os.getenv("VAAS_PASSWORD"), token_endpoint=token_url ) - # If you got a client id with a link you may use self registration and create a new username and password for the - # ResourceOwnerPasswordAuthenticator by yourself like the example above. + # You may use self registration and create a new username and password for the + # ResourceOwnerPasswordAuthenticator by yourself like the example above on https://vaas.gdata.de/login - # If you got a client id and client secret from us, you can use the ClientCredentialsGrantAuthenticator like this + # Else if you got a client id and client secret from us, you can use the ClientCredentialsGrantAuthenticator like this else: authenticator = ClientCredentialsGrantAuthenticator( os.getenv("CLIENT_ID"),