diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 387c966..d10a714 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -28,11 +28,17 @@ jobs:
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
- java-version: 8
+ java-version: 17
distribution: temurin
- - name: Run tests
- run: mvn clean test
+ - name: Set up Homebrew
+ uses: Homebrew/actions/setup-homebrew@master
+
+ - name: Install topaz
+ run: brew tap aserto-dev/tap && brew install aserto-dev/tap/topaz && topaz install
+
+ - name: Run all tests
+ run: mvn clean test -Pintegration
release:
runs-on: ubuntu-latest
needs: build
diff --git a/examples/directory-example/.gitignore b/examples/directory-example/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/examples/directory-example/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/examples/directory-example/pom.xml b/examples/directory-example/pom.xml
new file mode 100644
index 0000000..1c9e8fe
--- /dev/null
+++ b/examples/directory-example/pom.xml
@@ -0,0 +1,54 @@
+
+
+ 4.0.0
+
+ org.example
+ directory-example
+ 0.0.1
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ com.aserto
+ aserto-java
+ 0.20.10
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.4.1
+
+ false
+
+
+
+
+ shade
+
+
+ true
+
+
+
+
+ org.example.DirectoryExample
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/directory-example/src/main/java/org/example/DirectoryExample.java b/examples/directory-example/src/main/java/org/example/DirectoryExample.java
new file mode 100644
index 0000000..4874f83
--- /dev/null
+++ b/examples/directory-example/src/main/java/org/example/DirectoryExample.java
@@ -0,0 +1,53 @@
+package org.example;
+
+import com.aserto.ChannelBuilder;
+import com.aserto.directory.v3.DirectoryClient;
+import com.aserto.directory.common.v3.ObjectIdentifier;
+import com.aserto.directory.reader.v3.GetObjectManyResponse;
+import com.aserto.directory.reader.v3.GetObjectResponse;
+import com.aserto.directory.reader.v3.GetObjectsResponse;
+import com.aserto.directory.v3.Directory;
+import io.grpc.ManagedChannel;
+
+import javax.net.ssl.SSLException;
+import java.util.List;
+
+public class DirectoryExample {
+ public static void main(String[] args) throws SSLException {
+ // create a channel that has the connection details
+ ManagedChannel channel = new ChannelBuilder()
+ .withHost("localhost")
+ .withPort(9292)
+ .withInsecure(true)
+ .build();
+
+ // create a directory client that wil be used to interact with the directory
+ DirectoryClient directoryClient = new DirectoryClient(channel);
+
+ getUserExample(directoryClient);
+ getUsersExample(directoryClient);
+ getObjectManyRequest(directoryClient);
+ }
+
+ public static void getUserExample(DirectoryClient directoryClient) {
+ System.out.println("------ Get user example ------");
+ GetObjectResponse getObjectResponse = directoryClient.getObject("user", "morty@the-citadel.com", false);
+ System.out.println(getObjectResponse);
+ }
+
+ public static void getUsersExample(DirectoryClient directoryClient) {
+ System.out.println("------ Get users example ------");
+ GetObjectsResponse getObjectsResponse = directoryClient.getObjects("user", 100, "");
+ System.out.println(getObjectsResponse);
+ }
+
+ public static void getObjectManyRequest(DirectoryClient directoryClient) {
+ System.out.println("------ Get object many example ------");
+ List objects = List.of(
+ Directory.buildObjectIdentifier("user", "rick@the-citadel.com"),
+ Directory.buildObjectIdentifier("user", "morty@the-citadel.com"));
+
+ GetObjectManyResponse getObjectManyRequest = directoryClient.getObjectManyRequest(objects);
+ System.out.println(getObjectManyRequest);
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5f0e8ce..7b755d5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.aserto
aserto-java
- 0.20.9
+ 0.20.10
${project.groupId}:${project.artifactId}
Java SDK to interact with aserto services
@@ -37,11 +37,11 @@
- 8
- 8
+ 17
+ 17
UTF-8
- 1.58.0
+ 1.59.0
IntegrationTest
@@ -49,25 +49,25 @@
com.aserto
java-authorizer
- 0.20.6
+ 0.20.7
com.aserto
java-directory
- 0.0.1
+ 0.30.1
org.junit.jupiter
junit-jupiter-engine
- 5.10.0
+ 5.10.1
test
- org.junit.platform
- junit-platform-runner
- 1.10.0
+ org.assertj
+ assertj-core
+ 3.24.2
test
@@ -83,6 +83,18 @@
3.12.4
test
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.21.1
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.21.1
+
@@ -174,7 +186,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 3.1.2
+ 3.2.2
${exclude-tests}
diff --git a/src/main/java/com/aserto/ChannelBuilder.java b/src/main/java/com/aserto/ChannelBuilder.java
index 2fe06fd..f685b67 100644
--- a/src/main/java/com/aserto/ChannelBuilder.java
+++ b/src/main/java/com/aserto/ChannelBuilder.java
@@ -90,7 +90,11 @@ public ManagedChannel build() throws SSLException {
.intercept(MetadataUtils.newAttachHeadersInterceptor(metadata));
boolean insecure = cfg.getInsecure();
- boolean caSpecified = !cfg.getCaCertPath().isEmpty();
+
+ boolean caSpecified = true;
+ if (cfg.getCaCertPath() == null || cfg.getCaCertPath().isEmpty()) {
+ caSpecified = false;
+ }
if (insecure) {
SslContext context = GrpcSslContexts.forClient()
diff --git a/src/main/java/com/aserto/DirectoryClient.java b/src/main/java/com/aserto/DirectoryClient.java
deleted file mode 100644
index 824b586..0000000
--- a/src/main/java/com/aserto/DirectoryClient.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.aserto;
-
-import com.aserto.directory.common.v2.ObjectTypeIdentifier;
-import com.aserto.directory.common.v2.PaginationRequest;
-import com.aserto.directory.exporter.v2.ExporterGrpc;
-import com.aserto.directory.importer.v2.ImporterGrpc;
-import com.aserto.directory.reader.v2.*;
-import com.aserto.directory.writer.v2.WriterGrpc;
-import com.aserto.directory.common.v2.Object;
-import io.grpc.ManagedChannel;
-
-public class DirectoryClient {
- private ReaderGrpc.ReaderBlockingStub readerClient;
- private WriterGrpc.WriterBlockingStub writerClient;
- private ImporterGrpc.ImporterBlockingStub importerClient;
- private ExporterGrpc.ExporterBlockingStub exporterClient;
- private ManagedChannel channel;
-
- public DirectoryClient(ManagedChannel channel) {
- this.readerClient = ReaderGrpc.newBlockingStub(channel);
- this.writerClient = WriterGrpc.newBlockingStub(channel);
- this.importerClient = ImporterGrpc.newBlockingStub(channel);
- this.exporterClient = ExporterGrpc.newBlockingStub(channel);
- this.channel = channel;
- }
-
- public ReaderGrpc.ReaderBlockingStub getReaderClient() {
- return readerClient;
- }
-
- public WriterGrpc.WriterBlockingStub getWriterClient() {
- return writerClient;
- }
-
- public ImporterGrpc.ImporterBlockingStub getImporterClient() {
- return importerClient;
- }
-
- public ExporterGrpc.ExporterBlockingStub getExporterClient() {
- return exporterClient;
- }
- class Result {
- private T[] results;
- private String nextPageToken;
-
- public Result(T[] results, String nextPageToken) {
- this.results = results;
- this.nextPageToken = nextPageToken;
- }
-
- public T[] getResults() {
- return results;
- }
-
- public String getNextPageToken() {
- return nextPageToken;
- }
- }
-
- public Result