-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe2074c
commit 1fe4fd4
Showing
25 changed files
with
1,592 additions
and
122 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 |
---|---|---|
@@ -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 |
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,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>directory-example</artifactId> | ||
<version>0.0.1</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.aserto</groupId> | ||
<artifactId>aserto-java</artifactId> | ||
<version>0.20.10</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>3.4.1</version> | ||
<configuration> | ||
<createDependencyReducedPom>false</createDependencyReducedPom> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<shadedArtifactAttached>true</shadedArtifactAttached> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"> | ||
</transformer> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>org.example.DirectoryExample</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
53 changes: 53 additions & 0 deletions
53
examples/directory-example/src/main/java/org/example/DirectoryExample.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,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", "[email protected]", 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<ObjectIdentifier> objects = List.of( | ||
Directory.buildObjectIdentifier("user", "[email protected]"), | ||
Directory.buildObjectIdentifier("user", "[email protected]")); | ||
|
||
GetObjectManyResponse getObjectManyRequest = directoryClient.getObjectManyRequest(objects); | ||
System.out.println(getObjectManyRequest); | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
3 changes: 2 additions & 1 deletion
3
src/main/java/com/aserto/AuthzClient.java → ...va/com/aserto/authorizer/AuthzClient.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
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,26 @@ | ||
package com.aserto.directory.v3; | ||
|
||
import com.aserto.directory.common.v3.Object; | ||
import com.aserto.directory.common.v3.ObjectIdentifier; | ||
import com.aserto.directory.common.v3.Relation; | ||
|
||
public class Directory { | ||
|
||
public static Object buildObject(String type, String id) { | ||
return Object.newBuilder().setType(type).setId(id).build(); | ||
} | ||
|
||
public static ObjectIdentifier buildObjectIdentifier(String type, String id) { | ||
return ObjectIdentifier.newBuilder().setObjectType(type).setObjectId(id).build(); | ||
} | ||
|
||
public static Relation buildRelation(String objectType, String objectId, String relation, String subjectType, String subjectId) { | ||
return Relation.newBuilder() | ||
.setObjectType(objectType) | ||
.setObjectId(objectId) | ||
.setRelation(relation) | ||
.setSubjectType(subjectType) | ||
.setSubjectId(subjectId) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.