You can create an RDF store that uses graph-level access control.
Determine the DB2® data types for the RDF object values for these predicates. Currently, only the DB2 VARCHAR data type is supported.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import com.ibm.rdf.store.StoreManager;
public class CreateStoreGraphAccessControl {
/* Access to the graph is controlled based on the
* following two RDF predicates.
*/
private final static String APPID =
"http://myapp.net/xmlns/APPID";
private final static String CONTEXTID =
"http://myapp.net/xmlns/CONTEXTID";
/**
* The DB2 data type for these predicates is assigned.
*/
private final static String APPID_DATATYPE = "VARCHAR(60)";
private final static String CONTEXTID_DATATYPE = "VARCHAR(60)";
/*
* Create a java.util.properties file that lists these two
* properties and their data types, where
* propertyName is the RDF predicate and
* propertyValue is the data type for the RDF predicate.
*/
private static Properties filterPredicateProps = new
Properties();
static {
filterPredicateProps.setProperty(APPID, APPID_DATATYPE);
filterPredicateProps.setProperty(CONTEXTID,
CONTEXTID_DATATYPE);
}
public static void main(String[] args) throws SQLException {
Connection conn = null;
// Get a connection to the DB2 database.
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
conn = DriverManager.getConnection(
"jdbc:db2://localhost:50000/dbrdf",
"db2admin", "db2admin");
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
/*
* Create the store with the access control predicates.
*/
StoreManager.createStore(conn, "db2admin",
"SampleAccessControl", null,
filterPredicateProps);
}
}