else if (!mStartedTLS && !OzImapServer.allowCleartextLogins()) {
else if (!mStartedTLS && !allowCleartextLogin()) {
    boolean doLOGIN(String tag, List args) throws IOException {        if (!checkState(tag, ImapSession.STATE_NOT_AUTHENTICATED))            return CONTINUE_PROCESSING;        else if (!mStartedTLS && !OzImapServer.allowCleartextLogins()) {            sendNO(tag, "cleartext logins disabled");            return CONTINUE_PROCESSING;        }        String username = (String) args.remove(0);        String password = (String) args.remove(0);        Mailbox mailbox = null;        ImapSession session = null;        try {            Provisioning prov = Provisioning.getInstance();            Account account = prov.getAccountByName(username);            if (account == null) {                sendNO(tag, "LOGIN failed");                return CONTINUE_PROCESSING;            }            prov.authAccount(account, password);            if (!account.getBooleanAttr(Provisioning.A_zimbraImapEnabled, false)) {                sendNO(tag, "account does not have IMAP access enabled");                return CONTINUE_PROCESSING;            } else if (!account.isCorrectHost()) {                String correctHost = account.getAttr(Provisioning.A_zimbraMailHost);                ZimbraLog.imap.info("LOGIN failed; should be on host " + correctHost);                if (correctHost == null || correctHost.trim().equals(""))                    sendNO(tag, "LOGIN failed [wrong host]");                else                    sendNO(tag, "[REFERRAL imap://" + URLEncoder.encode(account.getName(), "utf-8") + '@' + correctHost + "/] LOGIN failed");                return CONTINUE_PROCESSING;            }            session = (ImapSession) SessionCache.getNewSession(account.getId(), SessionCache.SESSION_IMAP);            if (session == null) {                sendNO(tag, "LOGIN failed");                return CONTINUE_PROCESSING;            }            mailbox = session.getMailbox();            synchronized (mailbox) {                session.setUsername(account.getName());                session.cacheFlags(mailbox);                for (Iterator it = mailbox.getTagList(session.getContext()).iterator(); it.hasNext(); )                    session.cacheTag((Tag) it.next());            }        } catch (ServiceException e) {            if (mSession != null)            	mSession.clearTagCache();            ZimbraLog.imap.warn("LOGIN failed", e);            if (e.getCode() == AccountServiceException.CHANGE_PASSWORD)                sendNO(tag, "[ALERT] password must be changed before IMAP login permitted");            else if (e.getCode() == AccountServiceException.MAINTENANCE_MODE)                sendNO(tag, "[ALERT] account undergoing maintenance; please try again later");            else                sendNO(tag, "LOGIN failed");            return canContinue(e);        }        // XXX: could use mSession.getMailbox() instead of saving a copy...        mMailbox = mailbox;        mSession = session;        // TODO: ANAND: mSession.setHandler(this);        // TODO: ANAND: throw out too big inputs.        sendCapability();        sendOK(tag, "LOGIN completed");        return CONTINUE_PROCESSING;    }