Skip to content
This repository was archived by the owner on Apr 22, 2022. It is now read-only.

Commit b24f976

Browse files
committed
add grantLOLook function and fix duplicated configuration of virtuso
1 parent f703eb0 commit b24f976

File tree

3 files changed

+53
-34
lines changed

3 files changed

+53
-34
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#Framework configuration files
2+
/src/main/webapp/WEB-INF/web.xml
3+
/src/main/resources/framework-configuration.ttl
4+
15
#Mac
26
.DS_Store
37

src/main/java/authentication/FrameworkConfiguration.java

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class FrameworkConfiguration {
4848
private String settingsGraph = "";
4949
private String initialSettingsGraph = "";
5050
private String groupsGraph = "";
51+
private String frameworkUri;
5152

5253
private static FrameworkConfiguration instance;
5354

@@ -75,7 +76,7 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
7576
String accountsOntologyFile = "framework-accounts-ontology.ttl";
7677

7778
// initialize parameters from context
78-
String frameworkUri = context.getInitParameter("framework-uri");
79+
instance.frameworkUri = context.getInitParameter("framework-uri");
7980

8081
instance.setFrameworkOntologyNS(context.getInitParameter("framework-ontology-ns"));
8182
instance.setAccountsOntologyNamespace(context.getInitParameter("accounts-ns"));
@@ -96,11 +97,10 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
9697
} catch (RiotException e) {
9798
throw new IOException("Malformed " + configurationFile + " file");
9899
}
99-
// get and set the properties framework configuration (endpoints and
100-
// credentials)
100+
// get the endpoint URL to use for the framework
101101
String query = "PREFIX lds: <http://stack.linkeddata.org/ldis-schema/> "
102-
+ " SELECT ?endpoint WHERE {" + " <" + frameworkUri + "> lds:integrates ?component ."
103-
+ " ?component lds:providesService ?service ."
102+
+ " SELECT ?endpoint WHERE {" + " <" + instance.getFrameworkUri()
103+
+ "> lds:integrates ?component ." + " ?component lds:providesService ?service ."
104104
+ " ?service a lds:SPARQLEndPointService ." + " ?service lds:serviceUrl ?endpoint }";
105105

106106
QueryExecution qexec = QueryExecutionFactory.create(query, configurationModel);
@@ -113,8 +113,9 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
113113
}
114114
qexec.close();
115115

116+
// get the endpoint for authenticated users, and user and password of the system framework
116117
query = "PREFIX lds: <http://stack.linkeddata.org/ldis-schema/>"
117-
+ " SELECT ?endpoint ?user ?password WHERE {" + " <" + frameworkUri
118+
+ " SELECT ?endpoint ?user ?password WHERE {" + " <" + instance.getFrameworkUri()
118119
+ "> lds:integrates ?component ." + " ?component lds:providesService ?service ."
119120
+ " ?service a lds:SecuredSPARQLEndPointService ."
120121
+ " ?service lds:serviceUrl ?endpoint ." + " ?service lds:user ?user ."
@@ -134,7 +135,7 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
134135

135136
// get and set the database configuration (Virtuoso)
136137
query = "PREFIX lds: <http://stack.linkeddata.org/ldis-schema/>"
137-
+ " SELECT ?connectionString ?user ?password WHERE {" + " <" + frameworkUri
138+
+ " SELECT ?connectionString ?user ?password WHERE {" + " <" + instance.getFrameworkUri()
138139
+ "> lds:integrates ?component ." + " ?component lds:providesService ?service ."
139140
+ " ?service a lds:StorageService ."
140141
+ " ?service lds:connectionString ?connectionString ." + " ?service lds:user ?user ."
@@ -151,12 +152,11 @@ public static synchronized FrameworkConfiguration getInstance(ServletContext con
151152
}
152153
qexec.close();
153154

154-
// get and set the named graphs
155+
// get and set the system named graphs
155156
query = "PREFIX sd: <http://www.w3.org/ns/sparql-service-description#> "
156157
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + "SELECT ?name ?label "
157158
+ "WHERE "
158159
+ "{ ?s sd:namedGraph ?o . ?o sd:name ?name . ?o sd:graph ?g . ?g rdfs:label ?label } ";
159-
160160
qexec = QueryExecutionFactory.create(query, configurationModel);
161161
results = qexec.execSelect();
162162
if (!results.hasNext())
@@ -193,7 +193,10 @@ else if ("groups".equals(soln.get("label").asLiteral().getString()))
193193
userManager.createUser(instance.getAuthSparqlUser(), instance.getAuthSparqlPassword());
194194
userManager.setDefaultRdfPermissions(instance.getAuthSparqlUser(), 3);
195195
userManager.grantRole(instance.getAuthSparqlUser(), "SPARQL_UPDATE");
196+
userManager.grantLOLook(instance.getAuthSparqlUser());
197+
// TODO: check if we still need to grant these to SPARQL user
196198
userManager.grantRole("SPARQL", "SPARQL_UPDATE");
199+
userManager.grantLOLook("SPARQL");
197200

198201
System.out.println("[INFO] System User was created ");
199202
} catch (Exception e) {
@@ -226,13 +229,13 @@ else if ("groups".equals(soln.get("label").asLiteral().getString()))
226229
System.out.println("[INFO] Default Graphs creation/configuration ");
227230

228231
// Read configuration files
229-
Model datrasetModel = ModelFactory.createDefaultModel();
232+
Model datasetModel = ModelFactory.createDefaultModel();
230233
Model componentsModel = ModelFactory.createDefaultModel();
231234
Model ontologyModel = ModelFactory.createDefaultModel();
232235
Model ontologyAccountsModel = ModelFactory.createDefaultModel();
233236

234237
try {
235-
datrasetModel.read(datasetsFile);
238+
datasetModel.read(datasetsFile);
236239
componentsModel.read(componentsFile);
237240
ontologyModel.read(ontologyFile);
238241
ontologyAccountsModel.read(accountsOntologyFile);
@@ -258,10 +261,32 @@ else if ("groups".equals(soln.get("label").asLiteral().getString()))
258261
userManager.setRdfGraphPermissions(instance.getAuthSparqlUser(), instance
259262
.getInitialSettingsGraph(), 3);
260263

264+
// join the settings files
261265
Model settingsModel = ModelFactory.createDefaultModel();
262-
settingsModel.add(datrasetModel);
266+
settingsModel.add(datasetModel);
263267
settingsModel.add(componentsModel);
264268
settingsModel.add(ontologyModel);
269+
270+
// add to settings virtuoso component without users/passwords
271+
queryString = "PREFIX foaf:<http://xmlns.com/foaf/0.1/> "
272+
+ "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
273+
+ "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
274+
+ "PREFIX lds:<http://stack.linkeddata.org/ldis-schema/>" + " CONSTRUCT { <"
275+
+ instance.getFrameworkUri() + "> ?p ?o . " + "<" + instance.getFrameworkUri()
276+
+ "> lds:integrates ?component ."
277+
+ "?component rdfs:label ?label . ?component rdf:type ?type . "
278+
+ "?component lds:providesService ?service . ?service rdf:type ?servicetype ."
279+
+ "?service lds:serviceUrl ?serviceUrl .} " + " WHERE { <"
280+
+ instance.getFrameworkUri() + "> ?p ?o ." + "<" + instance.getFrameworkUri()
281+
+ "> lds:integrates ?component ."
282+
+ "?component rdfs:label ?label . ?component rdf:type ?type . "
283+
+ "?component lds:providesService ?service . ?service rdf:type ?servicetype ."
284+
+ "?service lds:serviceUrl ?serviceUrl .}";
285+
qexec = QueryExecutionFactory.create(queryString, configurationModel);
286+
Model triples = qexec.execConstruct();
287+
settingsModel.add(triples);
288+
qexec.close();
289+
265290
// write the initial settings model (default settings for new
266291
// users)
267292
ByteArrayOutputStream os = new ByteArrayOutputStream();
@@ -485,4 +510,13 @@ public String getFrameworkOntologyNS() {
485510
public void setFrameworkOntologyNS(String frameworkOntologyNS) {
486511
this.frameworkOntologyNS = frameworkOntologyNS;
487512
}
513+
514+
public String getFrameworkUri() {
515+
return frameworkUri;
516+
}
517+
518+
public void setFrameworkUri(String frameworkUri) {
519+
this.frameworkUri = frameworkUri;
520+
}
521+
488522
}

src/main/resources/framework-components.ttl

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,9 @@
5050
dcterms:hasVersion "2.0"^^xsd:string ;
5151
gkg:publicEndpoint :VirtuosoEndpoint ;
5252
gkg:authEndpoint :VirtuosoAuthSPARQLEndpoint ;
53-
lds:integrates :Virtuoso, :Facete, :Limes, :Sparqlify, :TripleGeo, :GeoLift, :OntoWiki, :Mappify ;
53+
lds:integrates :Facete, :Limes, :Sparqlify, :TripleGeo, :GeoLift, :OntoWiki, :Mappify ;
5454
foaf:homepage <http://localhost:8080/generator> .
5555

56-
:Virtuoso
57-
a lds:StackComponent ;
58-
rdfs:label "Service URL"^^xsd:string ;
59-
dcterms:hasVersion "7.0"^^xsd:string ;
60-
lds:providesService :VirtuosoConductor, :VirtuosoAutSPARQLEndpoint, :VirtuosoEndpoint;
61-
foaf:homepage <http://virtuoso.openlinksw.com/> .
62-
63-
:VirtuosoConductor
64-
a lds:StorageService ;
65-
lds:serviceUrl <http://10.0.0.84:8890/conductor> .
66-
67-
:VirtuosoAuthSPARQLEndpoint
68-
a lds:SecuredSPARQLEndPointService ;
69-
lds:serviceUrl <http://10.0.0.84:8890/sparql-auth> .
70-
71-
:VirtuosoEndpoint
72-
a lds:SPARQLEndPointService ;
73-
lds:serviceUrl <http://10.0.0.84:8890/sparql> .
74-
7556
:Sparqlify
7657
a lds:StackComponent ;
7758
rdfs:label "Sparqlify"^^xsd:string ;
@@ -81,7 +62,7 @@
8162

8263
:SparqlifyService
8364
a lds:ExplorationService ;
84-
lds:serviceUrl <http://144.76.166.111:8080/sparqlify/> .
65+
lds:serviceUrl <http://localhost:8080/sparqlify/> .
8566

8667
:Facete
8768
a lds:StackComponent ;
@@ -131,7 +112,7 @@
131112
foaf:homepage <http://aksw.org/Projects/OntoWiki.html> .
132113
:OntoWikiService
133114
a lds:AuthoringService ;
134-
lds:serviceUrl <http://144.76.166.111/ontowiki> .
115+
lds:serviceUrl <http://192.168.2.18/ontowiki> .
135116

136117
:Mappify
137118
a lds:StackComponent ;

0 commit comments

Comments
 (0)