Package com.inrupt.client.accessgrant

Classes for working with Access Grants.

This module provides utilities for using Access Grants in Solid Applications. There are three primary classes used for this.

AccessGrant: this class represents either a SolidAccessGrant or a SolidAccessRequest. A developer can parse an AccessGrant from a String or InputStream in the following way:

   try (InputStream stream = fetchAccessGrant()) {
       AccessGrant accessGrant = AccessGrant.ofAccessGrant(data);

AccessGrantSession: this class can be used to build a Session object that uses Access Grants when negotiating for access tokens. These sessions will also need an OpenID-based session.

   AccessGrant accessGrant1 = AccessGrant.ofAccessGrant(data1);
   AccessGrant accessGrant2 = AccessGrant.ofAccessGrant(data2);

   Session openid = OpenIdSession.ofIdToken(idToken);
   Session session = AccessGrantSession.ofAccessGrant(openid, accessGrant1, accessGrant2);

   SolidClient client = SolidClient.getClient().session(session);

AccessGrantClient: this class can be used for managing the lifecycle of Access Grants: creation, deletion, revocation and query. 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");
   client.query(SOLID_ACCESS_GRANT, null, resource, null)
       .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