← Back to plugin index

Database Credential Persister

Description
Configurable credential persister and iterator using a database table as credential-repository.

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:
  1. 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.
  2. 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.
Type name
DatabaseCredentialPersister
Class
com.airlock.iam.core.misc.impl.persistency.db.DatabaseCredentialPersister
May be used by
Properties
SQL Data Source (sqlDataSource)
Description
Defines how connections to the database are obtained.
Attributes
Plugin-Link
Mandatory
Assignable plugins
Credential Table Name (credentialTableName)
Description
The name of the database table containing the credential data (and often also user data).
Attributes
String
Mandatory
Suggested values
medusa_user, medusa_token
Col User Name (colUserName)
Description
The name of the database column with the username. This column is used to search the credential given the user's name.
Attributes
String
Mandatory
Suggested values
username
User Name Resolve Query (userNameResolveQuery)
Description
An SQL query that returns a primary key for the user table given the user name.
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.

Attributes
String
Optional
Example
SELECT u.id FROM user u, person p WHERE p.id = u.person_id and p.contractId = ?
Col Binary Credential Data (colBinaryCredentialData)
Description
The name of the database column with the current credential data's binary credential data. This database field must be able to store the appropriate amount of binary data (depending on the credential). The data type of this column is expected to be 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".
Attributes
String
Optional
Example
tokenSeed
Example
tanHashes
Example
token_list
Col String Credential Data (colStringCredentialData)
Description
The name of the database column with the current credential data's string type credential data. This database field must be able to store the appropriate amount of string data (depending on the credential). The data type of this column is expected to be 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".
Attributes
String
Optional
Suggested values
mtan_number, cert_subject_cn, oathotp_data, securid_user
Col Credential Serial (colCredentialSerial)
Description
The name of the database column with the current credential data's serial number. This database field must be able to store the appropriate amount of string data (depending on the credential). The data type of this column is expected to be VARCHAR or CHAR.
Attributes
String
Optional
Suggested values
cert_serial, oathotp_serial, securid_serial
Col Credential Not Active After (colCredentialNotActiveAfter)
Description
The name of the database column indicating the point in time after which the current credential is considered no more active. The type of this column either DATETIME or TIMESTAMP.
Attributes
String
Optional
Example
active_until
Example
tokenExpiryDate
Col Credential Not Active Before (colCredentialNotActiveBefore)
Description
The name of the database column indicating the point in time prior to which the current credential is considered active yet. The type of this column either DATETIME or TIMESTAMP.
Attributes
String
Optional
Example
tokenActivationDate
Example
valid_since
Col Credential Delivery Date (colCredentialDeliveryDate)
Description
The name of the database column with the date and time of the latest credential delivery. This column type is either DATETIME or TIMESTAMP
Attributes
String
Optional
Suggested values
mtan_del_date, cert_del_date, oathotp_del_date
Col Credential Generation Date (colCredentialGenerationDate)
Description
The name of the database column with the date and time of the latest credential generation or assignment. This column type is either DATETIME or TIMESTAMP
Attributes
String
Optional
Suggested values
mtan_ass_date, cert_ass_date, oathotp_gen_date
Col Next Binary Credential Data (colNextBinaryCredentialData)
Description
The name of the database column with the next credential data's binary credential data. This database field must be able to store the appropriate amount of binary data (depending on the credential). The data type of this column is expected to be 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".
Attributes
String
Optional
Example
tokenSeed
Example
tanHashes
Example
token_list
Col Next String Credential Data (colNextStringCredentialData)
Description
The name of the database column with the next credential data's string type credential data. This database field must be able to store the appropriate amount of string data (depending on the credential). The data type of this column is expected to be 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".
Attributes
String
Optional
Example
tokenUserInAce
Example
bas64TanHash
Col Next Credential Serial (colNextCredentialSerial)
Description
The name of the database column with the next credential data's serial number. This database field must be able to store the appropriate amount of string data (depending on the credential). The data type of this column is expected to be VARCHAR or CHAR.
Attributes
String
Optional
Example
serial
Example
token_serial
Col Next Credential Not Active After (colNextCredentialNotActiveAfter)
Description
The name of the database column indicating the point in time after which the next credential is considered no more active. The type of this column either DATETIME or TIMESTAMP.
Attributes
String
Optional
Example
active_until
Example
tokenExpiryDate
Col Next Credential Not Active Before (colNextCredentialNotActiveBefore)
Description
The name of the database column indicating the point in time prior to which the next credential is considered active yet. The type of this column either DATETIME or TIMESTAMP.
Attributes
String
Optional
Example
tokenActivationDate
Example
valid_since
Col Next Credential Delivery Date (colNextCredentialDeliveryDate)
Description
The name of the database column with the date and time of the (latest) delivery of the next credential item. This column type is either DATETIME or TIMESTAMP
Attributes
String
Optional
Example
latest_token_delivery
Example
card_letter_delivery
Col Next Credential Generation Date (colNextCredentialGenerationDate)
Description
The name of the database column with the date and time of the latest credential generation or assignment. This column type is either DATETIME or TIMESTAMP
Attributes
String
Optional
Example
matrix_letter_generation
Example
card_assignment_date
Col Credential Active (colCredentialActive)
Description
The name of the database column with the flag indicating whether the credential is active or not. This field refers to the 'type' of credential for the user, not to a particular instance. If a current and a next credential data item exist for this credential type, deactivating this field concerns both credential data items. If only one credential data item should be deactivated, the fields not-active-before and not-active-after are required. Inactive credentials may not be used by the callers. This column type is either 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.
Attributes
String
Optional
Example
active
Example
tokenActive
Col Other Credentials Delivery Timestamps (colOtherCredentialsDeliveryTimestamps)
Description
Comma-separated list of column names with the delivery dates of other credentials. This information may be used in order to delay the delivery time for credentials so no two credentials of the same user are delivered the same day.
Attributes
String
Optional
Example
password_delivery
Example
password_delivery,iak_delivery
Col Credential Ordered Flag (colCredentialOrderedFlag)
Description
The name of the database column with the flag indicating whether a new credential should be generated or assigned for the user. This column type is either CHAR or NUMBER. The value "0" is treated as false, any other value is treated as true.
Attributes
String
Optional
Suggested values
mtan_order_new, cert_order_new, oathotp_order_new
Col Credential Ordered User (colCredentialOrderedUser)
Description
The name of the database column with the user by whom the new credential was ordered to be generated or assigned for the user. This column type is either CHAR or VARCHAR.
Attributes
String
Optional
Suggested values
mtan_order_user, cert_order_user, oathotp_order_user
Col Credential Ordered Date (colCredentialOrderedDate)
Description
The name of the database column with the date of when the new credential was ordered to be generated or assigned for the user. This column type is either DATETIME or TIMESTAMP.
Attributes
String
Optional
Suggested values
mtan_order_date, cert_order_date, oathotp_order_date
Additional Where Clause (additionalWhereClause)
Description
Optional SQL query part that is added to the where clause when searching the credentials by user name.
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"

Attributes
String
Optional
Example
deleted = 0
Example
group = 'remoteUsers' AND verified = 1
Search Condition Query (searchConditionQuery)
Description
A way to limit the set of valid credential records with an arbitrary SQL query. (See also configuration property "additional-where-clause": it offers a different, slightly more efficient but less powerful way to limit the set of valid credential records).

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.

Attributes
String
Optional
Example
SELECT p.valid FROM PERSON p WHERE p.person_no = ${person_no}
Additional Iterator Where Clause (additionalIteratorWhereClause)
Description
Same as property "additional-where-clause" except that it is used as where part when iterating over the credentials.
Attributes
String
Optional
Example
deleted = 0
Example
group = 'remoteUsers' AND verified = 1
Iterator Query (iteratorQuery)
Description
This query is used to get all user ids (or all matching user ids) instead of the default generated query defined by the user table, the username column and the context data fields.

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!

Attributes
String
Optional
Example
SELECT p.id from PERSON p, User u where u.person_id = p.id
Context Data Items (contextDataItems)
Description
A list of context data items that are fetched and returned to the caller together with the credential.
Attributes
Plugin-List
Optional
Assignable plugins
Additional Context Data (additionalContextData)
Description
This selector allows to read context data from other tables by executing the specified query. The selector of this configuration property specifies the name of the context data variable to be read. The value of this configuration property may be empty (no effect) or any valid SQL query. You can use the values of the user record (Record selected from table specified by property 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}

Attributes
Plugin-List
Optional
Assignable plugins
Col Deleted (colDeleted)
Description
The name of a binary column that marks a record as deleted. A record that has been marked as deleted is no more found by the persister.
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.
Attributes
String
Optional
Suggested values
deleted
Col Version Id (colVersionId)
Description
Name of a database column containing a numerical version id that is automatically incremented by one when a record is changed.
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.

Attributes
String
Optional
Suggested values
rowVersionId
Col Record Modification Date (colRecordModificationDate)
Description
Name of a database column with the date and time this record was modified. The timestamp is written by this plugin at the time the record is modified by this plugin.

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.

Attributes
String
Optional
Suggested values
rowUpdateDate
Col Record Modification User (colRecordModificationUser)
Description
Name of a database column with the name of the system that modified the record. The name is determined by configuration property "record-modification-user" and is written by this plugin at the time the record is modified by this plugin.

Note that - if configured (see separate property) - the modification date may also be written to the database at the same time.

Attributes
String
Optional
Suggested values
rowUpdateUser
Record Modification User (recordModificationUser)
Description
Specifies a string (typically the name associated with the system using this plugin) that is written to the database fields specified by properties "col-record-insertion-user" and "col-record-modification-user" when this plugin creates or modifies a user record.
Attributes
String
Optional
Suggested values
AirlockIAM
YAML Template (with default values)

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: