|
30 | 30 | import com.atomgraph.linkeddatahub.server.security.AgentContext; |
31 | 31 | import com.atomgraph.linkeddatahub.server.util.AuthorizationParams; |
32 | 32 | import com.atomgraph.linkeddatahub.vocabulary.ACL; |
| 33 | +import com.atomgraph.linkeddatahub.vocabulary.FOAF; |
33 | 34 | import com.atomgraph.linkeddatahub.vocabulary.LACL; |
34 | 35 | import com.atomgraph.spinrdf.vocabulary.SPIN; |
35 | 36 | import jakarta.inject.Inject; |
|
51 | 52 | import org.apache.jena.query.ResultSetRewindable; |
52 | 53 | import org.apache.jena.rdf.model.Model; |
53 | 54 | import org.apache.jena.rdf.model.ModelFactory; |
| 55 | +import org.apache.jena.rdf.model.ResIterator; |
54 | 56 | import org.apache.jena.rdf.model.Resource; |
55 | 57 | import org.apache.jena.rdf.model.ResourceFactory; |
56 | 58 | import org.apache.jena.vocabulary.RDF; |
@@ -126,13 +128,25 @@ public Response get(@QueryParam(QUERY) Query unused, |
126 | 128 | authPss.setParams(new AuthorizationParams(getApplication().getAdminApplication().getBase(), accessTo, agent).get()); |
127 | 129 |
|
128 | 130 | Model authModel = getApplication().getAdminApplication().getService().getSPARQLClient().loadModel(authPss.asQuery()); |
| 131 | + |
| 132 | + // filter out authorizations with acl:accessToClass foaf:Agent - all agents already have that access |
| 133 | + ResIterator agentClassIter = authModel.listSubjectsWithProperty(ACL.agentClass, FOAF.Agent); |
| 134 | + try |
| 135 | + { |
| 136 | + agentClassIter.toList().forEach((auth) -> authModel.removeAll(auth, null, null)); |
| 137 | + } |
| 138 | + finally |
| 139 | + { |
| 140 | + agentClassIter.close(); |
| 141 | + } |
| 142 | + |
129 | 143 | // special case where the agent is the owner of the requested document - automatically grant acl:Read/acl:Append/acl:Write access |
130 | 144 | if (isOwner(accessTo, agent)) |
131 | 145 | { |
132 | 146 | log.debug("Agent <{}> is the owner of <{}>, granting acl:Read/acl:Append/acl:Write access", agent, accessTo); |
133 | 147 | authModel.add(createOwnerAuthorization(accessTo, agent).getModel()); |
134 | 148 | } |
135 | | - |
| 149 | + |
136 | 150 | return getResponseBuilder(authModel).build(); |
137 | 151 | } |
138 | 152 | finally |
|
0 commit comments