* @return a new User instance.
*/
private User loadUser( String fullAddress, Properties properties ) throws InvalidAddressException
{
EmailAddress address = new EmailAddress( fullAddress );
User user = new User( address );
// Load the password
String password = properties.getProperty( USER_DEF_PREFIX + fullAddress );
// If the password is not hashed, hash it now.
if( password.length() != 60 ) {
password = PasswordManager.encryptPassword( password );
properties.setProperty( USER_DEF_PREFIX + fullAddress, password );
if( password == null ) {
log.error( "Error encrypting plaintext password from user.conf for user " + fullAddress );
throw new RuntimeException( "Error encrypting password for user: " + fullAddress );
}
userConfModified = true;
}
user.setPassword( password );
// Load the 'forward' addresses.
String forwardAddressesString = properties.getProperty( USER_PROPERTY_PREFIX + fullAddress + USER_FILE_FORWARDS );
String[] forwardAddresses = new String[0];
if( forwardAddressesString != null && forwardAddressesString.trim().length() >= 0 )
{
forwardAddresses = tokenize( forwardAddressesString );
}
ArrayList addressList = new ArrayList( forwardAddresses.length );
for( int index = 0; index < forwardAddresses.length; index++ ) {
try {
addressList.add( new EmailAddress( forwardAddresses[index] ) );
}
catch (InvalidAddressException e) {
log.warn( "Forward address: " + forwardAddresses[index] + " for user " + user.getFullUsername() + " is invalid and will be ignored." );
}
}
EmailAddress[] emailAddresses = new EmailAddress[ addressList.size() ];
emailAddresses = (EmailAddress[]) addressList.toArray( emailAddresses );
if( log.isDebugEnabled() ) log.debug( emailAddresses.length + " forward addresses load for user: " + user.getFullUsername() );
user.setForwardAddresses( emailAddresses );
return user;
}