// 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.");
}