@Override public ProtocolSession newSession(ProtocolTransport transport) { return new POP3SessionImpl(transport, getConfiguration()); }
@Override public List<CharSequence> getLines() { return POP3StartTlsResponse.this.getLines(); } };
public POP3Configuration() { setSoftwareName("JAMES Protocols POP3 Server"); } }
private POP3Protocol createProtocol(AbstractPassCmdHandler handler) throws WiringException { return new POP3Protocol(new POP3ProtocolHandlerChain(handler), new POP3Configuration()); }
@Override public Response onConnect(POP3Session session) { StringBuilder responseBuffer = new StringBuilder(); // Generate the timestamp which can be also used with APOP. See RFC1939 APOP responseBuffer.append("<").append(session.getSessionID()).append(".").append(System.currentTimeMillis()).append("@").append(session.getConfiguration().getHelloName()).append("> "); // store the timestamp for later usage session.setAttachment(POP3Session.APOP_TIMESTAMP, responseBuffer.toString(), State.Connection); // complete the response banner and send it back to the client responseBuffer.append("POP3 server (").append(session.getConfiguration().getSoftwareName()).append(") ready "); return new POP3Response(POP3Response.OK_RESPONSE, responseBuffer.toString()); }
@Override public Response onCommand(POP3Session session, Request request) { // check if starttls is supported, the state is the right one and it was // not started before if (session.isStartTLSSupported() && session.getHandlerState() == POP3Session.AUTHENTICATION_READY && session.isTLSStarted() == false) { return BEGIN_TLS; } else { return POP3Response.ERR; } }
@Override @SuppressWarnings("unchecked") public Set<String> getImplementedCapabilities(POP3Session session) { if (session.isStartTLSSupported() && session.getHandlerState() == POP3Session.AUTHENTICATION_READY) { return CAPS; } else { return Collections.EMPTY_SET; } }
/** * The {@link AbstractPassCmdHandler}'s to use. If at least one {@link AbstractPassCmdHandler} is given, the {@link POP3ProtocolHandlerChain} * will add all default handlers * * @param authHandlers * @throws WiringException */ public POP3ProtocolHandlerChain(AbstractPassCmdHandler... authHandlers) throws WiringException { if (authHandlers != null && authHandlers.length > 0) { addAll(initDefaultHandlers(authHandlers)); wireExtensibleHandlers(); } }
@Override public Response onCommand(POP3Session session, Request request) { POP3Response response = new POP3Response(POP3Response.OK_RESPONSE, "Capability list follows"); for (CapaCapability capabilities : caps) { for (String cap : capabilities.getImplementedCapabilities(session)) { response.appendLine(cap); } } response.appendLine("."); return response; }
/** * Handler method called upon receipt of a NOOP command. Like all good * NOOPs, does nothing much. */ @Override public Response onCommand(POP3Session session, Request request) { if (session.getHandlerState() == POP3Session.TRANSACTION) { return POP3Response.OK; } else { return POP3Response.ERR; } }
@Override protected final Mailbox auth(POP3Session session, String username, String password) throws Exception { return auth(session, (String)session.getAttachment(POP3Session.APOP_TIMESTAMP, State.Connection), username, password); }
@Override public void resetState() { getState().clear(); setHandlerState(AUTHENTICATION_READY); }
/** * {@link #POP3Response(String, CharSequence)} * */ public POP3Response(String code) { setRetCode(code); }
@Override public boolean isEndSession() { return POP3StartTlsResponse.this.isEndSession(); }
@Override public String getRetCode() { return POP3StartTlsResponse.this.getRetCode(); }
private POP3Protocol createProtocol(AbstractPassCmdHandler handler) throws WiringException { return new POP3Protocol(new POP3ProtocolHandlerChain(handler), new POP3Configuration()); }
@Override @SuppressWarnings("unchecked") public Set<String> getImplementedCapabilities(POP3Session session) { if (session.getHandlerState() == POP3Session.TRANSACTION) { return CAPS; } else { return Collections.EMPTY_SET; } }
private POP3Protocol createProtocol(AbstractPassCmdHandler handler) throws WiringException { return new POP3Protocol(new POP3ProtocolHandlerChain(handler), new POP3Configuration()); }
@Override @SuppressWarnings("unchecked") public Set<String> getImplementedCapabilities(POP3Session session) { if (session.getHandlerState() == POP3Session.TRANSACTION) { return CAPS; } else { return Collections.EMPTY_SET; } }
private POP3Protocol createProtocol(AbstractPassCmdHandler handler) throws WiringException { return new POP3Protocol(new POP3ProtocolHandlerChain(handler), new POP3Configuration()); }