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

Commit 126bc0a

Browse files
author
taleksashina
committed
Merge remote-tracking branch 'remotes/origin/master' into ontos-ldiw-acc
2 parents 7dddc2c + 92a11f7 commit 126bc0a

File tree

8 files changed

+181
-54
lines changed

8 files changed

+181
-54
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: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,81 @@
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/> .
56+
:Sparqlify
57+
a lds:StackComponent ;
58+
rdfs:label "Sparqlify"^^xsd:string ;
59+
lds:providesService :SparqlifyService ;
60+
lds:version "0.1-SNAPSHOT"^^xsd:string ;
61+
foaf:homepage <http://aksw.org/Projects/Sparqlify.html> .
6262

63-
:VirtuosoConductor
64-
a lds:StorageService ;
65-
lds:serviceUrl <http://localhost:8890/conductor> .
63+
:SparqlifyService
64+
a lds:ExplorationService ;
65+
lds:serviceUrl <http://localhost:8080/sparqlify/> .
6666

67-
:VirtuosoAuthSPARQLEndpoint
68-
a lds:SecuredSPARQLEndPointService ;
69-
lds:serviceUrl <http://localhost:8890/sparql-auth> .
67+
:Facete
68+
a lds:StackComponent ;
69+
rdfs:label "Facete"^^xsd:string ;
70+
lds:providesService :FaceteService ;
71+
lds:version "0.1-SNAPSHOT"^^xsd:string ;
72+
foaf:homepage <http://aksw.org/Projects/Facete.html> .
73+
:FaceteService
74+
a lds:ExplorationService ;
75+
lds:serviceUrl <http://cstadler.aksw.org/facete2/> .
7076

71-
:VirtuosoEndpoint
72-
a lds:SPARQLEndPointService ;
73-
lds:serviceUrl <http://localhost:8890/sparql> .
77+
:Limes
78+
a lds:StackComponent ;
79+
rdfs:label "Limes Linking Service"^^xsd:string ;
80+
lds:providesService :LimesService;
81+
lds:version "0.6.4"^^xsd:string ;
82+
foaf:homepage <http://aksw.org/Projects/LIMES.html> .
83+
:LimesService
84+
a lds:InterlinkingService ;
85+
lds:serviceUrl <http://localhost:8080/Limes-Service> .
86+
87+
:TripleGeo
88+
a lds:StackComponent ;
89+
rdfs:label "TripleGeo"^^xsd:string ;
90+
lds:providesService :TripleGeoService ;
91+
lds:version "1.0"^^xsd:string ;
92+
foaf:homepage <https://web.imis.athena-innovation.gr/redmine/projects/geoknow_public/wiki/TripleGeo> .
93+
:TripleGeoService
94+
a lds:ExtractionService ;
95+
lds:serviceUrl <http://localhost:8080/TripleGeo-Service> .
96+
97+
:GeoLift
98+
a lds:StackComponent ;
99+
rdfs:label "GeoLift"^^xsd:string ;
100+
lds:providesService :GeoLiftService ;
101+
lds:version "0.6.4"^^xsd:string ;
102+
foaf:homepage <https://github.com/AKSW/GeoLift> .
103+
:GeoLiftService
104+
a lds:EnrichmentService ;
105+
lds:serviceUrl <http://localhost:8080/GeoLift-Service> .
106+
107+
:OntoWiki
108+
a lds:StackComponent ;
109+
rdfs:label "OntoWiki"^^xsd:string ;
110+
lds:providesService :OntoWikiService ;
111+
lds:version "0.9.10-1"^^xsd:string ;
112+
foaf:homepage <http://aksw.org/Projects/OntoWiki.html> .
113+
:OntoWikiService
114+
a lds:AuthoringService ;
115+
lds:serviceUrl <http://192.168.2.18/ontowiki> .
116+
117+
:Mappify
118+
a lds:StackComponent ;
119+
rdfs:label "Mappify"^^xsd:string ;
120+
lds:providesService :MappifyService ;
121+
lds:version "0.9.10-1"^^xsd:string ;
122+
foaf:homepage <https://github.com/GeoKnow/Mappify> .
123+
:MappifyService
124+
a lds:ExplorationService ;
125+
lds:serviceUrl <http://cstadler.aksw.org/mappify2/> .
74126

75-
:D2RQ
127+
:D2RQ
76128
a lds:StackComponent ;
77129
rdfs:label "D2RQ"^^xsd:string ;
78130
lds:providesService :D2RQService ;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
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 ;
32-
gkg:authEndpoint :VirtuosoAutSPARQLEndpoint ;
32+
gkg:authEndpoint :VirtuosoAuthSPARQLEndpoint ;
3333
lds:integrates :Virtuoso ;
3434
foaf:homepage <http://localhost:8080/generator> .
3535

3636
:Virtuoso
3737
a lds:StackComponent ;
3838
rdfs:label "Service URL"^^xsd:string ;
3939
dcterms:hasVersion "7.0"^^xsd:string ;
40-
lds:providesService :VirtuosoConductor , :VirtuosoAutSPARQLEndpoint, :VirtuosoEndpoint;
40+
lds:providesService :VirtuosoConductor , :VirtuosoAuthSPARQLEndpoint, :VirtuosoEndpoint;
4141
foaf:homepage <http://virtuoso.openlinksw.com/> .
4242

4343
:VirtuosoConductor
@@ -47,7 +47,7 @@
4747
lds:connectionString "jdbc:virtuoso://***REMOVED***:1111/"^^xsd:string;
4848
lds:user "***REMOVED***""^^xsd:string .
4949

50-
:VirtuosoAutSPARQLEndpoint
50+
:VirtuosoAuthSPARQLEndpoint
5151
a lds:SecuredSPARQLEndPointService ;
5252
lds:password "***REMOVED***"^^xsd:string ;
5353
lds:serviceUrl <http://***REMOVED***:8890/sparql-auth> ;
@@ -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>

0 commit comments

Comments
 (0)