Package org.pjdbc.drivers
Class SchemaValidationDriver
java.lang.Object
org.pjdbc.sql.AbstractDriver
org.pjdbc.sql.AbstractProxyDriver
org.pjdbc.drivers.SchemaValidationDriver
- All Implemented Interfaces:
Driver
@DriverCapability(prefix="schema",
description="Validates SQL statements against a defined schema (table/column whitelist or blacklist)",
capabilities={"security","validation"})
@DriverParameter(name="allowedTables",type=STRING,description="Semicolon-separated list of allowed table names (whitelist mode)") @DriverParameter(name="blockedTables",type=STRING,description="Semicolon-separated list of blocked table names (blacklist mode)") @DriverParameter(name="allowedColumns",type=STRING,description="Semicolon-separated list of allowed column patterns") @DriverParameter(name="blockedColumns",type=STRING,description="Semicolon-separated list of blocked column patterns") @DriverParameter(name="mode",type=STRING,description="Validation mode",defaultValue="whitelist",enumValues={"whitelist","blacklist","metadata"}) @DriverParameter(name="caseSensitive",type=BOOLEAN,description="Whether table/column names are case-sensitive",defaultValue="false") @DriverParameter(name="message",type=STRING,description="Custom error message prefix",defaultValue="SchemaValidationDriver") @DriverParameter(name="loadFromDb",type=BOOLEAN,description="Load allowed tables from database metadata",defaultValue="false") @DriverParameter(name="schemaPattern",type=STRING,description="Schema pattern for metadata loading") @DriverParameter(name="tableTypes",type=STRING,description="Semicolon-separated table types for metadata",defaultValue="TABLE;VIEW")
public class SchemaValidationDriver
extends AbstractProxyDriver
SchemaValidationDriver validates SQL statements against a defined schema.
URL format: jdbc:schema[param=value,...]:jdbc:target:...
Modes:
- whitelist - Only tables in allowedTables list are permitted
- blacklist - All tables except those in blockedTables list are permitted
- metadata - Load allowed tables from database metadata at connection time
Example URLs:
jdbc:schema[allowedTables=users;orders;products]:jdbc:postgresql://localhost/mydb jdbc:schema[blockedTables=audit_log;secrets,mode=blacklist]:jdbc:mysql://localhost/db jdbc:schema[mode=metadata,schemaPattern=public]:jdbc:postgresql://localhost/mydb jdbc:schema[blockedColumns=ssn;credit_card]:jdbc:postgresql://localhost/mydb
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration holder for schema validation parameters.static enumValidation mode for the schema driver. -
Driver Parameters
URL format:
jdbc:schema[param=value,...]:<target-url>Parameter Type Default Constraints Description allowedTablesstring - - Semicolon-separated list of allowed table names (whitelist mode) blockedTablesstring - - Semicolon-separated list of blocked table names (blacklist mode) allowedColumnsstring - - Semicolon-separated list of allowed column patterns blockedColumnsstring - - Semicolon-separated list of blocked column patterns modestring whitelistone of: "whitelist", "blacklist", "metadata" Validation mode caseSensitiveboolean false- Whether table/column names are case-sensitive messagestring SchemaValidationDriver- Custom error message prefix loadFromDbboolean false- Load allowed tables from database metadata schemaPatternstring - - Schema pattern for metadata loading tableTypesstring TABLE;VIEW- Semicolon-separated table types for metadata Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptsSubName(String subname) protected booleanacceptsSubProtocol(String subprotocol) connect(String url, Properties info) getSchemaConfig(Connection conn) Get the schema configuration for a connection.protected CallableStatementproxyCallableStatement(CallableStatement delegate, Connection conn) protected ConnectionproxyConnection(Connection delegate, String url, Properties info, Driver driver) protected PreparedStatementproxyPreparedStatement(PreparedStatement delegate, Connection conn) protected StatementproxyStatement(Statement delegate, Connection conn) Methods inherited from class org.pjdbc.sql.AbstractProxyDriver
getPropertyInfo, isCompositionValidationEnabled, isValidateParametersEnabled, proxyCallableStatement, proxyConnection, proxyConnection, proxyPreparedStatement, proxyResultSetMethods inherited from class org.pjdbc.sql.AbstractDriver
acceptsProtocol, acceptsURL, getMajorVersion, getMinorVersion, getParentLogger, getUrlParameter, getUrlParameter, getUrlParameters, jdbcCompliant, parseUrl, protocol, subname, subprotocol, validateParameters
-
Constructor Details
-
SchemaValidationDriver
public SchemaValidationDriver()
-
-
Method Details
-
acceptsSubProtocol
- Specified by:
acceptsSubProtocolin classAbstractDriver
-
acceptsSubName
- Overrides:
acceptsSubNamein classAbstractProxyDriver
-
connect
- Specified by:
connectin interfaceDriver- Overrides:
connectin classAbstractProxyDriver- Throws:
SQLException
-
proxyConnection
protected Connection proxyConnection(Connection delegate, String url, Properties info, Driver driver) throws SQLException - Overrides:
proxyConnectionin classAbstractProxyDriver- Throws:
SQLException
-
proxyStatement
- Overrides:
proxyStatementin classAbstractProxyDriver- Throws:
SQLException
-
proxyPreparedStatement
protected PreparedStatement proxyPreparedStatement(PreparedStatement delegate, Connection conn) throws SQLException - Overrides:
proxyPreparedStatementin classAbstractProxyDriver- Throws:
SQLException
-
proxyCallableStatement
protected CallableStatement proxyCallableStatement(CallableStatement delegate, Connection conn) throws SQLException - Overrides:
proxyCallableStatementin classAbstractProxyDriver- Throws:
SQLException
-
getSchemaConfig
Get the schema configuration for a connection.
-