-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(java-sdk): add ABAC support to OpenFgaClient
- Loading branch information
1 parent
ced4d3d
commit a5d8eef
Showing
10 changed files
with
196 additions
and
86 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
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
31 changes: 31 additions & 0 deletions
31
config/clients/java/template/client-ClientRelationshipCondition.java.mustache
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,31 @@ | ||
{{>licenseInfo}} | ||
package {{invokerPackage}}; | ||
|
||
import {{modelPackage}}.RelationshipCondition; | ||
|
||
public class ClientRelationshipCondition { | ||
private String name; | ||
private Object context; | ||
public ClientRelationshipCondition name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public ClientRelationshipCondition context(Object context) { | ||
this.context = context; | ||
return this; | ||
} | ||
|
||
public Object getContext() { | ||
return context; | ||
} | ||
|
||
public RelationshipCondition asRelationshipCondition() { | ||
return new RelationshipCondition().name(name).context(context); | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
config/clients/java/template/client-ClientTupleKeyWithCondition.java.mustache
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,63 @@ | ||
{{>licenseInfo}} | ||
package {{invokerPackage}}; | ||
|
||
import {{modelPackage}}.ContextualTupleKeys; | ||
import {{modelPackage}}.TupleKey; | ||
import {{modelPackage}}.WriteRequestWrites; | ||
import java.util.Collection; | ||
import java.util.stream.Collectors; | ||
|
||
public class ClientTupleKeyWithCondition extends ClientTupleKey { | ||
private ClientRelationshipCondition condition; | ||
public ClientTupleKeyWithCondition condition(ClientRelationshipCondition condition) { | ||
this.condition = condition; | ||
return this; | ||
} | ||
|
||
public ClientRelationshipCondition getCondition() { | ||
return condition; | ||
} | ||
|
||
public TupleKey asTupleKey() { | ||
return new TupleKey() | ||
.user(getUser()) | ||
.relation(getRelation()) | ||
._object(getObject()) | ||
.condition(condition.asRelationshipCondition()); | ||
} | ||
|
||
public static ContextualTupleKeys asContextualTupleKeys(Collection<ClientTupleKeyWithCondition> tupleKeys) { | ||
return new ContextualTupleKeys() | ||
.tupleKeys(tupleKeys.stream() | ||
.map(ClientTupleKeyWithCondition::asTupleKey) | ||
.collect(Collectors.toList())); | ||
} | ||
|
||
public static WriteRequestWrites asWriteRequestWrites(Collection<ClientTupleKeyWithCondition> tupleKeys) { | ||
return new WriteRequestWrites() | ||
.tupleKeys(tupleKeys.stream() | ||
.map(ClientTupleKeyWithCondition::asTupleKey) | ||
.collect(Collectors.toList())); | ||
} | ||
|
||
/* Overrides for correct typing */ | ||
|
||
@Override | ||
public ClientTupleKeyWithCondition user(String user) { | ||
super.user(user); | ||
return this; | ||
} | ||
|
||
@Override | ||
public ClientTupleKeyWithCondition relation(String relation) { | ||
super.relation(relation); | ||
return this; | ||
} | ||
|
||
@Override | ||
public ClientTupleKeyWithCondition _object(String _object) { | ||
super._object(_object); | ||
return this; | ||
} | ||
} |
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 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
Oops, something went wrong.