Database Credential Persister
The database is accessed via JDBC. It fetches the data of a user by directly executing a prepared statement. Making changes persistent is achieved by multiple update statement executions on the user record within a transaction.
This plug-in is very flexible in that it allows you to specify extra where clauses and search filters to select the set of credential records.
Note: This persister also supports iteration over credentials.
How this plug-in finds a credential record
There are two ways how this plugin finds a credential record for getting data, updating data and deleting data. The credential record is always fetched using a select statement given a primary key and applying the configured filters (additional where clause). The two variants differ in how the primary key is determined:- The primary key for selecting the credential record is the username itself. This is by far the most common and most efficient method to obtain credential data.
- The primary key is determined by a separate query including the username. The query can be configured. This way of selecting the credential record is more flexible but results in an additional select statement.
sqlDataSource) credentialTableName) colUserName) userNameResolveQuery) Such a query is useful if the username (used on the login page) is not part of the user table.
The query must be such that - given the username - it returns one value that can be used as primary key in the user table. The query must contain one question mark (?) which will be substituted by the username (a string).
If the query returns no records, it results in the user not being found.
If the query returns more than one record, it results in the username being ambiguous.
If this property is not defined, the username itself is used as primary key in the user table (the usual and efficient way).
Note: If this property is defined credential insertion by this plugin is no more possible.
colBinaryCredentialData) BYTE or VARBYTE.
The presence of this property indicates that the credential data is stored in binary form and not in string form. If this property is set, this class returns (and expects) instances of CredentialBean returning false in method "CredentialBean.isCredentialDataStringType()".
You cannot specify both this property and property "col-string-credential-type".
colStringCredentialData) VARCHAR or CHAR.
The presence of this property indicates that the credential data is stored as string and not in binary form. If this property is set, this class returns (and expects) instances of CredentialBean returning true in method "CredentialBean.isCredentialDataStringType()".
You cannot specify both this property and property "col-binary-credential-type".
colCredentialSerial) VARCHAR or CHAR. colCredentialNotActiveAfter) DATETIME or TIMESTAMP. colCredentialNotActiveBefore) DATETIME or TIMESTAMP. colCredentialDeliveryDate) DATETIME or TIMESTAMP colCredentialGenerationDate) DATETIME or TIMESTAMP colNextBinaryCredentialData) BYTE or VARBYTE.
The presence of this property indicates that the credential data is stored in binary form and not in string form. If this property is set, this class returns (and expects) instances of CredentialBean returning false in method "CredentialBean.isCredentialDataStringType()".
You cannot specify both this property and property "col-string-credential-type".
colNextStringCredentialData) VARCHAR or CHAR.
The presence of this property indicates that the credential data is stored as string and not in binary form. If this property is set, this class returns (and expects) instances of CredentialBean returning true in method "CredentialBean.isCredentialDataStringType()".
You cannot specify both this property and property "col-binary-credential-type".
colNextCredentialSerial) VARCHAR or CHAR. colNextCredentialNotActiveAfter) DATETIME or TIMESTAMP. colNextCredentialNotActiveBefore) DATETIME or TIMESTAMP. colNextCredentialDeliveryDate) DATETIME or TIMESTAMP colNextCredentialGenerationDate) DATETIME or TIMESTAMP colCredentialActive) CHAR or NUMBER. The value "0" (zero) is treated as false, any other value is treated as true.
If the column is not specified, all credentials are considered to be active.
colOtherCredentialsDeliveryTimestamps) colCredentialOrderedFlag) CHAR or NUMBER. The value "0" is treated as false, any other value is treated as true. colCredentialOrderedUser) CHAR or VARCHAR. colCredentialOrderedDate) DATETIME or TIMESTAMP. additionalWhereClause) The SQL query without an additional where clause is "SELECT * FROM credential-table WHERE colusername = 'username'"(real values for "credential-table", "colusername" are taken from the configuration and "username" is taken from the credential object).
The SQL query with an additional where clause "xyz" is: "SELECT * FROM credential-table WHERE colusername = 'username' AND xyz".
Example: If the value of this configuration setting is "GROUP = 'a' AND COD = 1" the resulting query is "SELECT * FROM credential-table WHERE colusername = 'username' AND GROUP = 'a' AND COD = 1"
searchConditionQuery) After the credential has been found by username (and matching the optional additional where clause as specified by configuration property "additional-where-clause") the query specified by this configuration property is executed.
If the result of the query is "true" or "1", the credential record is considered valid. In all other cases, the credential record is not valid, i.e. the behaviour is as if the record did not exist.
The value of this configuration property can be empty (no effect) or any valid SQL query. You can use values of the user record (Record selected from table specified by configuration property "user-table-name" by user name and optionally additional where clause) in the query as follows: ${xxx} references the field (column) "xxx" from the selected user record.
Example:
In our example the selected user record has the following values (column name = value): user_id = 'freddy', person_no = 13, ... Further, there is a different database table "PERSON" which is referenced by the user table. The table "PERSON" has a column of type boolean called "valid" which indicates whether a person record is valid or not.
Consider the following value for this configuration property: SELECT p.valid FROM PERSON p WHERE p.person_no = ${person_no} Thus, when looking for the user record (given the username and the matching the optional additonal where part), the above query is executed where ${person_no} is substituted by the value 13 of field "person_no" of the selected user record.
additionalIteratorWhereClause) iteratorQuery) Specifying such a query is only necessary if the username cannot be used as primary key in the user table (this only if property "user-name-resolve-query" is specified).
The query must be such that it returns one-column records one username (userid) per row.
Note that his query is used both when returning all user ids and when returning only matching user ids (filtered by the user). Thus, the query must be such that LIKE-clauses against context data columns work. This usually means that you must join the result with the user table (even if the user id is not read from the usertable) so the LIKE-clauses can access the context data of the user table. Failing to do so will result in runtime SQL syntax exceptions!Note: If this property is specified, additional-iterator-clauses and the deleted flag is ignored. They must be part of the query itself!
contextDataItems) additionalContextData) user-table-name by user name) in the query as follows: ${xxx} refers to the field (column) xxx from the selected user record.
Note: These context data values are read only! When fetching credential records, the query will be executed for each credential and the values will be added to the context data container. Modified, new or deleted values will not be written when credential records are updated.
Also note that context data fields defined in configuration property context-data-columns override corresponding entries in this property.
Example:
SELECT p.mobile_no FROM person p WHERE p.person_no = ${person_no}
colDeleted) Note: If a credential is deleted and this property is defined, the record is marked as deleted and not really removed from the database! If this property is not defined and a credential is deleted, the record is deleted from the database. The type of this column is either
CHAR or NUMBER. The value "0" is treated as not deleted, any other value is treated as deleted. colVersionId) Such a technical column is used by some applications or libraries (such as Hibernate) to implement optimistic locking.
Note that this plugin still uses its own data-based optimistic locking mechanism. It just increments the value within a transaction in order to be compliant with other components' locking mechanisms.
The column must be of an integer type. Usually a long type is used.
colRecordModificationDate) The type of the column must be compatible with a timestamp.
Note that - if configured (see separate property) - user information may also be written to the database at the same time.
colRecordModificationUser) Note that - if configured (see separate property) - the modification date may also be written to the database at the same time.
recordModificationUser)
type: DatabaseCredentialPersister
id: DatabaseCredentialPersister-xxxxxx
displayName:
comment:
properties:
additionalContextData:
additionalIteratorWhereClause:
additionalWhereClause:
colBinaryCredentialData:
colCredentialActive:
colCredentialDeliveryDate:
colCredentialGenerationDate:
colCredentialNotActiveAfter:
colCredentialNotActiveBefore:
colCredentialOrderedDate:
colCredentialOrderedFlag:
colCredentialOrderedUser:
colCredentialSerial:
colDeleted:
colNextBinaryCredentialData:
colNextCredentialDeliveryDate:
colNextCredentialGenerationDate:
colNextCredentialNotActiveAfter:
colNextCredentialNotActiveBefore:
colNextCredentialSerial:
colNextStringCredentialData:
colOtherCredentialsDeliveryTimestamps:
colRecordModificationDate:
colRecordModificationUser:
colStringCredentialData:
colUserName:
colVersionId:
contextDataItems:
credentialTableName:
iteratorQuery:
recordModificationUser:
searchConditionQuery:
sqlDataSource:
userNameResolveQuery: