use of org.apache.jena.fuseki.auth.Auth in project jena by apache.
the class FusekiConfig method oldStyleCompat.
/**
* Old style compatibility.
* For each endpoint in "endpoints1", ensure there is an endpoint on the dataset (endpoint name "") itself.
* Combine the authentication as "AND" of named endpoints authentication.
*/
private static Collection<Endpoint> oldStyleCompat(DataService.Builder dataService, Set<Endpoint> endpoints1) {
Map<Operation, Endpoint> endpoints3 = new HashMap<>();
endpoints1.forEach(ep -> {
Operation operation = ep.getOperation();
AuthPolicy auth = ep.getAuthPolicy();
if (!StringUtils.isEmpty(ep.getName())) {
if (endpoints3.containsKey(operation)) {
Endpoint ep1 = endpoints3.get(operation);
// Accumulate Authorization.
auth = AuthPolicyList.merge(ep1.getAuthPolicy(), auth);
Endpoint ep2 = Endpoint.create(ep.getOperation(), "", auth);
endpoints3.put(operation, ep2);
} else {
Endpoint ep2 = Endpoint.create(operation, "", auth);
endpoints3.put(operation, ep2);
}
}
});
// Now, after making all legacy endpoints, remove any that are explicit defined in endpoints1.
// Given the small numbers involved, it is easier to do it this way than
// additional logic in the first pass over endpoints1.
endpoints1.stream().filter(ep -> StringUtils.isEmpty(ep.getName())).forEach(ep -> endpoints3.remove(ep.getOperation()));
return endpoints3.values();
}
Aggregations