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 DataSourcedataSourceprivate List<ColumnMapper>mappersprivate JdbcSecurityRealmBuilderparentprivate Stringsql
-
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 JdbcSecurityRealmbuild()Builds a newJdbcSecurityRealminstance based on configuration defined for thisJdbcSecurityRealmBuilderinstance.(package private) QueryConfigurationbuildQuery()QueryBuilderfrom(DataSource dataSource)Defines theDataSourcefrom where connections are obtained.QueryBuilderprincipalQuery(String sql)A SQL SELECT statement that will be used to return data from a database based on the principal's name.JdbcSecurityRealmBuildersetProviders(Supplier<Provider[]> providers)Set the providers to be used by the realm.QueryBuilderwithMapper(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 theDataSourcefrom where connections are obtained.- Parameters:
dataSource- the data source.- Returns:
- this builder
-
principalQuery
public QueryBuilder principalQuery(String sql)
Description copied from class:JdbcSecurityRealmBuilderA 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:
principalQueryin classJdbcSecurityRealmBuilder- Parameters:
sql- the authentication query- Returns:
- this builder
-
setProviders
public JdbcSecurityRealmBuilder setProviders(Supplier<Provider[]> providers)
Description copied from class:JdbcSecurityRealmBuilderSet the providers to be used by the realm.- Overrides:
setProvidersin classJdbcSecurityRealmBuilder- Parameters:
providers- the providers to be used by the realm.- Returns:
- this builder.
-
build
public JdbcSecurityRealm build()
Description copied from class:JdbcSecurityRealmBuilderBuilds a newJdbcSecurityRealminstance based on configuration defined for thisJdbcSecurityRealmBuilderinstance.- Overrides:
buildin classJdbcSecurityRealmBuilder- Returns:
- the built realm
-
buildQuery
QueryConfiguration buildQuery()
-
-