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

Commit 9a70b9a

Browse files
author
jj
committed
Merge branch 'master' of [email protected]:ontos-lds.git
Conflicts: src/main/resources/framework-components.ttl
2 parents af85fcd + 92a11f7 commit 9a70b9a

File tree

8 files changed

+83
-29
lines changed

8 files changed

+83
-29
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

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ These option will not install any integrated component from the stack and you re
1616

1717
1. Make a copy of the `src/main/resources/framework-configuration-template.ttl` to `src/main/resources/framework-configuration.ttl` and provide the ***REMOVED*** data.
1818

19-
1. Make a copy of the `src/main/webapp/WEB-INF/web-template.xml` to `src/main/webapp/WEB-INF/web.xml` and provide the ***REMOVED*** data.
19+
2. Have a clean triple store and make sure to have a user create in the lds:StorageService, the lds:SecuredSPARQLEndPointService user will be automatically created
20+
21+
3. Make a copy of the `src/main/webapp/WEB-INF/web-template.xml` to `src/main/webapp/WEB-INF/web.xml` and provide the ***REMOVED*** data.
2022

2123

2224
Note that the endpoint has to support [UPDATE](http://www.w3.org/TR/2013/REC-sparql11-update-20130321/) service and [Graph Store HTTP Protocol](http://www.w3.org/TR/2013/REC-sparql11-http-rdf-update-20130321/)

src/main/java/accounts/VirtuosoUserManager.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public class VirtuosoUserManager implements UserManager {
1313
private Connection connection;
1414

1515
/**
16-
* This class manages the User creation in virtuoso for authentication and
17-
* graph access control
16+
* This class manages the User creation in virtuoso for authentication and graph access control
1817
*
1918
* @param connectionString
2019
* Connection string to Virtuoso
@@ -30,46 +29,62 @@ public VirtuosoUserManager(String connectionString, String user, String password
3029
}
3130

3231
@Override
33-
public void createUser(String name, String password) throws Exception {
32+
public void createUser(String name, String password) throws ClassNotFoundException, SQLException {
3433
executeUpdate(getConnection(), "DB.DBA.USER_CREATE('" + name + "', '" + password + "')");
3534
// executeUpdate(getConnection(), "USER_SET_OPTION('" + name +
3635
// "', 'DAV_ENABLE', 1)");
3736
}
3837

3938
@Override
40-
public void dropUser(String name) throws Exception {
39+
public void dropUser(String name) throws ClassNotFoundException, SQLException {
4140
executeUpdate(getConnection(), "USER_DROP('" + name + "', 1)");
4241
}
4342

4443
@Override
45-
public void grantRole(String user, String role) throws Exception {
44+
public void grantRole(String user, String role) throws ClassNotFoundException, SQLException {
4645
executeUpdate(getConnection(), "GRANT " + role + " TO \"" + user + "\"");
4746
}
4847

4948
@Override
50-
public void setDefaultRdfPermissions(String user, int permissions) throws Exception {
49+
public void setDefaultRdfPermissions(String user, int permissions) throws ClassNotFoundException,
50+
SQLException {
5151
executeUpdate(getConnection(), "DB.DBA.RDF_DEFAULT_USER_PERMS_SET ('" + user + "', "
5252
+ permissions + ")");
5353
}
5454

5555
@Override
56-
public void setRdfGraphPermissions(String user, String graph, int permissions) throws Exception {
56+
public void setRdfGraphPermissions(String user, String graph, int permissions)
57+
throws ClassNotFoundException, SQLException {
5758
executeUpdate(getConnection(), "DB.DBA.RDF_GRAPH_USER_PERMS_SET ('" + graph + "', '" + user
5859
+ "', " + permissions + ")");
5960
}
6061

6162
@Override
62-
public void deleteRdfGraphPermissions(String user, String graph) throws Exception {
63+
public void deleteRdfGraphPermissions(String user, String graph) throws ClassNotFoundException,
64+
SQLException {
6365
executeUpdate(getConnection(), "DB.DBA.RDF_GRAPH_USER_PERMS_DEL ('" + graph + "', '" + user
6466
+ "')");
6567
}
6668

6769
@Override
68-
public void setDefaultGraphPermissions(String graph, int permissions) throws Exception {
70+
public void setDefaultGraphPermissions(String graph, int permissions)
71+
throws ClassNotFoundException, SQLException {
6972
executeUpdate(getConnection(), "DB.DBA.RDF_GRAPH_USER_PERMS_SET ('" + graph + "', 'nobody', "
7073
+ permissions + ")");
7174
}
7275

76+
/**
77+
* This function grant L_O_LOOK in virtuoso which was required to solve the error: Virtuoso 42000
78+
* Error SR186: No permission to execute dpipe DB.DBA.L_O_LOOK with user ID 106, group ID 106
79+
*
80+
* @param user
81+
* @throws ClassNotFoundException
82+
* @throws SQLException
83+
*/
84+
public void grantLOLook(String user) throws ClassNotFoundException, SQLException {
85+
executeUpdate(getConnection(), "GRANT EXECUTE ON DB.DBA.L_O_LOOK TO '" + user + "'");
86+
}
87+
7388
private Connection getConnection() throws ClassNotFoundException, SQLException {
7489
if (connection == null || connection.isClosed()) {
7590
Class.forName(jdbcDriver);

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
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

5656
:Virtuoso
@@ -81,7 +81,7 @@
8181

8282
:SparqlifyService
8383
a lds:ExplorationService ;
84-
lds:serviceUrl <http://144.76.166.111:8080/sparqlify/> .
84+
lds:serviceUrl <http://localhost:8080/sparqlify/> .
8585

8686
:Facete
8787
a lds:StackComponent ;
@@ -131,7 +131,7 @@
131131
foaf:homepage <http://aksw.org/Projects/OntoWiki.html> .
132132
:OntoWikiService
133133
a lds:AuthoringService ;
134-
lds:serviceUrl <http://144.76.166.111/ontowiki> .
134+
lds:serviceUrl <http://localhost/ontowiki> .
135135

136136
:Mappify
137137
a lds:StackComponent ;

src/main/resources/framework-configuration-template.ttl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
rdfs:comment "This resource contains all the configuration required by the application"^^xsd:string ;
2727
rdfs:label "GeoKnowGeneator"^^xsd:string ;
2828
dcterms:hasVersion "2.0"^^xsd:string ;
29-
lds:password "***REMOVED***""^^xsd:string ; # an admin user for the webapp
29+
lds:password "***REMOVED***""^^xsd:string ; # an admin user for the webapp NOT IMPLEMENTED YET
3030
lds:user "***REMOVED***""^^xsd:string ;
3131
gkg:publicEndpoint :VirtuosoEndpoint ;
3232
gkg:authEndpoint :VirtuosoAuthSPARQLEndpoint ;
@@ -132,4 +132,3 @@
132132
dcterms:created "2014-04-12"^^xsd:date;
133133
void:sparqlEndpoint <http://10.0.0.63:8890/sparql> ]
134134
.
135-

src/main/webapp/WEB-INF/web-template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,4 @@
179179
<mime-type>application/rdf+xml</mime-type>
180180
</mime-mapping>
181181

182-
</web-app>
182+
</web-app>

src/main/webapp/popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
================================================== -->
5050
<!-- Placed at the end of the document so the pages load faster -->
5151
<!-- <script src="lib/jquery/jquery-1.7.2.min.js"></script> -->
52-
5352
<script src="lib/jquery/jquery-1.9.1.js"></script>
5453
<script src="lib/jquery/jquery-ui-1.10.1.custom.min.js"></script>
5554

@@ -59,6 +58,7 @@
5958
<script src="lib/angularjs/angular-route.js"></script>
6059
<script src="lib/modal-master/bootstrap-modal.js"></script>
6160
<script src="lib/modal-master/bootstrap-modalmanager.js"></script>
61+
<script src="js/config.js"></script>
6262
<script src="js/app.js"></script>
6363
<!-- services for the different modules/pages -->
6464
<script src="js/services/config.js"></script>

0 commit comments

Comments
 (0)