Package tigase.mongodb
Class MongoRepository
java.lang.Object
tigase.db.AbstractAuthRepositoryWithCredentials
tigase.mongodb.MongoRepository
- All Implemented Interfaces:
tigase.db.AuthRepository
,tigase.db.DataSourceAware<MongoDataSource>
,tigase.db.Repository
,tigase.db.UserRepository
,tigase.db.util.RepositoryVersionAware
,MongoRepositoryVersionAware
public class MongoRepository
extends tigase.db.AbstractAuthRepositoryWithCredentials
implements tigase.db.UserRepository, tigase.db.DataSourceAware<MongoDataSource>, MongoRepositoryVersionAware
MongoRepository is implementation of UserRepository and AuthRepository which supports MongoDB data store.
- Author:
- andrzej
-
Nested Class Summary
Nested classes/interfaces inherited from interface tigase.db.AuthRepository
tigase.db.AuthRepository.AccountStatus, tigase.db.AuthRepository.DefaultCredentials, tigase.db.AuthRepository.SingleCredential
Nested classes/interfaces inherited from interface tigase.db.Repository
tigase.db.Repository.Meta, tigase.db.Repository.SchemaId
Nested classes/interfaces inherited from interface tigase.db.util.RepositoryVersionAware
tigase.db.util.RepositoryVersionAware.SchemaVersion
Nested classes/interfaces inherited from interface tigase.db.UserRepository
tigase.db.UserRepository.UserRemovedEvent
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
Fields inherited from interface tigase.db.AuthRepository
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataList
(tigase.xmpp.jid.BareJID user, String subnode, String key, String[] list) void
addUser
(tigase.xmpp.jid.BareJID user) void
protected byte[]
calculateHash
(String user) protected byte[]
generateId
(tigase.xmpp.jid.BareJID user) tigase.db.AuthRepository.AccountStatus
getAccountStatus
(tigase.xmpp.jid.BareJID user) long
getActiveUsersCountIn
(Duration duration) getCredentialIds
(tigase.xmpp.jid.BareJID user) tigase.auth.credentials.Credentials
getCredentials
(tigase.xmpp.jid.BareJID user, String credentialId) String[]
getDataList
(tigase.xmpp.jid.BareJID user, String subnode, String key) getDataMap
(tigase.xmpp.jid.BareJID user, String subnode) getDataMap
(tigase.xmpp.jid.BareJID user, String subnode, Function<String, T> converter) String[]
getKeys
(tigase.xmpp.jid.BareJID user) String[]
String[]
getSubnodes
(tigase.xmpp.jid.BareJID user) String[]
getSubnodes
(tigase.xmpp.jid.BareJID user, String subnode) List<tigase.xmpp.jid.BareJID>
getUsers()
long
long
getUsersCount
(String domain) long
getUserUID
(tigase.xmpp.jid.BareJID user) Deprecated.void
initRepository
(String resource_uri, Map<String, String> params) Deprecated.void
loggedIn
(tigase.xmpp.jid.BareJID jid) void
logout
(tigase.xmpp.jid.BareJID user) boolean
void
protected <T> List<T>
readAllDistinctValuesForField
(com.mongodb.client.MongoCollection<org.bson.Document> collection, String field, org.bson.Document crit) void
removeCredential
(tigase.xmpp.jid.BareJID user, String credentialId) void
removeData
(tigase.xmpp.jid.BareJID user, String key) void
removeData
(tigase.xmpp.jid.BareJID user, String subnode, String key) void
removeSubnode
(tigase.xmpp.jid.BareJID user, String subnode) void
removeUser
(tigase.xmpp.jid.BareJID user) void
setAccountStatus
(tigase.xmpp.jid.BareJID user, tigase.db.AuthRepository.AccountStatus status) void
void
void
setDataList
(tigase.xmpp.jid.BareJID user, String subnode, String key, String[] list) void
setDataSource
(MongoDataSource dataSource) void
updateCredential
(tigase.xmpp.jid.BareJID user, String credentialId, String password) void
updatePassword
(tigase.xmpp.jid.BareJID user, String password) tigase.db.util.SchemaLoader.Result
updateSchema
(Optional<tigase.util.Version> oldVersion, tigase.util.Version newVersion) boolean
userExists
(tigase.xmpp.jid.BareJID user) Methods inherited from class tigase.db.AbstractAuthRepositoryWithCredentials
getCredentialsDecoder, getCredentialsEncoder, getPassword, isMechanismSupported, setCredentialsCodecs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface tigase.db.AuthRepository
getUsernames, isUserDisabled, setUserDisabled
Methods inherited from interface tigase.mongodb.MongoRepositoryVersionAware
getVersion
-
Field Details
-
USERS_COLLECTION
- See Also:
-
USER_CREDENTIALS_COLLECTION
- See Also:
-
NODES_COLLECTION
- See Also:
-
ID_KEY
- See Also:
-
DOMAIN_KEY
- See Also:
-
autoCreateUser
@ConfigField(desc="Auto create user", alias="autoCreateUser=") protected boolean autoCreateUser
-
-
Constructor Details
-
MongoRepository
public MongoRepository()
-
-
Method Details
-
addDataList
public void addDataList(tigase.xmpp.jid.BareJID user, String subnode, String key, String[] list) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
addDataList
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
addUser
public void addUser(tigase.xmpp.jid.BareJID user) throws tigase.db.UserExistsException, tigase.db.TigaseDBException - Specified by:
addUser
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserExistsException
tigase.db.TigaseDBException
-
addUser
public void addUser(tigase.xmpp.jid.BareJID user, String password) throws tigase.db.UserExistsException, tigase.db.TigaseDBException - Specified by:
addUser
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.UserExistsException
tigase.db.TigaseDBException
-
calculateHash
- Throws:
tigase.db.TigaseDBException
-
generateId
protected byte[] generateId(tigase.xmpp.jid.BareJID user) throws tigase.db.TigaseDBException - Throws:
tigase.db.TigaseDBException
-
getAccountStatus
public tigase.db.AuthRepository.AccountStatus getAccountStatus(tigase.xmpp.jid.BareJID user) throws tigase.db.TigaseDBException - Specified by:
getAccountStatus
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.TigaseDBException
-
getCredentials
public tigase.auth.credentials.Credentials getCredentials(tigase.xmpp.jid.BareJID user, String credentialId) throws tigase.db.TigaseDBException - Specified by:
getCredentials
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.TigaseDBException
-
getData
public String getData(tigase.xmpp.jid.BareJID user, String subnode, String key, String def) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getData
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
getData
public String getData(tigase.xmpp.jid.BareJID user, String subnode, String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getData
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
getData
public String getData(tigase.xmpp.jid.BareJID user, String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getData
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
getDataMap
public Map<String,String> getDataMap(tigase.xmpp.jid.BareJID user, String subnode) throws tigase.db.TigaseDBException - Specified by:
getDataMap
in interfacetigase.db.UserRepository
- Throws:
tigase.db.TigaseDBException
-
getDataMap
public <T> Map<String,T> getDataMap(tigase.xmpp.jid.BareJID user, String subnode, Function<String, T> converter) throws tigase.db.TigaseDBException- Specified by:
getDataMap
in interfacetigase.db.UserRepository
- Throws:
tigase.db.TigaseDBException
-
getDataList
public String[] getDataList(tigase.xmpp.jid.BareJID user, String subnode, String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getDataList
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
getKeys
public String[] getKeys(tigase.xmpp.jid.BareJID user, String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getKeys
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
getKeys
public String[] getKeys(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getKeys
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
getResourceUri
- Specified by:
getResourceUri
in interfacetigase.db.AuthRepository
- Specified by:
getResourceUri
in interfacetigase.db.UserRepository
-
getSubnodes
public String[] getSubnodes(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getSubnodes
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
getSubnodes
public String[] getSubnodes(tigase.xmpp.jid.BareJID user, String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getSubnodes
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
getCredentialIds
public Collection<String> getCredentialIds(tigase.xmpp.jid.BareJID user) throws tigase.db.TigaseDBException - Specified by:
getCredentialIds
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.TigaseDBException
-
getActiveUsersCountIn
- Specified by:
getActiveUsersCountIn
in interfacetigase.db.AuthRepository
-
getUserUID
Deprecated.Should be removed as only relational DB are using this and it is not required by any other code- Specified by:
getUserUID
in interfacetigase.db.UserRepository
- Throws:
tigase.db.TigaseDBException
-
getUsers
- Specified by:
getUsers
in interfacetigase.db.UserRepository
- Throws:
tigase.db.TigaseDBException
-
getUsersCount
public long getUsersCount()- Specified by:
getUsersCount
in interfacetigase.db.AuthRepository
- Specified by:
getUsersCount
in interfacetigase.db.UserRepository
-
getUsersCount
- Specified by:
getUsersCount
in interfacetigase.db.AuthRepository
- Specified by:
getUsersCount
in interfacetigase.db.UserRepository
-
initRepository
@Deprecated public void initRepository(String resource_uri, Map<String, String> params) throws tigase.db.DBInitExceptionDeprecated.- Specified by:
initRepository
in interfacetigase.db.Repository
- Throws:
tigase.db.DBInitException
-
loggedIn
public void loggedIn(tigase.xmpp.jid.BareJID jid) throws tigase.db.TigaseDBException - Specified by:
loggedIn
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.TigaseDBException
-
logout
public void logout(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
logout
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
otherAuth
public boolean otherAuth(Map<String, Object> authProps) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException, tigase.db.AuthorizationException- Specified by:
otherAuth
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
tigase.db.AuthorizationException
-
queryAuth
- Specified by:
queryAuth
in interfacetigase.db.AuthRepository
-
readAllDistinctValuesForField
protected <T> List<T> readAllDistinctValuesForField(com.mongodb.client.MongoCollection<org.bson.Document> collection, String field, org.bson.Document crit) throws com.mongodb.MongoException - Throws:
com.mongodb.MongoException
-
removeCredential
public void removeCredential(tigase.xmpp.jid.BareJID user, String credentialId) throws tigase.db.TigaseDBException - Specified by:
removeCredential
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.TigaseDBException
-
removeData
public void removeData(tigase.xmpp.jid.BareJID user, String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
removeData
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
removeData
public void removeData(tigase.xmpp.jid.BareJID user, String subnode, String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
removeData
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
removeSubnode
public void removeSubnode(tigase.xmpp.jid.BareJID user, String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
removeSubnode
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
removeUser
public void removeUser(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
removeUser
in interfacetigase.db.AuthRepository
- Specified by:
removeUser
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
setAccountStatus
public void setAccountStatus(tigase.xmpp.jid.BareJID user, tigase.db.AuthRepository.AccountStatus status) throws tigase.db.TigaseDBException - Specified by:
setAccountStatus
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.TigaseDBException
-
setData
public void setData(tigase.xmpp.jid.BareJID user, String key, String value) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
setData
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
setData
public void setData(tigase.xmpp.jid.BareJID user, String subnode, String key, String value) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
setData
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
setDataList
public void setDataList(tigase.xmpp.jid.BareJID user, String subnode, String key, String[] list) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
setDataList
in interfacetigase.db.UserRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
setDataSource
- Specified by:
setDataSource
in interfacetigase.db.DataSourceAware<MongoDataSource>
-
updateCredential
public void updateCredential(tigase.xmpp.jid.BareJID user, String credentialId, String password) throws tigase.db.TigaseDBException - Specified by:
updateCredential
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.TigaseDBException
-
updatePassword
public void updatePassword(tigase.xmpp.jid.BareJID user, String password) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
updatePassword
in interfacetigase.db.AuthRepository
- Throws:
tigase.db.UserNotFoundException
tigase.db.TigaseDBException
-
updateSchema
public tigase.db.util.SchemaLoader.Result updateSchema(Optional<tigase.util.Version> oldVersion, tigase.util.Version newVersion) throws tigase.db.TigaseDBException - Specified by:
updateSchema
in interfacetigase.db.util.RepositoryVersionAware
- Throws:
tigase.db.TigaseDBException
-
userExists
public boolean userExists(tigase.xmpp.jid.BareJID user) - Specified by:
userExists
in interfacetigase.db.UserRepository
-