nameIndex = 7;
colOffset = 0;
}
// Can handle instances of DefaultJamesUser and DefaultUser.
DefaultJamesUser jamesUser;
if (user instanceof DefaultJamesUser) {
jamesUser = (DefaultJamesUser) user;
} else if (user instanceof DefaultUser) {
DefaultUser aUser = (DefaultUser) user;
jamesUser = new DefaultJamesUser(aUser.getUserName(), aUser.getHashedPassword(), aUser.getHashAlgorithm());
}
// Can't handle any other implementations.
else {
throw new RuntimeException("An unknown implementation of User was " + "found. This implementation cannot be " + "persisted to a UsersJDBCRepsitory.");
}
// Get the user details to save.
stmt.setString(nameIndex, jamesUser.getUserName());
stmt.setString(1 + colOffset, jamesUser.getHashedPassword());
stmt.setString(2 + colOffset, jamesUser.getHashAlgorithm());
stmt.setInt(3 + colOffset, (jamesUser.getForwarding() ? 1 : 0));
MailAddress forwardAddress = jamesUser.getForwardingDestination();
String forwardDestination = null;
if (forwardAddress != null) {
forwardDestination = forwardAddress.toString();
}
stmt.setString(4 + colOffset, forwardDestination);
stmt.setInt(5 + colOffset, (jamesUser.getAliasing() ? 1 : 0));
stmt.setString(6 + colOffset, jamesUser.getAlias());
}