protected void taggedBad(ImapCommand command, String tag, ImapProcessor.Responder responder, HumanReadableText e) { StatusResponse response = factory.taggedBad(tag, command, e); responder.respond(response); }
protected void taggedBad(final ImapCommand command, final String tag, final ImapProcessor.Responder responder, final HumanReadableText e) { StatusResponse response = factory.taggedBad(tag, command, e); responder.respond(response); }
public ImapResponseMessage process(ImapMessage message) { LOGGER.debug("Unknown message: {}", message); final ImapResponseMessage result; if (message instanceof ImapRequest) { ImapRequest request = (ImapRequest) message; final String tag = request.getTag(); final ImapCommand command = request.getCommand(); result = factory.taggedBad(tag, command, HumanReadableText.UNKNOWN_COMMAND); } else { result = factory.untaggedBad(HumanReadableText.UNKNOWN_COMMAND); } return result; }
public ImapResponseMessage process(ImapMessage message, ImapSession session) { Logger logger = session.getLog(); if (logger != null && logger.isDebugEnabled()) { logger.debug("Unknown message: " + message); } final ImapResponseMessage result; if (message instanceof ImapRequest) { ImapRequest request = (ImapRequest) message; final String tag = request.getTag(); final ImapCommand command = request.getCommand(); result = factory.taggedBad(tag, command, HumanReadableText.UNKNOWN_COMMAND); } else { result = factory.untaggedBad(HumanReadableText.UNKNOWN_COMMAND); } return result; }
@Override public void onLine(ImapSession session, byte[] data) { String line; if (data.length > 2) { line = new String(data, 0, data.length - 2); } else { line = ""; } if (idleListener != null) { try { mailboxManager.removeListener(sm.getPath(), idleListener, mailboxSession); } catch (MailboxException e) { LOGGER.error("Unable to remove idle listener for mailbox {}", sm.getPath(), e); } } session.popLineHandler(); if (!DONE.equals(line.toUpperCase(Locale.US))) { StatusResponse response = getStatusResponseFactory().taggedBad(tag, command, HumanReadableText.INVALID_COMMAND); responder.respond(response); } else { okComplete(command, tag, responder); } idleActive.set(false); } });
StatusResponse response = getStatusResponseFactory().taggedBad(tag, command, HumanReadableText.INVALID_COMMAND); responder.respond(response); } else {
/** * Parses a request into a command message for later processing. * * @param request * <code>ImapRequestLineReader</code>, not null * @return <code>ImapCommandMessage</code>, not null */ @Override public final ImapMessage parse(ImapRequestLineReader request, String tag, ImapSession session) { ImapMessage result; if (!command.validForState(session.getState())) { result = statusResponseFactory.taggedNo(tag, command, HumanReadableText.INVALID_COMMAND); } else { try { result = decode(command, request, tag, session); } catch (DecodingException e) { LOGGER.debug("Cannot parse protocol ", e); result = statusResponseFactory.taggedBad(tag, command, e.getKey()); } } return result; }
@Test public void testTaggedBad() { StatusResponse response = factory.taggedBad(TAG, command, KEY); assertThat(response).isNotNull(); assertThat(response.getServerResponseType()).isEqualTo(StatusResponse.Type.BAD); assertThat(response.getTag()).isEqualTo(TAG); assertThat(response.getTextKey()).isEqualTo(KEY); assertThat(response.getResponseCode()).isNull(); assertThat(response.getCommand()).isEqualTo(command); response = factory.taggedBad(TAG, command, KEY, CODE); assertThat(response).isNotNull(); assertThat(response.getServerResponseType()).isEqualTo(StatusResponse.Type.BAD); assertThat(response.getTag()).isEqualTo(TAG); assertThat(response.getTextKey()).isEqualTo(KEY); assertThat(response.getResponseCode()).isEqualTo(CODE); assertThat(response.getCommand()).isEqualTo(command); }
/** * Parses a request into a command message for later processing. * * @param request * <code>ImapRequestLineReader</code>, not null * @return <code>ImapCommandMessage</code>, not null */ public final ImapMessage parse(ImapRequestLineReader request, String tag, ImapSession session) { ImapMessage result; if (!command.validForState(session.getState())) { result = statusResponseFactory.taggedNo(tag, command, HumanReadableText.INVALID_COMMAND); } else { try { result = decode(command, request, tag, session); } catch (DecodingException e) { if (session.getLog().isDebugEnabled()) { session.getLog().debug("Cannot parse protocol ", e); } result = statusResponseFactory.taggedBad(tag, command, e.getKey()); } } return result; }
private ImapMessage unknownCommand(final String tag, final ImapSession session) { ImapMessage message; Object c = session.getAttribute(INVALID_COMMAND_COUNT); int count = 0; if (c != null) { count = (Integer) c; } count++; if (count > maxInvalidCommands || session.getState() == ImapSessionState.NON_AUTHENTICATED) { message = responseFactory.bye(HumanReadableText.BYE_UNKNOWN_COMMAND); session.logout(); } else { session.setAttribute(INVALID_COMMAND_COUNT, count); if (tag == null) { message = responseFactory.untaggedBad(HumanReadableText.UNKNOWN_COMMAND); } else { message = responseFactory.taggedBad(tag, null, HumanReadableText.UNKNOWN_COMMAND); } } return message; }
private ImapMessage unknownCommand(String tag, ImapSession session) { ImapMessage message; Object c = session.getAttribute(INVALID_COMMAND_COUNT); int count = 0; if (c != null) { count = (Integer) c; } count++; if (count > maxInvalidCommands || session.getState() == ImapSessionState.NON_AUTHENTICATED) { message = responseFactory.bye(HumanReadableText.BYE_UNKNOWN_COMMAND); session.logout(); } else { session.setAttribute(INVALID_COMMAND_COUNT, count); if (tag == null) { message = responseFactory.untaggedBad(HumanReadableText.UNKNOWN_COMMAND); } else { message = responseFactory.taggedBad(tag, null, HumanReadableText.UNKNOWN_COMMAND); } } return message; }
@Override protected void doProcess(StartTLSRequest request, Responder responder, ImapSession session) { if (session.supportStartTLS()) { responder.respond(factory.taggedOk(request.getTag(), request.getCommand(), HumanReadableText.STARTTLS)); session.startTLS(); } else { responder.respond(factory.taggedBad(request.getTag(), request.getCommand(), HumanReadableText.UNKNOWN_COMMAND)); } }
/** * @see * org.apache.james.imap.processor.base.AbstractChainedProcessor * #doProcess(org.apache.james.imap.api.ImapMessage, * org.apache.james.imap.api.process.ImapProcessor.Responder, * org.apache.james.imap.api.process.ImapSession) */ protected void doProcess(StartTLSRequest request, Responder responder, ImapSession session) { if (session.supportStartTLS()) { responder.respond(factory.taggedOk(request.getTag(), request.getCommand(), HumanReadableText.STARTTLS)); session.startTLS(); } else { responder.respond(factory.taggedBad(request.getTag(), request.getCommand(), HumanReadableText.UNKNOWN_COMMAND)); } }
@Override protected void doProcess(CompressRequest request, Responder responder, ImapSession session) { if (session.isCompressionSupported()) { Object obj = session.getAttribute(COMPRESSED); if (obj != null) { responder.respond(factory.taggedNo(request.getTag(), request.getCommand(), HumanReadableText.COMPRESS_ALREADY_ACTIVE)); } else { if (request.getAlgorithm().equalsIgnoreCase(ALGO) == false) { responder.respond(factory.taggedBad(request.getTag(), request.getCommand(), HumanReadableText.ILLEGAL_ARGUMENTS)); } else { responder.respond(factory.taggedOk(request.getTag(), request.getCommand(), HumanReadableText.DEFLATE_ACTIVE)); if (session.startCompression()) { session.setAttribute(COMPRESSED, true); } } } } else { responder.respond(factory.taggedBad(request.getTag(), request.getCommand(), HumanReadableText.UNKNOWN_COMMAND)); } }
/** * @see * org.apache.james.imap.processor.base.AbstractChainedProcessor#doProcess(org.apache.james.imap.api.ImapMessage, * org.apache.james.imap.api.process.ImapProcessor.Responder, * org.apache.james.imap.api.process.ImapSession) */ protected void doProcess(CompressRequest request, Responder responder, ImapSession session) { if (session.isCompressionSupported()) { Object obj = session.getAttribute(COMPRESSED); if (obj != null) { responder.respond(factory.taggedNo(request.getTag(), request.getCommand(), HumanReadableText.COMPRESS_ALREADY_ACTIVE)); } else { if (request.getAlgorithm().equalsIgnoreCase(ALGO) == false) { responder.respond(factory.taggedBad(request.getTag(), request.getCommand(), HumanReadableText.ILLEGAL_ARGUMENTS)); } else { responder.respond(factory.taggedOk(request.getTag(), request.getCommand(), HumanReadableText.DEFLATE_ACTIVE)); if (session.startCompression()) { session.setAttribute(COMPRESSED, true); } } } } else { responder.respond(factory.taggedBad(request.getTag(), request.getCommand(), HumanReadableText.UNKNOWN_COMMAND)); } }