Class QueryBuilder

java.lang.Object
org.wildfly.security.auth.realm.jdbc.JdbcSecurityRealmBuilder
org.wildfly.security.auth.realm.jdbc.QueryBuilder

public class QueryBuilder extends JdbcSecurityRealmBuilder
A builder class with different configuration options to configure queries.
Author:
Pedro Igor
  • Method Details

    • withMapper

      public QueryBuilder withMapper(ColumnMapper... mapper)
      Defines a mapper that will be applied to the query in order to map the returned columns to some internal representation.
      Parameters:
      mapper - the column mapper instance
      Returns:
      this builder
    • from

      public QueryBuilder from(DataSource dataSource)
      Defines the DataSource from where connections are obtained.
      Parameters:
      dataSource - the data source.
      Returns:
      this builder
    • principalQuery

      public QueryBuilder principalQuery(String sql)
      Description copied from class: JdbcSecurityRealmBuilder

      A SQL SELECT statement that will be used to return data from a database based on the principal's name.

      When authenticating, validating or obtaining credentials for a RealmIdentity, this query will be used. You must provide a SELECT with a single query parameter as follows:

          JdbcSecurityRealm securityRealm = JdbcSecurityRealm.builder().principalQuery("SELECT password FROM user_bcrypt_password where name = ?")
      

      Where the query parameter value would be the principal's name.

      Overrides:
      principalQuery in class JdbcSecurityRealmBuilder
      Parameters:
      sql - the authentication query
      Returns:
      this builder
    • setProviders

      public JdbcSecurityRealmBuilder setProviders(Supplier<Provider[]> providers)
      Description copied from class: JdbcSecurityRealmBuilder
      Set the providers to be used by the realm.
      Overrides:
      setProviders in class JdbcSecurityRealmBuilder
      Parameters:
      providers - the providers to be used by the realm.
      Returns:
      this builder.
    • build

      public JdbcSecurityRealm build()
      Description copied from class: JdbcSecurityRealmBuilder
      Builds a new JdbcSecurityRealm instance based on configuration defined for this JdbcSecurityRealmBuilder instance.
      Overrides:
      build in class JdbcSecurityRealmBuilder
      Returns:
      the built realm