@Override protected Closeable addContextToMDC(AuthenticateRequest message) { return MDCBuilder.create() .addContext(MDCBuilder.ACTION, "AUTHENTICATE") .addContext("authType", message.getAuthType()) .build(); } }
@Override protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, ImapSession session) throws DecodingException { ImapMessage result; String authType = request.astring(); try { result = new AuthenticateRequest(command, authType, tag); request.eol(); } catch (DecodingException e) { // Ok this means we have some SASL-IR request to parse String initialClientResponse = request.astring(); result = new IRAuthenticateRequest(command, authType, tag, initialClientResponse); request.eol(); } return result; }
/** * @see * org.apache.james.imap.decode.base.AbstractImapCommandParser#decode(org.apache.james.imap.api.ImapCommand, * org.apache.james.imap.decode.ImapRequestLineReader, java.lang.String, * org.apache.james.imap.api.process.ImapSession) */ protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, ImapSession session) throws DecodingException { ImapMessage result; String authType = request.astring(); try { result = new AuthenticateRequest(command, authType, tag); request.eol(); } catch (DecodingException e) { // Ok this means we have some SASL-IR request to parse String initialClientResponse = request.astring(); result = new IRAuthenticateRequest(command, authType, tag, initialClientResponse); request.eol(); } return result; }
@Override protected void doProcess(AuthenticateRequest request, ImapSession session, final String tag, final ImapCommand command, final Responder responder) { final String authType = request.getAuthType(); if (authType.equalsIgnoreCase(PLAIN)) { // See if AUTH=PLAIN is allowed. See IMAP-304 if (session.isPlainAuthDisallowed() && session.isTLSActive() == false) { no(command, tag, responder, HumanReadableText.DISABLED_LOGIN); } else { if (request instanceof IRAuthenticateRequest) { IRAuthenticateRequest irRequest = (IRAuthenticateRequest) request; doPlainAuth(irRequest.getInitialClientResponse(), session, tag, command, responder); } else { responder.respond(new AuthenticateResponse()); session.pushLineHandler((requestSession, data) -> { // cut of the CRLF String initialClientResponse = new String(data, 0, data.length - 2, Charset.forName("US-ASCII")); doPlainAuth(initialClientResponse, requestSession, tag, command, responder); // remove the handler now requestSession.popLineHandler(); }); } } } else { LOGGER.debug("Unsupported authentication mechanism '{}'", authType); no(command, tag, responder, HumanReadableText.UNSUPPORTED_AUTHENTICATION_MECHANISM); } }
final String authType = request.getAuthType(); if (authType.equalsIgnoreCase(PLAIN)) {