AuthZ | Java SDK
Create tuple
tupleCreate(TupleCreateRequest request)Create tuples in the AuthZ Service. The request will fail if there is no schema or the tuples do not validate against the schema.
client.tupleCreate(
new TupleCreateRequest.Builder(
new Tuple[] {
new Tuple(
new Resource.Builder("folder").setId("folder_1").build(),
"owner",
new Subject.Builder("user").setId("user_1").build()
),
}
).build()
);
List tuples
tupleList(TupleListRequest request)Return a paginated list of filtered tuples. The filter is given in terms of a tuple. Fill out the fields that you want to filter. If the filter is empty it will return all the tuples.
var filter = new FilterTupleList();
filter.resourceType().set("user");
filter.resourceID().set("user_1");
var response = client.tupleList(new TupleListRequest.Builder().setFilter(filter).build());
Delete tuples
tupleDelete(TupleDeleteRequest request)Delete tuples in the AuthZ Service.
client.tupleDelete(
new TupleDeleteRequest.Builder(
new Tuple[] {
new Tuple(
new Resource.Builder("folder").setId("folder_1").build(),
"owner",
new Subject.Builder("user").setId("user_1").build()
),
}
).build()
);
Check authorization
check(CheckRequest request)Check if a subject has permission to perform an action on the resource.
var response = client.check(
new CheckRequest.Builder()
.setResource(new Resource.Builder("folder").setId("folder_1").build())
.setSubject(new Subject.Builder("user").setId("user_1").build())
.setAction("update")
.build()
);
List resources
listResources(ListResourcesRequest request)Given a type, action, and subject, list all the resources of the type that the subject has access to the action with.
var response = client.listResources(
new ListResourcesRequest.Builder(
"folder",
"edit",
new Subject.Builder("user").setId("user_1").build()
).build()
);
List subjects
listSubjects(ListSubjectsRequest request)Given a resource and an action, return the list of subjects who have access to the action for the given resource.
var response = client.listSubjects(
new ListSubjectsRequest.Builder(
new Resource.Builder("folder").setId("folder_1").build(),
"update"
).build()
);