acciente / oacc-core

OACC (Object ACcess Control) is an advanced Java Application Security Framework
http://oaccframework.org/
Apache License 2.0
107 stars 23 forks source link

How to initialize OACC, when using SQLite? #31

Closed smotti closed 7 years ago

smotti commented 7 years ago

The getting started tutorial mentions that OACC needs to be initialized with SQLAccessControlSystemInitializer. Though this fails for SQLite because it has no concept of a database schema. And under RDBMS specific-notes, it says to pass null for schemaName but there's no way to do so via the command line. Even if -dbschema is not provided SQLAccessControlSystemInitializer defaults to TEST_OACC (see here).

For -dbschema="":

Exception in thread "main" java.lang.IllegalArgumentException: Invalid database schema name - it can only consist of (optionally delimited) unicode word characters, or be null, but it was:
        at com.acciente.oacc.sql.internal.SchemaNameValidator.assertValid(SchemaNameValidator.java:74)
        at com.acciente.oacc.sql.internal.SQLAccessControlSystemInitializer.initializeOACC(SQLAccessControlSystemInitializer.java:34)
        at com.acciente.oacc.sql.SQLAccessControlSystemInitializer.initializeOACC(SQLAccessControlSystemInitializer.java:92)
        at com.acciente.oacc.sql.SQLAccessControlSystemInitializer.main(SQLAccessControlSystemInitializer.java:79)

For -dbschema=:

Exception in thread "main" java.lang.IllegalArgumentException: Invalid database schema name - it can only consist of (optionally delimited) unicode word characters, or be null, but it was:
        at com.acciente.oacc.sql.internal.SchemaNameValidator.assertValid(SchemaNameValidator.java:74)
        at com.acciente.oacc.sql.internal.SQLAccessControlSystemInitializer.initializeOACC(SQLAccessControlSystemInitializer.java:34)
        at com.acciente.oacc.sql.SQLAccessControlSystemInitializer.initializeOACC(SQLAccessControlSystemInitializer.java:92)
        at com.acciente.oacc.sql.SQLAccessControlSystemInitializer.main(SQLAccessControlSystemInitializer.java:79)
adinath-raveendraraj commented 7 years ago

smotti, I have not gotten a chance to investigate this yet, but I am pretty sure you have run into a "defect" in the command line tool, since it does not allow specifying a null value.

If you look at the source for the command line tool, you will see that it simply calls the method: com.acciente.oacc.sql.internal.SQLAccessControlSystemInitializer.initializeOACC(Connection connection, String dbSchema, String oaccRootPwd). Until we fix the command line tool for this, as a workaround, I suggest that you write a simple Java program with a main() to call the above method with your database connection, and where you can pass null to the dbSchema arg.

smotti commented 7 years ago

adinath-raveendraraj, that is what i did ;),