/** * Check for an IMAP login REFERRAL response code. * * @exception IMAPReferralException if REFERRAL response code found * @see "RFC 2221" */ private void checkReferral(Response r) throws IMAPReferralException { String s = r.getRest(); // get the text after the response if (s.startsWith("[")) { // a response code int i = s.indexOf(' '); if (i > 0 && s.substring(1, i).equalsIgnoreCase("REFERRAL")) { String url, msg; int j = s.indexOf(']'); if (j > 0) { // should always be true; url = s.substring(i + 1, j); msg = s.substring(j + 1).trim(); } else { url = s.substring(i + 1); msg = ""; } if (r.isBYE()) disconnect(); throw new IMAPReferralException(msg, url); } } }
/** * Check for an IMAP login REFERRAL response code. * * @exception IMAPReferralException if REFERRAL response code found * @see "RFC 2221" */ private void checkReferral(Response r) throws IMAPReferralException { String s = r.getRest(); // get the text after the response if (s.startsWith("[")) { // a response code int i = s.indexOf(' '); if (i > 0 && s.substring(1, i).equalsIgnoreCase("REFERRAL")) { String url, msg; int j = s.indexOf(']'); if (j > 0) { // should always be true; url = s.substring(i + 1, j); msg = s.substring(j + 1).trim(); } else { url = s.substring(i + 1); msg = ""; } if (r.isBYE()) disconnect(); throw new IMAPReferralException(msg, url); } } }
/** * LOGOUT Command. * * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.1.3" */ public void logout() throws ProtocolException { try { Response[] r = command("LOGOUT", null); authenticated = false; // dispatch any unsolicited responses. // NOTE that the BYE response is dispatched here as well notifyResponseHandlers(r); } finally { disconnect(); } }
/** * LOGOUT Command. * * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.1.3" */ public void logout() throws ProtocolException { try { Response[] r = command("LOGOUT", null); authenticated = false; // dispatch any unsolicited responses. // NOTE that the BYE response is dispatched here as well notifyResponseHandlers(r); } finally { disconnect(); } }
/** * Empty the connection pool. */ private void emptyConnectionPool(boolean force) { synchronized (pool) { for (int index = pool.authenticatedConnections.size() - 1; index >= 0; --index) { try { IMAPProtocol p = pool.authenticatedConnections.elementAt(index); p.removeResponseHandler(this); if (force) p.disconnect(); else p.logout(); } catch (ProtocolException pex) {}; } pool.authenticatedConnections.removeAllElements(); } pool.logger.fine("removed all authenticated connections from pool"); }
/** * Empty the connection pool. */ private void emptyConnectionPool(boolean force) { synchronized (pool) { for (int index = pool.authenticatedConnections.size() - 1; index >= 0; --index) { try { IMAPProtocol p = pool.authenticatedConnections.elementAt(index); p.removeResponseHandler(this); if (force) p.disconnect(); else p.logout(); } catch (ProtocolException pex) {}; } pool.authenticatedConnections.removeAllElements(); } pool.logger.fine("removed all authenticated connections from pool"); }
/** * Release the protocol object. * * ASSERT: This method must be called only when holding the * messageCacheLock * * @param returnToPool return the protocol object to the pool? */ protected void releaseProtocol(boolean returnToPool) { if (protocol != null) { protocol.removeResponseHandler(this); if (returnToPool) ((IMAPStore)store).releaseProtocol(this, protocol); else { protocol.disconnect(); // make sure it's disconnected ((IMAPStore)store).releaseProtocol(this, null); } protocol = null; } }
/** * Release the protocol object. * * ASSERT: This method must be called only when holding the * messageCacheLock * * @param returnToPool return the protocol object to the pool? */ protected void releaseProtocol(boolean returnToPool) { if (protocol != null) { protocol.removeResponseHandler(this); if (returnToPool) ((IMAPStore)store).releaseProtocol(this, protocol); else { protocol.disconnect(); // make sure it's disconnected ((IMAPStore)store).releaseProtocol(this, null); } protocol = null; } }
/** * STARTTLS Command. * * @exception ProtocolException for protocol failures * @see "RFC3501, section 6.2.1" */ public void startTLS() throws ProtocolException { try { super.startTLS("STARTTLS"); } catch (ProtocolException pex) { logger.log(Level.FINE, "STARTTLS ProtocolException", pex); // ProtocolException just means the command wasn't recognized, // or failed. This should never happen if we check the // CAPABILITY first. throw pex; } catch (Exception ex) { logger.log(Level.FINE, "STARTTLS Exception", ex); // any other exception means we have to shut down the connection // generate an artificial BYE response and disconnect Response[] r = { Response.byeResponse(ex) }; notifyResponseHandlers(r); disconnect(); throw new ProtocolException("STARTTLS failure", ex); } }
/** * COMPRESS Command. Only supports DEFLATE. * * @exception ProtocolException for protocol failures * @see "RFC 4978" */ public void compress() throws ProtocolException { try { super.startCompression("COMPRESS DEFLATE"); } catch (ProtocolException pex) { logger.log(Level.FINE, "COMPRESS ProtocolException", pex); // ProtocolException just means the command wasn't recognized, // or failed. This should never happen if we check the // CAPABILITY first. throw pex; } catch (Exception ex) { logger.log(Level.FINE, "COMPRESS Exception", ex); // any other exception means we have to shut down the connection // generate an artificial BYE response and disconnect Response[] r = { Response.byeResponse(ex) }; notifyResponseHandlers(r); disconnect(); throw new ProtocolException("COMPRESS failure", ex); } }
/** * COMPRESS Command. Only supports DEFLATE. * * @exception ProtocolException for protocol failures * @see "RFC 4978" */ public void compress() throws ProtocolException { try { super.startCompression("COMPRESS DEFLATE"); } catch (ProtocolException pex) { logger.log(Level.FINE, "COMPRESS ProtocolException", pex); // ProtocolException just means the command wasn't recognized, // or failed. This should never happen if we check the // CAPABILITY first. throw pex; } catch (Exception ex) { logger.log(Level.FINE, "COMPRESS Exception", ex); // any other exception means we have to shut down the connection // generate an artificial BYE response and disconnect Response[] r = { Response.byeResponse(ex) }; notifyResponseHandlers(r); disconnect(); throw new ProtocolException("COMPRESS failure", ex); } }
/** * STARTTLS Command. * * @exception ProtocolException for protocol failures * @see "RFC3501, section 6.2.1" */ public void startTLS() throws ProtocolException { try { super.startTLS("STARTTLS"); } catch (ProtocolException pex) { logger.log(Level.FINE, "STARTTLS ProtocolException", pex); // ProtocolException just means the command wasn't recognized, // or failed. This should never happen if we check the // CAPABILITY first. throw pex; } catch (Exception ex) { logger.log(Level.FINE, "STARTTLS Exception", ex); // any other exception means we have to shut down the connection // generate an artificial BYE response and disconnect Response[] r = { Response.byeResponse(ex) }; notifyResponseHandlers(r); disconnect(); throw new ProtocolException("STARTTLS failure", ex); } }
protocol.disconnect(); protocol = null; throw new ReferralException(ex.getUrl(), ex.getMessage()); protocol.disconnect(); protocol = null; Response r = cex.getResponse(); protocol.disconnect(); protocol = null; throw new MessagingException(pex.getMessage(), pex);
protocol.disconnect(); protocol = null; throw new ReferralException(ex.getUrl(), ex.getMessage()); protocol.disconnect(); protocol = null; Response r = cex.getResponse(); protocol.disconnect(); protocol = null; throw new MessagingException(pex.getMessage(), pex);
fullName); if (protocol != null) protocol.disconnect(); } else if (((IMAPStore)store).isConnectionPoolFull()) {
setCapabilities(r); } else { disconnect(); throw new ConnectionException(this, r);
fullName); if (protocol != null) protocol.disconnect(); } else if (((IMAPStore)store).isConnectionPoolFull()) {
setCapabilities(r); } else { disconnect(); throw new ConnectionException(this, r);