Search in sources :

Example 1 with Auth

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();
}
Also used : Context(org.apache.jena.sparql.util.Context) java.util(java.util) RDF(org.apache.jena.vocabulary.RDF) Auth(org.apache.jena.fuseki.auth.Auth) AuthPolicy(org.apache.jena.fuseki.auth.AuthPolicy) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) FmtUtils(org.apache.jena.sparql.util.FmtUtils) StringUtils(org.apache.commons.lang3.StringUtils) StrUtils(org.apache.jena.atlas.lib.StrUtils) RDFParserRegistry.isRegistered(org.apache.jena.riot.RDFParserRegistry.isRegistered) JA(org.apache.jena.assembler.JA) DirectoryStream(java.nio.file.DirectoryStream) QuerySolution(org.apache.jena.query.QuerySolution) GraphUtils(org.apache.jena.sparql.util.graph.GraphUtils) Fuseki(org.apache.jena.fuseki.Fuseki) FusekiException(org.apache.jena.fuseki.FusekiException) Method(java.lang.reflect.Method) Path(java.nio.file.Path) Dataset(org.apache.jena.query.Dataset) BuildLib.nodeLabel(org.apache.jena.fuseki.build.BuildLib.nodeLabel) FusekiVocab(org.apache.jena.fuseki.server.FusekiVocab) Lang(org.apache.jena.riot.Lang) Logger(org.slf4j.Logger) Assembler(org.apache.jena.assembler.Assembler) Files(java.nio.file.Files) ActionService(org.apache.jena.fuseki.servlets.ActionService) BuildLib.getZeroOrOne(org.apache.jena.fuseki.build.BuildLib.getZeroOrOne) IOException(java.io.IOException) org.apache.jena.fuseki.server(org.apache.jena.fuseki.server) String.format(java.lang.String.format) RDFLanguages.filenameToLang(org.apache.jena.riot.RDFLanguages.filenameToLang) File(java.io.File) org.apache.jena.rdf.model(org.apache.jena.rdf.model) IRILib(org.apache.jena.atlas.lib.IRILib) FusekiConfigException(org.apache.jena.fuseki.FusekiConfigException) Collectors.toList(java.util.stream.Collectors.toList) Util(org.apache.jena.rdf.model.impl.Util) Node(org.apache.jena.graph.Node) XSDDatatype(org.apache.jena.datatypes.xsd.XSDDatatype) ReadWrite(org.apache.jena.query.ReadWrite) Pair(org.apache.jena.atlas.lib.Pair) AssemblerUtils(org.apache.jena.sparql.core.assembler.AssemblerUtils) JenaException(org.apache.jena.shared.JenaException) AuthPolicyList(org.apache.jena.fuseki.auth.AuthPolicyList) ResultSet(org.apache.jena.query.ResultSet) AuthPolicy(org.apache.jena.fuseki.auth.AuthPolicy)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 Method (java.lang.reflect.Method)1 DirectoryStream (java.nio.file.DirectoryStream)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 java.util (java.util)1 Collectors.toList (java.util.stream.Collectors.toList)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Assembler (org.apache.jena.assembler.Assembler)1 JA (org.apache.jena.assembler.JA)1 IRILib (org.apache.jena.atlas.lib.IRILib)1 Pair (org.apache.jena.atlas.lib.Pair)1 StrUtils (org.apache.jena.atlas.lib.StrUtils)1 XSDDatatype (org.apache.jena.datatypes.xsd.XSDDatatype)1 Fuseki (org.apache.jena.fuseki.Fuseki)1 FusekiConfigException (org.apache.jena.fuseki.FusekiConfigException)1 FusekiException (org.apache.jena.fuseki.FusekiException)1 Auth (org.apache.jena.fuseki.auth.Auth)1