FileDocCategorySizeDatePackage
DefaultUsersJdbcRepository.javaAPI DocApache James 2.3.14698Fri Jan 12 12:56:32 GMT 2007org.apache.james.userrepository

DefaultUsersJdbcRepository

public class DefaultUsersJdbcRepository extends AbstractJdbcUsersRepository
A Jdbc-backed UserRepository which handles User instances of the DefaultUser class. Although this repository can handle subclasses of DefaultUser, like DefaultJamesUser, only properties from the DefaultUser class are persisted. TODO Please note that default configuration uses JamesUsersJdbcRepository instead of this class. So we could also delete this implementation.

Fields Summary
Constructors Summary
Methods Summary
public booleanaddUser(java.lang.String username, java.lang.String password)

see
org.apache.james.services.UsersRepository#addUser(java.lang.String, java.lang.String)

        User newbie = new DefaultUser(username, "SHA");
        newbie.setPassword(password);
        return addUser(newbie);
    
protected org.apache.james.services.UserreadUserFromResultSet(java.sql.ResultSet rsUsers)
Reads properties for a User from an open ResultSet.

param
rsUsers A ResultSet with a User record in the current row.
return
A User instance
throws
SQLException if an exception occurs reading from the ResultSet

        // Get the username, and build a DefaultUser with it.
        String username = rsUsers.getString(1);
        String passwordHash = rsUsers.getString(2);
        String passwordAlg = rsUsers.getString(3);
        DefaultUser user = new DefaultUser(username, passwordHash, passwordAlg);
        return user;
    
protected voidsetUserForInsertStatement(org.apache.james.services.User user, java.sql.PreparedStatement userInsert)
Set parameters of a PreparedStatement object with property values from a User instance.

param
user a User instance, which should be an implementation class which is handled by this Repostory implementation.
param
userInsert a PreparedStatement initialised with SQL taken from the "insert" SQL definition.
throws
SQLException if an exception occurs while setting parameter values.

        DefaultUser defUser = (DefaultUser)user;
        userInsert.setString(1, defUser.getUserName());
        userInsert.setString(2, defUser.getHashAlgorithm());
        userInsert.setString(3, defUser.getHashedPassword());
    
protected voidsetUserForUpdateStatement(org.apache.james.services.User user, java.sql.PreparedStatement userUpdate)
Set parameters of a PreparedStatement object with property values from a User instance.

param
user a User instance, which should be an implementation class which is handled by this Repostory implementation.
param
userUpdate a PreparedStatement initialised with SQL taken from the "update" SQL definition.
throws
SQLException if an exception occurs while setting parameter values.

        DefaultUser defUser = (DefaultUser)user;
        userUpdate.setString(3, defUser.getUserName());
        userUpdate.setString(1, defUser.getHashAlgorithm());
        userUpdate.setString(2, defUser.getHashedPassword());