Skip to content

Commit 8ba0bf5

Browse files
committed
rml-io: Allow D2RQ without driver, username, password.
It may be useful for SQLite that does not require authentication.
1 parent 9a162e0 commit 8ba0bf5

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

src/main/java/burp/ls/LogicalSourceFactory.java

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,39 @@ public static LogicalSource createXMLSource(Resource ls, String mpath) {
120120
return source;
121121
}
122122

123+
private static RDBSource createRDBSource(Resource sourceNode) {
124+
Statement jdbcDSNStmt = sourceNode.getProperty(D2RQ.jdbcDSN);
125+
if (jdbcDSNStmt == null) {
126+
throw new RuntimeException("RDB source must have a d2rq:jdbcDSN property");
127+
}
128+
String jdbcDSN = jdbcDSNStmt.getLiteral().getString();
129+
130+
Statement jdbcDriverStmt = sourceNode.getProperty(D2RQ.jdbcDriver);
131+
String jdbcDriver = jdbcDriverStmt != null ? jdbcDriverStmt.getLiteral().getString() : null;
132+
133+
Statement usernameStmt = sourceNode.getProperty(D2RQ.username);
134+
String username = usernameStmt != null ? usernameStmt.getLiteral().getString() : null;
135+
136+
Statement passwordStmt = sourceNode.getProperty(D2RQ.password);
137+
String password = passwordStmt != null ? passwordStmt.getLiteral().getString() : null;
138+
139+
RDBSource source = new RDBSource();
140+
source.jdbcDSN = jdbcDSN;
141+
source.jdbcDriver = jdbcDriver;
142+
source.username = username;
143+
source.password = password;
144+
// If getNullValuesSource does not exist, use getNullValues or implement accordingly
145+
source.nulls.addAll(getNullValues(sourceNode));
146+
return source;
147+
}
148+
123149
public static LogicalSource createSQL2008TableSource(Resource ls, String mpath) {
124150
Resource s = ls.getPropertyResourceValue(RML.source);
125-
String jdbcDSN = s.getProperty(D2RQ.jdbcDSN).getLiteral().getString();
126-
String jdbcDriver = s.getProperty(D2RQ.jdbcDriver).getLiteral().getString();
127-
String username = s.getProperty(D2RQ.username).getLiteral().getString();
128-
String password = s.getProperty(D2RQ.password).getLiteral().getString();
129151

130152
Statement t = ls.getProperty(RML.iterator);
131153
String query = "(SELECT * FROM " + t.getLiteral() + ")";
132154

133-
RDBSource source = new RDBSource();
134-
source.jdbcDSN = jdbcDSN;
135-
source.jdbcDriver = jdbcDriver;
136-
source.username = username;
137-
source.password = password;
155+
RDBSource source = createRDBSource(s);
138156

139157
// Apache jena "escapes" double quotes, so "Name" becomes \"Name\"
140158
// which is internally stored as \\"Name\\". We thus need to remove
@@ -148,19 +166,11 @@ public static LogicalSource createSQL2008TableSource(Resource ls, String mpath)
148166

149167
public static LogicalSource createSQL2008QuerySource(Resource ls, String mpath) {
150168
Resource s = ls.getPropertyResourceValue(RML.source);
151-
String jdbcDSN = s.getProperty(D2RQ.jdbcDSN).getLiteral().getString();
152-
String jdbcDriver = s.getProperty(D2RQ.jdbcDriver).getLiteral().getString();
153-
String username = s.getProperty(D2RQ.username).getLiteral().getString();
154-
String password = s.getProperty(D2RQ.password).getLiteral().getString();
155169

156170
Statement t = ls.getProperty(RML.iterator);
157171
String query = t.getLiteral().toString();
158172

159-
RDBSource source = new RDBSource();
160-
source.jdbcDSN = jdbcDSN;
161-
source.jdbcDriver = jdbcDriver;
162-
source.username = username;
163-
source.password = password;
173+
RDBSource source = createRDBSource(s);
164174

165175
// Apache jena "escapes" double quotes, so "Name" becomes \"Name\"
166176
// which is internally stored as \\"Name\\". We thus need to remove

0 commit comments

Comments
 (0)