Package com.inrupt.client.accessgrant
Class AccessGrantClient
java.lang.Object
com.inrupt.client.accessgrant.AccessGrantClient
A client for interacting with and managing Access Grant Resources.
This client will require a suitable
Session
object, typically an OpenID-based session:
URI issuer = URI.create("https://issuer.example");
Session openid = OpenIdSession.ofIdToken(idToken);
AccessGrantClient client = new AccessGrantClient(issuer).session(session);
URI resource = URI.create("https://storage.example/data/resource");
URI purpose = URI.create("https://purpose.example/1");
AccessCredentialQuery<AccessGrant> query = AccessCredentialQuery.newBuilder()
.resource(resource)
.mode("Read")
.purpose(purpose)
.build(AccessGrant.class);
client.query(query)
.thenApply(grants -> AccessGrantSession.ofAccessGrant(openid, grants.toArray(new AccessGrant[0])))
.thenApply(session -> SolidClient.getClient().session(session))
.thenAccept(cl -> {
// Do something with the Access Grant-scoped client
});
-
Constructor Summary
ConstructorDescriptionAccessGrantClient
(Client client, URI issuer) Create an access grant client.AccessGrantClient
(Client client, URI issuer, ClientCache<URI, com.inrupt.client.accessgrant.Metadata> metadataCache) Create an access grant client.AccessGrantClient
(URI issuer) Create an access grant client. -
Method Summary
Modifier and TypeMethodDescriptiondenyAccess
(AccessRequest request) Issue an access denial receipt based on an access request.<T extends AccessCredential>
CompletionStage<T>Fetch an access credential by identifier.grantAccess
(AccessRequest request) Issue an access grant based on an access request.<T extends AccessCredential>
CompletionStage<List<T>>query
(AccessCredentialQuery<T> query) Perform an Access Credentials query and returns 0 to N matching access credentials.<T extends AccessCredential>
CompletionStage<List<T>>Perform an Access Credentials query and returns 0 to N matching access credentials.Issue an access request.requestAccess
(URI recipient, Set<URI> resources, Set<String> modes, Set<URI> purposes, Instant expiration) Issue an access request.revoke
(AccessCredential credential) Revoke an access credential.Scope an access grant client to a particular session.verify
(AccessCredential credential) Verify an access grant or request.
-
Constructor Details
-
AccessGrantClient
Create an access grant client.- Parameters:
issuer
- the issuer
-
AccessGrantClient
Create an access grant client.- Parameters:
client
- the clientissuer
- the issuer
-
AccessGrantClient
public AccessGrantClient(Client client, URI issuer, ClientCache<URI, com.inrupt.client.accessgrant.Metadata> metadataCache) Create an access grant client.- Parameters:
client
- the clientissuer
- the issuermetadataCache
- the metadata cache
-
-
Method Details
-
session
Scope an access grant client to a particular session.- Parameters:
session
- the session- Returns:
- the scoped access grant client
-
requestAccess
Issue an access request.- Parameters:
request
- the parameters for the access request- Returns:
- the next stage of completion containing the resulting access request
-
requestAccess
public CompletionStage<AccessRequest> requestAccess(URI recipient, Set<URI> resources, Set<String> modes, Set<URI> purposes, Instant expiration) Issue an access request.- Parameters:
recipient
- the agent controlling access to the resourcesresources
- the resources to which this credential appliesmodes
- the access modes for this credentialpurposes
- the purposes of this credentialexpiration
- the expiration time of this credential- Returns:
- the next stage of completion containing the resulting access request
-
grantAccess
Issue an access grant based on an access request.- Parameters:
request
- the access request- Returns:
- the next stage of completion containing the issued access grant
-
denyAccess
Issue an access denial receipt based on an access request.- Parameters:
request
- the access request- Returns:
- the next stage of completion containing the issued access denial
-
verify
Verify an access grant or request.- Parameters:
credential
- the credential to verify- Returns:
- the next stage of completion containing the verification result in the form of a
AccessCredentialVerification
-
query
public <T extends AccessCredential> CompletionStage<List<T>> query(URI resource, URI creator, URI recipient, URI purpose, String mode, Class<T> clazz) Perform an Access Credentials query and returns 0 to N matching access credentials.- Type Parameters:
T
- the AccessCredential type- Parameters:
resource
- the resource identifier, may benull
creator
- the identifier for the agent who created the credential, may benull
recipient
- the identifier for the agent who is the recipient for the credential, may benull
purpose
- the access purpose, may benull
mode
- the access mode, may benull
clazz
- the AccessCredential type, eitherAccessGrant
orAccessRequest
- Returns:
- the next stage of completion, including the matched Access Credentials
-
query
Perform an Access Credentials query and returns 0 to N matching access credentials.- Type Parameters:
T
- the AccessCredential type- Parameters:
query
- the access credential query, nevernull
- Returns:
- the next stage of completion, including the matched Access Credentials
-
revoke
Revoke an access credential.- Parameters:
credential
- the access credential- Returns:
- the next stage of completion
-
fetch
Fetch an access credential by identifier. Return at most one access credential or throws an exception.- Type Parameters:
T
- the credential type- Parameters:
identifier
- the access credential identifierclazz
- the credential type, such asAccessGrant
orAccessRequest
- Returns:
- the next stage of completion, containing the access credential
-