Skip to content

Conversation

@hanicz
Copy link
Contributor

@hanicz hanicz commented Dec 19, 2025

…ls into DataSourceFactory

KNOX-3202 - Add support for Oracle DB as a Token State backend

What changes were proposed in this pull request?

  • Added com.oracle.database.jdbc.ojdbc11 dependency with provided scope.
  • Refactored JDBCUtils into factory pattern so every class has its clear responsibilities.
  • Introduced a new enum for database types.
  • Created new sql files to separate derby, oracle and common DDL scripts. This removes the on-the-fly replace calls on a single DDL script.
  • Added new unit tests for Oracle database type.
  • Added Oracle DB support for RemoteConfigDatabase as well.

How was this patch tested?

mvn clear verify

Below manual tests:
I started up Knox with a specific database type, created a new token, queried that token on the token management UI and also verified in the DB.
Tested oracle, derby, mysql, postgres and mariadb locally with docker images

Oracle: gvenzl/oracle-free jdbc:oracle:thin:localhost:1521/FREEPDB1
MariaDB: mariadb:11 jdbc:mariadb://127.0.0.1:3306/testdb?user=testuser&password=testpass
MySQL: mysql:8.4
PostgreSQL: postgres:16

Oracle:

    <property>
        <name>gateway.service.tokenstate.impl</name>
        <value>org.apache.knox.gateway.services.token.impl.JDBCTokenStateService</value>
    </property>
    <property>
        <name>gateway.database.type</name>
        <value>oracle</value>
    </property>
    <property>
        <name>gateway.database.port</name>
        <value>1521</value>
    </property>
    <property>
        <name>gateway.database.host</name>
        <value>localhost</value>
    </property>
    <property>
        <name>gateway.database.name</name>
        <value>FREEPDB1</value>
    </property>
    
    OR
    
    <property>
        <name>gateway.database.connection.url</name>
        <value>jdbc:oracle:thin:localhost:1521/FREEPDB1</value>
    </property>
install/knox-3.0.0-SNAPSHOT/bin/knoxcli.sh generate-jwk --saveAlias knox.token.hash.key
install/knox-3.0.0-SNAPSHOT/bin/knoxcli.sh create-aliases --alias gateway_database_user --value SYSTEM --alias gateway_database_password --value test
install/knox-3.0.0-SNAPSHOT/bin/knoxcli.sh create-aliases --alias gateway_database_user --value appuser --alias gateway_database_password --value apppass
Screenshot 2025-12-19 at 8 29 50 Screenshot 2025-12-19 at 8 29 57

Copy link
Contributor

@smolnar82 smolnar82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, please test/update the SQL files in RemoteConfigDatabase too.

@github-actions
Copy link

github-actions bot commented Dec 19, 2025

Test Results

7 tests   7 ✅  1s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 7a75d66.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@smolnar82 smolnar82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hanicz hanicz merged commit 5cdf8e6 into apache:master Dec 19, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants