tigase.db.jdbc
Class JDBCRepository

java.lang.Object
  extended by tigase.db.jdbc.JDBCRepository
All Implemented Interfaces:
UserAuthRepository, UserRepository

public class JDBCRepository
extends Object
implements UserAuthRepository, UserRepository

Not synchronized implementation! Musn't be used by more than one thread at the same time.

Thanks to Daniele for better unique IDs handling. Created: Thu Oct 26 11:48:53 2006

Version:
$Rev$
Author:
Artur Hefczyc, Daniele

Field Summary
static String DEF_MAXIDS_TBL
           
static String DEF_NODES_TBL
           
static String DEF_PAIRS_TBL
           
static String DEF_ROOT_NODE
           
static String DEF_USERS_TBL
           
static String DERBY_CONNVALID_QUERY
           
static String DERBY_GETSCHEMAVER_QUERY
           
static String JDBC_CONNVALID_QUERY
           
static String JDBC_GETSCHEMAVER_QUERY
           
 
Fields inherited from interface tigase.db.UserAuthRepository
DATA_KEY, MACHANISM_KEY, PROTOCOL_KEY, PROTOCOL_VAL_NONSASL, PROTOCOL_VAL_SASL, REALM_KEY, RESULT_KEY, SERVER_NAME_KEY, USER_ID_KEY
 
Constructor Summary
JDBCRepository()
           
 
Method Summary
 void addDataList(String user_id, String subnode, String key, String[] list)
          Describe addDataList method here.
 void addUser(String user_id)
          Describe addUser method here.
 void addUser(String user, String password)
          Describe addUser method here.
 boolean digestAuth(String user, String digest, String id, String alg)
          Describe digestAuth method here.
 String getData(String user_id, String key)
          Describe getData method here.
 String getData(String user_id, String subnode, String key)
          Describe getData method here.
 String getData(String user_id, String subnode, String key, String def)
          Describe getData method here.
 String[] getDataList(String user_id, String subnode, String key)
          Describe getDataList method here.
 String[] getKeys(String user_id)
          Describe getKeys method here.
 String[] getKeys(String user_id, String subnode)
          Describe getKeys method here.
 String getResourceUri()
          getResourceUri method returns database connection string.
 String[] getSubnodes(String user_id)
          Describe getSubnodes method here.
 String[] getSubnodes(String user_id, String subnode)
          Describe getSubnodes method here.
 List<String> getUsers()
          getUsers method is thread safe.
 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)
          Describe initRepository method here.
 void logout(String user)
          Describe logout method here.
 boolean otherAuth(Map<String,Object> props)
          Describe otherAuth method here.
 boolean plainAuth(String user, String password)
          Describe plainAuth method here.
 void queryAuth(Map<String,Object> authProps)
          queryAuth returns mechanisms available for authentication.
 void removeData(String user_id, String key)
          Describe removeData method here.
 void removeData(String user_id, String subnode, String key)
          Describe removeData method here.
 void removeSubnode(String user_id, String subnode)
          Describe removeSubnode method here.
 void removeUser(String user_id)
          removeUser method is thread safe.
 void setData(String user_id, String key, String value)
          Describe setData method here.
 void setData(String user_id, String subnode, String key, String value)
          Describe setData method here.
 void setDataList(String user_id, String subnode, String key, String[] list)
          Describe setDataList method here.
 void updatePassword(String user, String password)
          Describe updatePassword method here.
 boolean userExists(String user)
          Method userExists checks whether the user (or repository top node) exists in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_USERS_TBL

public static final String DEF_USERS_TBL
See Also:
Constant Field Values

DEF_NODES_TBL

public static final String DEF_NODES_TBL
See Also:
Constant Field Values

DEF_PAIRS_TBL

public static final String DEF_PAIRS_TBL
See Also:
Constant Field Values

DEF_MAXIDS_TBL

public static final String DEF_MAXIDS_TBL
See Also:
Constant Field Values

DEF_ROOT_NODE

public static final String DEF_ROOT_NODE
See Also:
Constant Field Values

DERBY_CONNVALID_QUERY

public static final String DERBY_CONNVALID_QUERY
See Also:
Constant Field Values

JDBC_CONNVALID_QUERY

public static final String JDBC_CONNVALID_QUERY
See Also:
Constant Field Values

DERBY_GETSCHEMAVER_QUERY

public static final String DERBY_GETSCHEMAVER_QUERY
See Also:
Constant Field Values

JDBC_GETSCHEMAVER_QUERY

public static final String JDBC_GETSCHEMAVER_QUERY
See Also:
Constant Field Values
Constructor Detail

JDBCRepository

public JDBCRepository()
Method Detail

userExists

public boolean userExists(String user)
Description copied from interface: UserRepository
Method userExists 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.

Specified by:
userExists in interface UserRepository
Parameters:
user - a String value
Returns:
a boolean value

getResourceUri

public String getResourceUri()
Description copied from interface: UserAuthRepository
getResourceUri method returns database connection string.

Specified by:
getResourceUri in interface UserAuthRepository
Specified by:
getResourceUri in interface UserRepository
Returns:
a String value of database connection string.

initRepository

public void initRepository(String connection_str,
                           Map<String,String> params)
                    throws DBInitException
Describe initRepository method here.

Specified by:
initRepository in interface UserAuthRepository
Specified by:
initRepository in interface UserRepository
Parameters:
connection_str - a String value
Throws:
DBInitException - if an error occurs during access database. It won't happen however as in this method we do simple variable assigment.

getUsersCount

public long getUsersCount()
getUsersCount method is thread safe. It uses local variable for storing Statement.

Specified by:
getUsersCount in interface UserAuthRepository
Specified by:
getUsersCount in interface UserRepository
Returns:
a long number of user accounts in database.

getUsersCount

public long getUsersCount(String domain)
Description copied from interface: UserAuthRepository
This method is only used by the server statistics component to report number of registered users for given domain.

Specified by:
getUsersCount in interface UserAuthRepository
Specified by:
getUsersCount in interface UserRepository
Returns:
a long number of registered users in the repository.

getUsers

public List<String> getUsers()
                      throws TigaseDBException
getUsers method is thread safe. It uses local variable for storing Statement.

Specified by:
getUsers in interface UserRepository
Returns:
a List of user IDs from database.
Throws:
TigaseDBException

addUser

public void addUser(String user_id)
             throws UserExistsException,
                    TigaseDBException
Describe addUser method here.

Specified by:
addUser in interface UserRepository
Parameters:
user_id - a String value
Throws:
UserExistsException - if an error occurs
TigaseDBException

removeUser

public void removeUser(String user_id)
                throws UserNotFoundException,
                       TigaseDBException
removeUser method is thread safe. It uses local variable for storing Statement.

Specified by:
removeUser in interface UserAuthRepository
Specified by:
removeUser in interface UserRepository
Parameters:
user_id - a String value the user Jabber ID.
Throws:
UserNotFoundException - if an error occurs
TigaseDBException - if an error occurs

getDataList

public String[] getDataList(String user_id,
                            String subnode,
                            String key)
                     throws UserNotFoundException,
                            TigaseDBException
Describe getDataList method here.

Specified by:
getDataList in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
key - a String value
Returns:
a String[] value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

getSubnodes

public String[] getSubnodes(String user_id,
                            String subnode)
                     throws UserNotFoundException,
                            TigaseDBException
Describe getSubnodes method here.

Specified by:
getSubnodes in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
Returns:
a String[] value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

getSubnodes

public String[] getSubnodes(String user_id)
                     throws UserNotFoundException,
                            TigaseDBException
Describe getSubnodes method here.

Specified by:
getSubnodes in interface UserRepository
Parameters:
user_id - a String value
Returns:
a String[] value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

removeSubnode

public void removeSubnode(String user_id,
                          String subnode)
                   throws UserNotFoundException,
                          TigaseDBException
Describe removeSubnode method here.

Specified by:
removeSubnode in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

setDataList

public void setDataList(String user_id,
                        String subnode,
                        String key,
                        String[] list)
                 throws UserNotFoundException,
                        TigaseDBException
Describe setDataList method here.

Specified by:
setDataList in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
key - a String value
list - a String[] value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

addDataList

public void addDataList(String user_id,
                        String subnode,
                        String key,
                        String[] list)
                 throws UserNotFoundException,
                        TigaseDBException
Describe addDataList method here.

Specified by:
addDataList in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
key - a String value
list - a String[] value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

getKeys

public String[] getKeys(String user_id,
                        String subnode)
                 throws UserNotFoundException,
                        TigaseDBException
Describe getKeys method here.

Specified by:
getKeys in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
Returns:
a String[] value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

getKeys

public String[] getKeys(String user_id)
                 throws UserNotFoundException,
                        TigaseDBException
Describe getKeys method here.

Specified by:
getKeys in interface UserRepository
Parameters:
user_id - a String value
Returns:
a String[] value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

getData

public String getData(String user_id,
                      String subnode,
                      String key,
                      String def)
               throws UserNotFoundException,
                      TigaseDBException
Describe getData method here.

Specified by:
getData in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
key - a String value
def - a String value
Returns:
a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

getData

public String getData(String user_id,
                      String subnode,
                      String key)
               throws UserNotFoundException,
                      TigaseDBException
Describe getData method here.

Specified by:
getData in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
key - a String value
Returns:
a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

getData

public String getData(String user_id,
                      String key)
               throws UserNotFoundException,
                      TigaseDBException
Describe getData method here.

Specified by:
getData in interface UserRepository
Parameters:
user_id - a String value
key - a String value
Returns:
a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

setData

public void setData(String user_id,
                    String subnode,
                    String key,
                    String value)
             throws UserNotFoundException,
                    TigaseDBException
Describe setData method here.

Specified by:
setData in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
key - a String value
value - a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

setData

public void setData(String user_id,
                    String key,
                    String value)
             throws UserNotFoundException,
                    TigaseDBException
Describe setData method here.

Specified by:
setData in interface UserRepository
Parameters:
user_id - a String value
key - a String value
value - a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

removeData

public void removeData(String user_id,
                       String subnode,
                       String key)
                throws UserNotFoundException,
                       TigaseDBException
Describe removeData method here.

Specified by:
removeData in interface UserRepository
Parameters:
user_id - a String value
subnode - a String value
key - a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

removeData

public void removeData(String user_id,
                       String key)
                throws UserNotFoundException,
                       TigaseDBException
Describe removeData method here.

Specified by:
removeData in interface UserRepository
Parameters:
user_id - a String value
key - a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException

plainAuth

public boolean plainAuth(String user,
                         String password)
                  throws UserNotFoundException,
                         TigaseDBException,
                         AuthorizationException
Describe plainAuth method here.

Specified by:
plainAuth in interface UserAuthRepository
Parameters:
user - a String value
password - a String value
Returns:
a boolean value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException - if an error occurs
AuthorizationException - if an error occurs during authentication process.

digestAuth

public boolean digestAuth(String user,
                          String digest,
                          String id,
                          String alg)
                   throws UserNotFoundException,
                          TigaseDBException,
                          AuthorizationException
Describe digestAuth method here.

Specified by:
digestAuth in interface UserAuthRepository
Parameters:
user - a String value
digest - a String value
id - a String value
alg - a String value
Returns:
a boolean value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException - if an error occurs
AuthorizationException - if an error occurs during authentication process.

otherAuth

public boolean otherAuth(Map<String,Object> props)
                  throws UserNotFoundException,
                         TigaseDBException,
                         AuthorizationException
Describe otherAuth method here.

Specified by:
otherAuth in interface UserAuthRepository
Parameters:
props - a Map value
Returns:
a boolean value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException - if an error occurs
AuthorizationException - if an error occurs

updatePassword

public void updatePassword(String user,
                           String password)
                    throws TigaseDBException
Description copied from interface: UserAuthRepository
Describe updatePassword method here.

Specified by:
updatePassword in interface UserAuthRepository
Parameters:
user - a String value
password - a String value
Throws:
UserNotFoundException
TigaseDBException - if an error occurs

logout

public void logout(String user)
            throws UserNotFoundException,
                   TigaseDBException
Description copied from interface: UserAuthRepository
Describe logout method here.

Specified by:
logout in interface UserAuthRepository
Parameters:
user - a String value
Throws:
UserNotFoundException - if an error occurs
TigaseDBException - if an error occurs

addUser

public void addUser(String user,
                    String password)
             throws UserExistsException,
                    TigaseDBException
Describe addUser method here.

Specified by:
addUser in interface UserAuthRepository
Parameters:
user - a String value
password - a String value
Throws:
UserExistsException - if an error occurs
TigaseDBException - if an error occurs

queryAuth

public void queryAuth(Map<String,Object> authProps)
Description copied from interface: UserAuthRepository
queryAuth returns mechanisms available for authentication.

Specified by:
queryAuth in interface UserAuthRepository
Parameters:
authProps - a Map value with parameters for authentication.


Copyright © 2001-2006 Tigase Developers Team. All rights Reserved.