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.SingleCredentialNested classes/interfaces inherited from interface tigase.db.Repository
tigase.db.Repository.Meta, tigase.db.Repository.SchemaIdNested classes/interfaces inherited from interface tigase.db.util.RepositoryVersionAware
tigase.db.util.RepositoryVersionAware.SchemaVersionNested classes/interfaces inherited from interface tigase.db.UserRepository
tigase.db.UserRepository.UserRemovedEvent -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final StringFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataList(tigase.xmpp.jid.BareJID user, String subnode, String key, String[] list) voidaddUser(tigase.xmpp.jid.BareJID user) voidprotected byte[]calculateHash(String user) protected byte[]generateId(tigase.xmpp.jid.BareJID user) tigase.db.AuthRepository.AccountStatusgetAccountStatus(tigase.xmpp.jid.BareJID user) longgetActiveUsersCountIn(Duration duration) getCredentialIds(tigase.xmpp.jid.BareJID user) tigase.auth.credentials.CredentialsgetCredentials(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()longlonggetUsersCount(String domain) longgetUserUID(tigase.xmpp.jid.BareJID user) Deprecated.voidinitRepository(String resource_uri, Map<String, String> params) Deprecated.voidloggedIn(tigase.xmpp.jid.BareJID jid) voidlogout(tigase.xmpp.jid.BareJID user) booleanvoidprotected <T> List<T>readAllDistinctValuesForField(com.mongodb.client.MongoCollection<org.bson.Document> collection, String field, org.bson.Document crit) voidremoveCredential(tigase.xmpp.jid.BareJID user, String credentialId) voidremoveData(tigase.xmpp.jid.BareJID user, String key) voidremoveData(tigase.xmpp.jid.BareJID user, String subnode, String key) voidremoveSubnode(tigase.xmpp.jid.BareJID user, String subnode) voidremoveUser(tigase.xmpp.jid.BareJID user) voidsetAccountStatus(tigase.xmpp.jid.BareJID user, tigase.db.AuthRepository.AccountStatus status) voidvoidvoidsetDataList(tigase.xmpp.jid.BareJID user, String subnode, String key, String[] list) voidsetDataSource(MongoDataSource dataSource) voidupdateCredential(tigase.xmpp.jid.BareJID user, String credentialId, String password) voidupdatePassword(tigase.xmpp.jid.BareJID user, String password) tigase.db.util.SchemaLoader.ResultupdateSchema(Optional<tigase.util.Version> oldVersion, tigase.util.Version newVersion) booleanuserExists(tigase.xmpp.jid.BareJID user) Methods inherited from class tigase.db.AbstractAuthRepositoryWithCredentials
getCredentialsDecoder, getCredentialsEncoder, getPassword, isMechanismSupported, setCredentialsCodecsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface tigase.db.AuthRepository
getUsernames, isUserDisabled, setUserDisabledMethods 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:
addDataListin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
addUser
public void addUser(tigase.xmpp.jid.BareJID user) throws tigase.db.UserExistsException, tigase.db.TigaseDBException - Specified by:
addUserin interfacetigase.db.UserRepository- Throws:
tigase.db.UserExistsExceptiontigase.db.TigaseDBException
-
addUser
public void addUser(tigase.xmpp.jid.BareJID user, String password) throws tigase.db.UserExistsException, tigase.db.TigaseDBException - Specified by:
addUserin interfacetigase.db.AuthRepository- Throws:
tigase.db.UserExistsExceptiontigase.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:
getAccountStatusin 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:
getCredentialsin 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:
getDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getData
public String getData(tigase.xmpp.jid.BareJID user, String subnode, String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getData
public String getData(tigase.xmpp.jid.BareJID user, String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getDataMap
public Map<String,String> getDataMap(tigase.xmpp.jid.BareJID user, String subnode) throws tigase.db.TigaseDBException - Specified by:
getDataMapin 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:
getDataMapin 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:
getDataListin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getKeys
public String[] getKeys(tigase.xmpp.jid.BareJID user, String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getKeysin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getKeys
public String[] getKeys(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getKeysin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getResourceUri
- Specified by:
getResourceUriin interfacetigase.db.AuthRepository- Specified by:
getResourceUriin interfacetigase.db.UserRepository
-
getSubnodes
public String[] getSubnodes(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getSubnodesin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getSubnodes
public String[] getSubnodes(tigase.xmpp.jid.BareJID user, String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
getSubnodesin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
getCredentialIds
public Collection<String> getCredentialIds(tigase.xmpp.jid.BareJID user) throws tigase.db.TigaseDBException - Specified by:
getCredentialIdsin interfacetigase.db.AuthRepository- Throws:
tigase.db.TigaseDBException
-
getActiveUsersCountIn
- Specified by:
getActiveUsersCountInin 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:
getUserUIDin interfacetigase.db.UserRepository- Throws:
tigase.db.TigaseDBException
-
getUsers
- Specified by:
getUsersin interfacetigase.db.UserRepository- Throws:
tigase.db.TigaseDBException
-
getUsersCount
public long getUsersCount()- Specified by:
getUsersCountin interfacetigase.db.AuthRepository- Specified by:
getUsersCountin interfacetigase.db.UserRepository
-
getUsersCount
- Specified by:
getUsersCountin interfacetigase.db.AuthRepository- Specified by:
getUsersCountin interfacetigase.db.UserRepository
-
initRepository
@Deprecated public void initRepository(String resource_uri, Map<String, String> params) throws tigase.db.DBInitExceptionDeprecated.- Specified by:
initRepositoryin interfacetigase.db.Repository- Throws:
tigase.db.DBInitException
-
loggedIn
public void loggedIn(tigase.xmpp.jid.BareJID jid) throws tigase.db.TigaseDBException - Specified by:
loggedInin 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:
logoutin interfacetigase.db.AuthRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
otherAuth
public boolean otherAuth(Map<String, Object> authProps) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException, tigase.db.AuthorizationException- Specified by:
otherAuthin interfacetigase.db.AuthRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBExceptiontigase.db.AuthorizationException
-
queryAuth
- Specified by:
queryAuthin 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:
removeCredentialin 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:
removeDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
removeData
public void removeData(tigase.xmpp.jid.BareJID user, String subnode, String key) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
removeDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
removeSubnode
public void removeSubnode(tigase.xmpp.jid.BareJID user, String subnode) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
removeSubnodein interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
removeUser
public void removeUser(tigase.xmpp.jid.BareJID user) throws tigase.db.UserNotFoundException, tigase.db.TigaseDBException - Specified by:
removeUserin interfacetigase.db.AuthRepository- Specified by:
removeUserin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
setAccountStatus
public void setAccountStatus(tigase.xmpp.jid.BareJID user, tigase.db.AuthRepository.AccountStatus status) throws tigase.db.TigaseDBException - Specified by:
setAccountStatusin 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:
setDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.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:
setDatain interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.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:
setDataListin interfacetigase.db.UserRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.db.TigaseDBException
-
setDataSource
- Specified by:
setDataSourcein interfacetigase.db.DataSourceAware<MongoDataSource>
-
updateCredential
public void updateCredential(tigase.xmpp.jid.BareJID user, String credentialId, String password) throws tigase.db.TigaseDBException - Specified by:
updateCredentialin 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:
updatePasswordin interfacetigase.db.AuthRepository- Throws:
tigase.db.UserNotFoundExceptiontigase.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:
updateSchemain interfacetigase.db.util.RepositoryVersionAware- Throws:
tigase.db.TigaseDBException
-
userExists
public boolean userExists(tigase.xmpp.jid.BareJID user) - Specified by:
userExistsin interfacetigase.db.UserRepository
-