public class DummyRepository extends Object implements UserRepository, AuthRepository
Repository.MetaDATA_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, USERNAME_KEY| Constructor and Description |
|---|
DummyRepository() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDataList(BareJID user,
String subnode,
String key,
String[] list)
addDataList method adds mode entries to existing data list
associated with given key in repository under given node path. |
void |
addUser(BareJID user)
This
addUser method allows to add new user to repository. |
void |
addUser(BareJID user,
String password)
Describe
addUser method here. |
boolean |
digestAuth(BareJID user,
String digest,
String id,
String alg)
Deprecated.
|
String |
getData(BareJID user,
String key)
getData method returns a value associated with given key for
user repository in default subnode. |
String |
getData(BareJID user,
String subnode,
String key)
getData method returns a value associated with given key for
user repository in given subnode. |
String |
getData(BareJID user,
String subnode,
String key,
String def)
getData method returns a value associated with given key for
user repository in given subnode. |
String[] |
getDataList(BareJID user,
String subnode,
String key)
getDataList method returns array of values associated with
given key or null if given key does not exist for given user
ID in given node path. |
String[] |
getKeys(BareJID user)
getKeys method returns list of all keys stored in default user
repository node. |
String[] |
getKeys(BareJID user,
String subnode)
getKeys method returns list of all keys stored in given
subnode in user repository. |
String |
getPassword(BareJID user) |
String |
getResourceUri()
Returns a DB connection string or DB connection URI.
|
String[] |
getSubnodes(BareJID user)
getSubnodes method returns list of all root nodes for
given user. |
String[] |
getSubnodes(BareJID user,
String subnode)
getSubnodes method returns list of all direct subnodes from
given node. |
List<BareJID> |
getUsers()
This method is only used by the data conversion tools.
|
long |
getUsersCount()
This method is only used by the server statistics component to report
number of registered users.
|
long |
getUsersCount(String domain)
This method is only used by the server statistics component to report
number of registered users for given domain.
|
long |
getUserUID(BareJID user)
Returns a user unique ID number within the given repository.
|
void |
initRepository(String string,
Map<String,String> params)
The method is called to initialize the data repository.
|
boolean |
isUserDisabled(BareJID user) |
void |
logout(BareJID user)
Describe
logout method here. |
boolean |
otherAuth(Map<String,Object> authProps)
Describe
otherAuth method here. |
boolean |
plainAuth(BareJID user,
String password)
Deprecated.
|
void |
queryAuth(Map<String,Object> authProps)
queryAuth returns mechanisms available for authentication. |
void |
removeData(BareJID user,
String key)
removeData method removes pair (key, value) from user
repository in default repository node. |
void |
removeData(BareJID user,
String subnode,
String key)
removeData method removes pair (key, value) from user
repository in given subnode. |
void |
removeSubnode(BareJID user,
String subnode)
removeSubnode method removes given subnode with all subnodes
in this node and all data stored in this node and in all subnodes. |
void |
removeUser(BareJID user)
This
removeUser method allows to remove user and all his data
from user repository. |
void |
setData(BareJID user,
String key,
String value)
This
setData method sets data value for given user ID
associated with given key in default repository node. |
void |
setData(BareJID user,
String subnode,
String key,
String value)
setData method sets data value for given user ID in repository
under given node path and associates it with given key. |
void |
setDataList(BareJID user,
String subnode,
String key,
String[] list)
setDataList method sets list of values for given user
associated given key in repository under given node path. |
void |
setUserDisabled(BareJID user,
Boolean value) |
void |
updatePassword(BareJID user,
String password)
Describe
updatePassword method here. |
boolean |
userExists(BareJID user)
Method
userExists checks whether the user (or repository top node)
exists in the database. |
public void addDataList(BareJID user, String subnode, String key, String[] list)
UserRepositoryaddDataList method adds mode entries to existing data list
associated with given key in repository under given node path.
This method is very similar to setDataList(...) except it
doesn't remove existing data.addDataList in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
key - a String with which the specified values list is to
be associated.list - a String[] is an array of values to be associated
with the specified key.public void addUser(BareJID user)
UserRepositoryaddUser method allows to add new user to repository.
It must throw en exception UserExistsException if such
user already exists because user must be unique within user
repository data base.user id consists of user name and domain
address: username@domain.address.net for example.addUser in interface UserRepositoryuser - a BareJID value of user id consisting of user name
and domain address.public void addUser(BareJID user, String password) throws UserExistsException, TigaseDBException
AuthRepositoryaddUser method here.addUser in interface AuthRepositoryuser - a BareJID valuepassword - a String valueUserExistsException - if an error occursTigaseDBException - if an error occurs@Deprecated public boolean digestAuth(BareJID user, String digest, String id, String alg) throws UserNotFoundException, TigaseDBException, AuthorizationException
AuthRepositorydigestAuth method performs non-sasl, digest authentication
as described in non-sasl authentication
XEP-0078
For now it is empty and always returns false as I don't
have description for database with passwords.digestAuth in interface AuthRepositoryuser - a BareJID value of user namedigest - a String value password digest sumid - a String value session ID used for digest sum
calculation.alg - a String value of algorithm ID used for digest sum
calculation.boolean value true on successful
authentication, false on authentication failure.UserNotFoundException - if an given user name is not found in
the authentication repository.TigaseDBException - if an error occurs during during accessing
database;AuthorizationException - if an error occurs during authentication
process.public String getData(BareJID user, String subnode, String key, String def)
getData method returns a value associated with given key for
user repository in given subnode.
If key is not found in repository given default value is returned.
getData in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
key - a String with which the needed value is
associated.def - a String value which is returned in case if data
for specified key does not exixist in repository.String value of null always.public String getData(BareJID user, String subnode, String key)
getData method returns a value associated with given key for
user repository in given subnode.
If key is not found in repository null value is returned.
getData in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
key - a String with which the needed value is
associated.String value of null always.public String getData(BareJID user, String key)
getData method returns a value associated with given key for
user repository in default subnode.
If key is not found in repository null value is returned.
getData in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.key - a String with which the needed value is
associated.String value of null always.public String[] getDataList(BareJID user, String subnode, String key)
UserRepositorygetDataList method returns array of values associated with
given key or null if given key does not exist for given user
ID in given node path.getDataList in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
key - a String with which the needed values list is
associated.String[] valuepublic String[] getKeys(BareJID user, String subnode)
UserRepositorygetKeys method returns list of all keys stored in given
subnode in user repository.
There is a value (or list of values) associated with each key. It is up to
user (developer) to know what key keeps one value and what key keeps list
of values.getKeys in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
String[] valuepublic String[] getKeys(BareJID user)
UserRepositorygetKeys method returns list of all keys stored in default user
repository node.
There is some a value (or list of values) associated with each key. It is
up to user (developer) to know what key keeps one value and what key keeps
list of values.getKeys in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored or retrieved. User ID consists of user name and domain name.String[] valuepublic String getResourceUri()
UserRepositorygetResourceUri in interface AuthRepositorygetResourceUri in interface UserRepositoryString value representing database connection string.public String[] getSubnodes(BareJID user, String subnode)
UserRepositorygetSubnodes method returns list of all direct subnodes from
given node.getSubnodes in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
String[] value is an array of all direct subnodes.public String[] getSubnodes(BareJID user)
UserRepositorygetSubnodes method returns list of all root nodes for
given user.getSubnodes in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.String[] value is an array of all root
nodes for given user.public long getUserUID(BareJID user) throws TigaseDBException
UserRepositorygetUserUID in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored or retrieved. User ID consists of user name and domain name.TigaseDBException - if there is a problem with accessing user repository.public List<BareJID> getUsers()
UserRepositorygetUsers in interface UserRepositorypublic long getUsersCount()
UserRepositorygetUsersCount in interface AuthRepositorygetUsersCount in interface UserRepositorylong number of registered users in the repository.public long getUsersCount(String domain)
UserRepositorygetUsersCount in interface AuthRepositorygetUsersCount in interface UserRepositorylong number of registered users in the repository.public void initRepository(String string, Map<String,String> params)
Repositoryresource_uri
parameter as the database connection string or via params map if
the required repository parameters are more complex or both.initRepository in interface Repositorystring - 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.public void logout(BareJID user) throws UserNotFoundException, TigaseDBException
AuthRepositorylogout method here.logout in interface AuthRepositoryuser - a BareJID valueUserNotFoundException - if an error occursTigaseDBException - if an error occurspublic boolean otherAuth(Map<String,Object> authProps) throws UserNotFoundException, TigaseDBException, AuthorizationException
AuthRepositoryotherAuth method here.otherAuth in interface AuthRepositoryauthProps - a Map valueboolean valueUserNotFoundException - if an error occursTigaseDBException - if an error occursAuthorizationException - if an error occurs@Deprecated public boolean plainAuth(BareJID user, String password) throws UserNotFoundException, TigaseDBException, AuthorizationException
AuthRepositoryplainAuth method performs non-sasl, plain authentication
as described in non-sasl authentication
XEP-0078.plainAuth in interface AuthRepositoryuser - a BareJID value of user namepassword - a String value of plain user password.boolean value true on successful
authentication, false on authentication failure.UserNotFoundException - if an given user name is not found in
the authentication repository.TigaseDBException - if an error occurs during during accessing
database;AuthorizationException - if an error occurs during authentication
process.public void queryAuth(Map<String,Object> authProps)
AuthRepositoryqueryAuth returns mechanisms available for authentication.queryAuth in interface AuthRepositoryauthProps - a Map value with parameters for authentication.public void removeData(BareJID user, String subnode, String key)
UserRepositoryremoveData method removes pair (key, value) from user
repository in given subnode.
If the key exists in user repository there is always a value
associated with this key - even empty String. If key does not
exist the null value is returned from repository backend or
given default value.removeData in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
key - a String for which the value is to be removed.public void removeData(BareJID user, String key)
UserRepositoryremoveData method removes pair (key, value) from user
repository in default repository node.
If the key exists in user repository there is always a value
associated with this key - even empty String. If key does not
exist the null value is returned from repository backend or
given default value.removeData in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.key - a String for which the value is to be removed.public void removeSubnode(BareJID user, String subnode)
UserRepositoryremoveSubnode method removes given subnode with all subnodes
in this node and all data stored in this node and in all subnodes.
Effectively it removes entire repository tree starting from given node.removeSubnode in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path to subnode which
has to be removed. Node path has the same form as directory path on file
system: /root/subnode1/subnode2.
public void removeUser(BareJID user)
UserRepositoryremoveUser method allows to remove user and all his data
from user repository.
If given user id does not exist UserNotFoundException must be
thrown. As one XMPP server can support many virtual internet
domains it is required that user id consists of user name and
domain address: username@domain.address.net for example.removeUser in interface AuthRepositoryremoveUser in interface UserRepositoryuser - a BareJID value of user id consisting of user name
and domain address.public void setData(BareJID user, String subnode, String key, String value)
UserRepositorysetData method sets data value for given user ID in repository
under given node path and associates it with given key.
If there already exists value for given key in given node, old value is
replaced with new value. No warning or exception is thrown in case if
methods overwrites old value.setData in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
key - a String with which the specified value is to be
associated.value - a String value to be associated with the
specified key.public void setData(BareJID user, String key, String value)
UserRepositorysetData method sets data value for given user ID
associated with given key in default repository node.
Default node is dependent on implementation and usually it is root user
node. If there already exists value for given key in given node, old value
is replaced with new value. No warning or exception is thrown in case if
methods overwrites old value.setData in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.key - a String with which the specified value is to be
associated.value - a String value to be associated with the
specified key.public void setDataList(BareJID user, String subnode, String key, String[] list)
UserRepositorysetDataList method sets list of values for given user
associated given key in repository under given node path.
If there already exist values for given key in given node, all old values are
replaced with new values. No warning or exception is thrown in case if
methods overwrites old value.setDataList in interface UserRepositoryuser - a BareJID value of user ID for which data must be
stored. User ID consists of user name and domain name.subnode - a String value is a node path where data is
stored. Node path has the same form as directory path on file system:
/root/subnode1/subnode2.
key - a String with which the specified values list is to
be associated.list - a String[] is an array of values to be associated
with the specified key.public void updatePassword(BareJID user, String password) throws UserNotFoundException, TigaseDBException
AuthRepositoryupdatePassword method here.updatePassword in interface AuthRepositoryuser - a BareJID valuepassword - a String valueUserNotFoundExceptionTigaseDBException - if an error occurspublic boolean userExists(BareJID user)
UserRepositoryuserExists checks whether the user (or repository top node)
exists in the database. The method doesn't throw any exception nor it creates
the user in case it is missing. It just checks whether the user is already
in the database.
Please don't overuse this method. All other methods
throw UserNotFoundException exception in case the user is missing
for which you executed the method. The exception is thrown unless
userAutoCreate property is set to true. In such case the exception
is never thrown and the methods are executed for given parameters prior to
creating user entry if it is missing.
Therefore this method should be used only to check whether the account exists
without creating it.userExists in interface UserRepositoryuser - a BareJID valueboolean valuepublic String getPassword(BareJID user) throws UserNotFoundException, TigaseDBException
getPassword in interface AuthRepositoryUserNotFoundExceptionTigaseDBExceptionpublic boolean isUserDisabled(BareJID user) throws UserNotFoundException, TigaseDBException
isUserDisabled in interface AuthRepositoryUserNotFoundExceptionTigaseDBExceptionpublic void setUserDisabled(BareJID user, Boolean value) throws UserNotFoundException, TigaseDBException
setUserDisabled in interface AuthRepositoryUserNotFoundExceptionTigaseDBExceptionCopyright © 2017 "Tigase, Inc.". All rights reserved.