Skip to content

Conversation

@acoburn
Copy link
Collaborator

@acoburn acoburn commented May 22, 2023

This introduces a utility function to make it easier to modify Access Control resources to support AccessGrants.

Eventually, this will become part of a stand-alone ACP module, but adding full support for ACP is beyond the scope of the 1.0 release. This, however, allows developers to interact more easily with ACRs within the 1.0 release timeframe.

A sample usage of this would be:

try (final SolidRDFSource resource = client.read(uri, SolidRDFSource.class)) {
    resource.getMetadata().getAcl().ifPresent(acl -> {
        try (final SolidRDFSource acr = client.read(acl, SolidRDFSource.class)) {
            AccessGrantUtils.accessControlPolicyTriples(acl, ACL.Read, ACL.Write)
                .forEach(acr.getGraph()::add);
            client.update(acr);
        }
    });
}

@acoburn acoburn requested a review from a team as a code owner May 22, 2023 19:14
@acoburn acoburn force-pushed the JCL-361-acr-update branch 2 times, most recently from 472eec8 to c4b993c Compare May 30, 2023 16:58
@acoburn acoburn force-pushed the JCL-361-acr-update branch from c4b993c to 7f70450 Compare May 31, 2023 11:52
final Set<String> supportedTypes;
if (AccessGrant.class.isAssignableFrom(clazz)) {
type = ACCESS_GRANT;
type = URI.create("SolidAccessGrant");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own understanding, in this case where the given string isn't a URI, what does the constructor do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a relative URI. Perfectly valid


// Access Control Resource
final IRI subject = asIRI(acl);
triples.add(rdf.createTriple(subject, a, asIRI(ACP.AccessControlResource)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this triple necessary? I assumed this type would be present by default in the ACR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Inrupt implementation, none of the type triples are strictly necessary. That said, a different impl may require them. Furthermore, the ACR for a resource may be empty, in which case the triple will not already be present.

In short: it never hurts to be explicit, and there may be cases where it is necessary

@acoburn acoburn merged commit ba97a28 into main Jun 1, 2023
@acoburn acoburn deleted the JCL-361-acr-update branch June 1, 2023 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants