Class JdbcSecurityRealmBuilder
- java.lang.Object
-
- org.wildfly.security.auth.realm.jdbc.JdbcSecurityRealmBuilder
-
- Direct Known Subclasses:
QueryBuilder
public class JdbcSecurityRealmBuilder extends Object
A builder class to that createsJdbcSecurityRealm
instances.- Author:
- Pedro Igor
-
-
Field Summary
Fields Modifier and Type Field Description private Charset
hashCharset
private Supplier<Provider[]>
providers
private List<QueryBuilder>
queries
-
Constructor Summary
Constructors Constructor Description JdbcSecurityRealmBuilder()
-
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.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
setHashCharset(Charset hashCharset)
Set the character set to use when converting the password string to a byte array.JdbcSecurityRealmBuilder
setProviders(Supplier<Provider[]> providers)
Set the providers to be used by the realm.
-
-
-
Field Detail
-
queries
private List<QueryBuilder> queries
-
hashCharset
private Charset hashCharset
-
-
Method Detail
-
build
public JdbcSecurityRealm build()
Builds a newJdbcSecurityRealm
instance based on configuration defined for thisJdbcSecurityRealmBuilder
instance.- Returns:
- the built realm
-
setProviders
public JdbcSecurityRealmBuilder setProviders(Supplier<Provider[]> providers)
Set the providers to be used by the realm.- Parameters:
providers
- the providers to be used by the realm.- Returns:
- this builder.
-
setHashCharset
public JdbcSecurityRealmBuilder setHashCharset(Charset hashCharset)
Set the character set to use when converting the password string to a byte array. Uses UTF-8 by default.- Parameters:
hashCharset
- the name of the character set (must not benull
)- Returns:
- this builder
-
principalQuery
public QueryBuilder principalQuery(String sql)
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.
- Parameters:
sql
- the authentication query- Returns:
- this builder
-
-