public class TigaseCustomAuth extends AbstractAuthRepositoryWithCredentials implements DataSourceAware<DataRepository>, RepositoryVersionAware
{ call
then the server assumes this is a stored procedure call,
otherwise it is executed as a plain SQL query. Each configuration value is stripped from white characters on both
ends before processing.
';'
at the end of the query as many JDBC drivers get confused and the query
may not work for unknown obvious reason.
'?'
in the query. Refer to the
configuration parameters description for more details about what parameters are expected in each query.
add-user-query={ call TigAddUserPlainPw(?, ?) }
add-user-query=insert into users (user_id, password) values (?, ?)
RepositoryVersionAware.SchemaVersion
AuthRepository.AccountStatus, AuthRepository.DefaultCredentials, AuthRepository.SingleCredential
Repository.Meta, Repository.SchemaId
Modifier and Type | Field and Description |
---|---|
static String |
DEF_ACCOUNTSTATUS_KEY |
static String |
DEF_ACCOUNTSTATUS_QUERY |
static String |
DEF_ADDUSER_KEY
Query adding a new user to the database.
|
static String |
DEF_ADDUSER_QUERY |
static String |
DEF_CONNVALID_KEY
Query executing periodically to ensure active connection with the database.
|
static String |
DEF_DELUSER_KEY
Removes a user from the database.
|
static String |
DEF_DELUSER_QUERY |
static String |
DEF_DISABLEACCOUNT_KEY
Deprecated.
|
static String |
DEF_ENABLEACCOUNT_KEY
Deprecated.
|
static String |
DEF_GETPASSWORD_KEY
Retrieves user password from the database for given user_id (JID).
|
static String |
DEF_GETPASSWORD_QUERY |
static String |
DEF_INITDB_KEY
Database initialization query which is run after the server is started.
|
static String |
DEF_INITDB_QUERY |
static String |
DEF_LISTDISABLEDACCOUNTS_KEY |
static String |
DEF_LISTDISABLEDACCOUNTS_QUERY |
static String |
DEF_NONSASL_MECHS |
static String |
DEF_NONSASL_MECHS_KEY
Comma separated list of NON-SASL authentication mechanisms.
|
static String |
DEF_SASL_MECHS |
static String |
DEF_SASL_MECHS_KEY
Comma separated list of SASL authentication mechanisms.
|
static String |
DEF_UPDATEACCOUNTSTATUS_KEY |
static String |
DEF_UPDATEACCOUNTSTATUS_QUERY |
static String |
DEF_UPDATELOGINTIME_KEY |
static String |
DEF_UPDATEPASSWORD_KEY
Updates (changes) password for a given user_id (JID).
|
static String |
DEF_UPDATEPASSWORD_QUERY |
static String |
DEF_USERLOGIN_KEY
Performs user login.
|
static String |
DEF_USERLOGIN_QUERY |
static String |
DEF_USERLOGOUT_KEY
This query is called when user logs out or disconnects.
|
static String |
DEF_USERLOGOUT_QUERY |
static String |
DEF_USERS_COUNT_KEY |
static String |
DEF_USERS_COUNT_QUERY |
static String |
DEF_USERS_DOMAIN_COUNT_KEY |
static String |
DEF_USERS_DOMAIN_COUNT_QUERY |
static String |
NO_QUERY |
static String |
SP_STARTS_WITH |
DATA_KEY, DIGEST_ID_KEY, DIGEST_KEY, MACHANISM_KEY, PASSWORD_KEY, PROTOCOL_KEY, PROTOCOL_VAL_NONSASL, PROTOCOL_VAL_SASL, REALM_KEY, RESULT_KEY, SERVER_NAME_KEY, USER_ID_KEY
Constructor and Description |
---|
TigaseCustomAuth() |
Modifier and Type | Method and Description |
---|---|
void |
addUser(BareJID user,
String password) |
AuthRepository.AccountStatus |
getAccountStatus(BareJID user) |
Collection<String> |
getCredentialIds(BareJID user) |
Credentials |
getCredentials(BareJID user,
String credentialId) |
protected String |
getParamWithDef(Map<String,String> params,
String key,
String def) |
String |
getResourceUri()
getResourceUri method returns database connection string. |
long |
getUsersCount()
getUsersCount method is thread safe. |
long |
getUsersCount(String domain)
This method is only used by the server statistics component to report number of registered users for given
domain.
|
void |
initRepository(String connection_str,
Map<String,String> params)
Deprecated.
|
boolean |
isMechanismSupported(String domain,
String mechanism) |
void |
loggedIn(BareJID user)
Do some actions on repository, when user logs in.
|
void |
logout(BareJID user) |
boolean |
otherAuth(Map<String,Object> props) |
void |
queryAuth(Map<String,Object> authProps)
queryAuth returns mechanisms available for authentication. |
void |
removeCredential(BareJID user,
String credentialId) |
void |
removeUser(BareJID user) |
void |
setAccountStatus(BareJID user,
AuthRepository.AccountStatus value) |
void |
setDataSource(DataRepository data_repo)
Method called to provide class with instance of a data source.
|
void |
updateCredential(BareJID user,
String credentialId,
String password) |
void |
updatePassword(BareJID user,
String password) |
getCredentialsDecoder, getCredentialsEncoder, getPassword, setCredentialsCodecs
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getVersion, updateSchema
getUsernames, isUserDisabled, setUserDisabled
public static final String DEF_CONNVALID_KEY
select 1
public static final String DEF_INITDB_KEY
update tig_users set online_status = 0
public static final String DEF_ADDUSER_KEY
(user_id (JID), password)
insert into tig_users (user_id, user_pw) values (?, ?)
public static final String DEF_DELUSER_KEY
(user_id (JID))
delete from tig_users where user_id = ?
public static final String DEF_GETPASSWORD_KEY
(user_id (JID))
select user_pw from tig_users where user_id = ?
public static final String DEF_UPDATEPASSWORD_KEY
(password, user_id (JID))
update tig_users set user_pw = ? where user_id = ?
public static final String DEF_USERLOGIN_KEY
user-login-query
or get-password-query
.
user-login-query
is used. Normally this method should be only used
with plain text password authentication or sasl-plain.
(user_id (JID), password)
select user_id from tig_users where (user_id = ?) AND (user_pw = ?)
public static final String DEF_USERLOGOUT_KEY
(user_id (JID))
update tig_users, set online_status = online_status - 1 where user_id = ?
public static final String DEF_UPDATELOGINTIME_KEY
public static final String DEF_USERS_COUNT_KEY
public static final String DEF_USERS_DOMAIN_COUNT_KEY
public static final String DEF_LISTDISABLEDACCOUNTS_KEY
@Deprecated public static final String DEF_DISABLEACCOUNT_KEY
@Deprecated public static final String DEF_ENABLEACCOUNT_KEY
public static final String DEF_UPDATEACCOUNTSTATUS_KEY
public static final String DEF_ACCOUNTSTATUS_KEY
public static final String DEF_NONSASL_MECHS_KEY
password
and
digest
. digest
mechanism can work only with get-password-query
active and
only when password are stored in plain text format in the database.public static final String DEF_SASL_MECHS_KEY
PLAIN
, DIGEST-MD5
, CRAM-MD5
.
get-password-query
active and only when passwords are
stored in plain text format in the database.public static final String NO_QUERY
public static final String DEF_INITDB_QUERY
public static final String DEF_ADDUSER_QUERY
public static final String DEF_DELUSER_QUERY
public static final String DEF_GETPASSWORD_QUERY
public static final String DEF_UPDATEPASSWORD_QUERY
public static final String DEF_USERLOGIN_QUERY
public static final String DEF_USERLOGOUT_QUERY
public static final String DEF_USERS_COUNT_QUERY
public static final String DEF_USERS_DOMAIN_COUNT_QUERY
public static final String DEF_LISTDISABLEDACCOUNTS_QUERY
public static final String DEF_UPDATEACCOUNTSTATUS_QUERY
public static final String DEF_ACCOUNTSTATUS_QUERY
public static final String DEF_NONSASL_MECHS
public static final String DEF_SASL_MECHS
public static final String SP_STARTS_WITH
public void addUser(BareJID user, String password) throws TigaseDBException
addUser
in interface AuthRepository
TigaseDBException
public AuthRepository.AccountStatus getAccountStatus(BareJID user) throws TigaseDBException
getAccountStatus
in interface AuthRepository
TigaseDBException
public Credentials getCredentials(BareJID user, String credentialId) throws TigaseDBException
getCredentials
in interface AuthRepository
TigaseDBException
public String getResourceUri()
AuthRepository
getResourceUri
method returns database connection string.getResourceUri
in interface AuthRepository
String
value of database connection string.public Collection<String> getCredentialIds(BareJID user) throws TigaseDBException
getCredentialIds
in interface AuthRepository
TigaseDBException
public long getUsersCount()
getUsersCount
method is thread safe. It uses local variable for storing Statement
.getUsersCount
in interface AuthRepository
long
number of user accounts in database.public long getUsersCount(String domain)
AuthRepository
getUsersCount
in interface AuthRepository
domain
- for which get the statisticslong
number of registered users in the repository.@Deprecated public void initRepository(String connection_str, Map<String,String> params) throws DBInitException
Repository
resource_uri
parameter as the database connection string or via
params
map if the required repository parameters are more complex or both.initRepository
in interface Repository
connection_str
- value in most cases representing the database connection string.params
- is a Map
with repository properties necessary to initialize and perform all the
functions. The initialization parameters are implementation dependent.DBInitException
- if there was an error during repository initialization. Some implementations,
though, perform so called lazy initialization so even though there is a problem with the underlying repository it
may not be signaled through this method call.public boolean isMechanismSupported(String domain, String mechanism)
isMechanismSupported
in interface AuthRepository
isMechanismSupported
in class AbstractAuthRepositoryWithCredentials
public void loggedIn(BareJID user) throws TigaseDBException
AuthRepository
last_login_time
)loggedIn
in interface AuthRepository
user
- JID of logged user.TigaseDBException
- if an error occurspublic void logout(BareJID user) throws TigaseDBException
logout
in interface AuthRepository
TigaseDBException
public boolean otherAuth(Map<String,Object> props) throws TigaseDBException, AuthorizationException
otherAuth
in interface AuthRepository
TigaseDBException
AuthorizationException
public void queryAuth(Map<String,Object> authProps)
AuthRepository
queryAuth
returns mechanisms available for authentication.queryAuth
in interface AuthRepository
authProps
- a Map
value with parameters for authentication.public void removeCredential(BareJID user, String credentialId) throws TigaseDBException
removeCredential
in interface AuthRepository
TigaseDBException
public void removeUser(BareJID user) throws TigaseDBException
removeUser
in interface AuthRepository
TigaseDBException
public void setAccountStatus(BareJID user, AuthRepository.AccountStatus value) throws TigaseDBException
setAccountStatus
in interface AuthRepository
TigaseDBException
public void setDataSource(DataRepository data_repo) throws DBInitException
DataSourceAware
setDataSource
in interface DataSourceAware<DataRepository>
DBInitException
public void updateCredential(BareJID user, String credentialId, String password) throws TigaseDBException
updateCredential
in interface AuthRepository
TigaseDBException
public void updatePassword(BareJID user, String password) throws TigaseDBException
updatePassword
in interface AuthRepository
TigaseDBException
Copyright © 2004–2021 "Tigase, Inc.". All rights reserved.