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
-
-
Field Summary
Fields Modifier and Type Field Description private DataSource
dataSource
private List<ColumnMapper>
mappers
private JdbcSecurityRealmBuilder
parent
private String
sql
-
Constructor Summary
Constructors Constructor Description QueryBuilder(String sql, JdbcSecurityRealmBuilder parent)
Construct new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JdbcSecurityRealm
build()
Builds a newJdbcSecurityRealm
instance based on configuration defined for thisJdbcSecurityRealmBuilder
instance.(package private) QueryConfiguration
buildQuery()
QueryBuilder
from(DataSource dataSource)
Defines theDataSource
from where connections are obtained.QueryBuilder
principalQuery(String sql)
A SQL SELECT statement that will be used to return data from a database based on the principal's name.JdbcSecurityRealmBuilder
setProviders(Supplier<Provider[]> providers)
Set the providers to be used by the realm.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.-
Methods inherited from class org.wildfly.security.auth.realm.jdbc.JdbcSecurityRealmBuilder
setHashCharset
-
-
-
-
Field Detail
-
sql
private final String sql
-
parent
private final JdbcSecurityRealmBuilder parent
-
mappers
private List<ColumnMapper> mappers
-
dataSource
private DataSource dataSource
-
-
Constructor Detail
-
QueryBuilder
QueryBuilder(String sql, JdbcSecurityRealmBuilder parent)
Construct new instance.- Parameters:
sql
- (must not benull
)parent
- (must not benull
)
-
-
Method Detail
-
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 theDataSource
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 classJdbcSecurityRealmBuilder
- 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 classJdbcSecurityRealmBuilder
- Parameters:
providers
- the providers to be used by the realm.- Returns:
- this builder.
-
build
public JdbcSecurityRealm build()
Description copied from class:JdbcSecurityRealmBuilder
Builds a newJdbcSecurityRealm
instance based on configuration defined for thisJdbcSecurityRealmBuilder
instance.- Overrides:
build
in classJdbcSecurityRealmBuilder
- Returns:
- the built realm
-
buildQuery
QueryConfiguration buildQuery()
-
-