1 17 18 package org.apache.james.userrepository; 19 20 import org.apache.james.services.User; 21 22 import java.sql.PreparedStatement ; 23 import java.sql.ResultSet ; 24 import java.sql.SQLException ; 25 26 27 35 public class DefaultUsersJdbcRepository extends AbstractJdbcUsersRepository 36 { 37 45 protected User readUserFromResultSet(ResultSet rsUsers) throws SQLException 46 { 47 String username = rsUsers.getString(1); 49 String passwordAlg = rsUsers.getString(2); 50 String passwordHash = rsUsers.getString(3); 51 DefaultUser user = new DefaultUser(username, passwordHash, passwordAlg); 52 return user; 53 } 54 55 65 protected void setUserForInsertStatement(User user, 66 PreparedStatement userInsert) 67 throws SQLException 68 { 69 DefaultUser defUser = (DefaultUser)user; 70 userInsert.setString(1, defUser.getUserName()); 71 userInsert.setString(2, defUser.getHashAlgorithm()); 72 userInsert.setString(3, defUser.getHashedPassword()); 73 } 74 75 85 protected void setUserForUpdateStatement(User user, 86 PreparedStatement userUpdate) 87 throws SQLException 88 { 89 DefaultUser defUser = (DefaultUser)user; 90 userUpdate.setString(3, defUser.getUserName()); 91 userUpdate.setString(1, defUser.getHashAlgorithm()); 92 userUpdate.setString(2, defUser.getHashedPassword()); 93 } 94 } 95 96 | Popular Tags |