// Path: src/java/is/idega/idegaweb/egov/citizen/business/WSCitizenAccountBusiness.java
// public interface WSCitizenAccountBusiness extends IBOService,
// 		CitizenAccountBusiness, CallbackHandler {
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#changePasswordAndSendLetterOrEmail
// 	 */
// 	public void changePasswordAndSendLetterOrEmail(IWUserContext iwuc,
// 			LoginTable loginTable, User user, String newPassword,
// 			boolean sendLetter) throws CreateException, RemoteException;
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#handle
// 	 */
// 	public void handle(Callback[] callbacks)
// 			throws UnsupportedCallbackException, RemoteException;
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#sendMessageToBank
// 	 */
// 	public boolean sendMessageToBank() throws RemoteException;
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#sendLostPasswordMessage
// 	 */
// 	public void sendLostPasswordMessage(User citizen, String login,
// 			String password) throws RemoteException, CreateException,
// 			RemoteException;
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#getAcceptMessageSubject
// 	 */
// 	public String getAcceptMessageSubject(User owner) throws RemoteException;
// }


import is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusiness;
import java.io.IOException;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.idega.business.IBOLookup;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.core.accesscontrol.data.LoginTableHome;
import com.idega.core.builder.data.ICPage;
import com.idega.core.localisation.presentation.LocalePresentationUtil;
import com.idega.core.location.data.Address;
import com.idega.core.location.data.Commune;
import com.idega.data.IDOLookup;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.ExceptionWrapper;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.Span;
import com.idega.presentation.text.Heading1;
import com.idega.presentation.text.Link;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.CheckBox;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.Form;
import com.idega.presentation.ui.HiddenInput;
import com.idega.presentation.ui.Label;
import com.idega.presentation.ui.TextInput;
import com.idega.user.business.UserBusiness;
import com.idega.user.data.User;
import com.idega.util.Age;
import com.idega.util.IWTimestamp;
import com.idega.util.text.SocialSecurityNumber;
		} else if (!SocialSecurityNumber.isValidIcelandicSocialSecurityNumber(ssn)) {
			errors.add(this.iwrb.getLocalizedString("not_a_valid_personal_id", "The personal ID you've entered is not valid."));
			hasErrors = true;
		}
		if (!isValidAge(iwc, ssn)) {
			Object[] arguments = { iwc.getApplicationSettings().getProperty(ATTRIBUTE_VALID_ACCOUNT_AGE, String.valueOf(18)) };
			errors.add(MessageFormat.format(this.iwrb.getLocalizedString(NOT_VALID_ACCOUNT_AGE_KEY, NOT_VALID_ACCOUNT_AGE_DEFAULT), arguments));
			hasErrors = true;
		}

		String email = iwc.getParameter(EMAIL_KEY);
		if (email == null || email.length() == 0) {
			errors.add(this.iwrb.getLocalizedString("email_can_not_be_empty", "You must provide a valid e-mail address"));
			hasErrors = true;
		}

		boolean agreementAccepted = iwc.getParameter(APP_AGREEMENT_PARAM) != null && iwc.getParameter(APP_AGREEMENT_PARAM).length() > 0;

		if (!agreementAccepted) {
			errors.add(this.iwrb.getLocalizedString(APP_AGREEMENT_NOTAGREED_KEY, APP_AGREEMENT_NOTAGREED_DEFAULT));
			hasErrors = true;
		}

		boolean sendSnailMail = iwc.getParameter(SNAIL_MAIL_KEY) != null && iwc.getParameter(SNAIL_MAIL_KEY).length() > 0;

		String emailRepeat = iwc.getParameter(EMAIL_KEY_REPEAT);
		String phoneHome = iwc.getParameter(PHONE_HOME_KEY);
		String phoneWork = iwc.getParameter(PHONE_CELL_KEY);
		String preferredLocale = iwc.getParameter(PARAMETER_PREFERRED_LOCALE);

// Path: src/java/is/idega/idegaweb/egov/citizen/business/WSCitizenAccountBusiness.java
// public interface WSCitizenAccountBusiness extends IBOService,
// 		CitizenAccountBusiness, CallbackHandler {
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#changePasswordAndSendLetterOrEmail
// 	 */
// 	public void changePasswordAndSendLetterOrEmail(IWUserContext iwuc,
// 			LoginTable loginTable, User user, String newPassword,
// 			boolean sendLetter) throws CreateException, RemoteException;
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#handle
// 	 */
// 	public void handle(Callback[] callbacks)
// 			throws UnsupportedCallbackException, RemoteException;
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#sendMessageToBank
// 	 */
// 	public boolean sendMessageToBank() throws RemoteException;
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#sendLostPasswordMessage
// 	 */
// 	public void sendLostPasswordMessage(User citizen, String login,
// 			String password) throws RemoteException, CreateException,
// 			RemoteException;
// 
// 	/**
// 	 * @see is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusinessBean#getAcceptMessageSubject
// 	 */
// 	public String getAcceptMessageSubject(User owner) throws RemoteException;
// }


// Path: src/java/is/idega/idegaweb/egov/citizen/presentation/CitizenAccountApplication.java
import is.idega.idegaweb.egov.citizen.business.WSCitizenAccountBusiness;
import java.io.IOException;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.idega.business.IBOLookup;
import com.idega.core.accesscontrol.business.UserHasLoginException;
import com.idega.core.accesscontrol.data.LoginTable;
import com.idega.core.accesscontrol.data.LoginTableHome;
import com.idega.core.builder.data.ICPage;
import com.idega.core.localisation.presentation.LocalePresentationUtil;
import com.idega.core.location.data.Address;
import com.idega.core.location.data.Commune;
import com.idega.data.IDOLookup;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.ExceptionWrapper;
import com.idega.presentation.IWContext;
import com.idega.presentation.Layer;
import com.idega.presentation.Span;
import com.idega.presentation.text.Heading1;
import com.idega.presentation.text.Link;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.CheckBox;
import com.idega.presentation.ui.DropdownMenu;
import com.idega.presentation.ui.Form;
import com.idega.presentation.ui.HiddenInput;
import com.idega.presentation.ui.Label;
import com.idega.presentation.ui.TextInput;
import com.idega.user.business.UserBusiness;
import com.idega.user.data.User;
import com.idega.util.Age;
import com.idega.util.IWTimestamp;
import com.idega.util.text.SocialSecurityNumber;

		} else if (!SocialSecurityNumber.isValidIcelandicSocialSecurityNumber(ssn)) {
			errors.add(this.iwrb.getLocalizedString("not_a_valid_personal_id", "The personal ID you've entered is not valid."));
			hasErrors = true;
		}
		if (!isValidAge(iwc, ssn)) {
			Object[] arguments = { iwc.getApplicationSettings().getProperty(ATTRIBUTE_VALID_ACCOUNT_AGE, String.valueOf(18)) };
			errors.add(MessageFormat.format(this.iwrb.getLocalizedString(NOT_VALID_ACCOUNT_AGE_KEY, NOT_VALID_ACCOUNT_AGE_DEFAULT), arguments));
			hasErrors = true;
		}

		String email = iwc.getParameter(EMAIL_KEY);
		if (email == null || email.length() == 0) {
			errors.add(this.iwrb.getLocalizedString("email_can_not_be_empty", "You must provide a valid e-mail address"));
			hasErrors = true;
		}

		boolean agreementAccepted = iwc.getParameter(APP_AGREEMENT_PARAM) != null && iwc.getParameter(APP_AGREEMENT_PARAM).length() > 0;

		if (!agreementAccepted) {
			errors.add(this.iwrb.getLocalizedString(APP_AGREEMENT_NOTAGREED_KEY, APP_AGREEMENT_NOTAGREED_DEFAULT));
			hasErrors = true;
		}

		boolean sendSnailMail = iwc.getParameter(SNAIL_MAIL_KEY) != null && iwc.getParameter(SNAIL_MAIL_KEY).length() > 0;

		String emailRepeat = iwc.getParameter(EMAIL_KEY_REPEAT);
		String phoneHome = iwc.getParameter(PHONE_HOME_KEY);
		String phoneWork = iwc.getParameter(PHONE_CELL_KEY);
		String preferredLocale = iwc.getParameter(PARAMETER_PREFERRED_LOCALE);

		WSCitizenAccountBusiness business = getBusiness(iwc);