21#ifndef G_POP_SERVER_PROTOCOL_H
22#define G_POP_SERVER_PROTOCOL_H
35 class ServerProtocol ;
36 class ServerProtocolText ;
50 G_EXCEPTION( ProtocolDone ,
"pop protocol done" ) ;
55 virtual bool protocolSend(
const std::string & s , std::size_t offset ) = 0 ;
62 virtual std::string greeting()
const = 0 ;
63 virtual std::string quit()
const = 0 ;
64 virtual std::string capa()
const = 0 ;
65 virtual std::string user(
const std::string &
id )
const = 0 ;
66 virtual ~Text() = default ;
77 virtual bool securityEnabled()
const = 0 ;
78 virtual void securityStart() = 0 ;
98 void apply(
const std::string & line ) ;
145 using EventData =
const std::string & ;
149 ~ServerProtocol() = default ;
156 void doQuit(
const std::string & line ,
bool & ) ;
157 void doQuitEarly(
const std::string & line ,
bool & ) ;
158 void doStat(
const std::string & line ,
bool & ) ;
159 void doList(
const std::string & line ,
bool & ) ;
160 void doRetr(
const std::string & line ,
bool & ) ;
161 void doDele(
const std::string & line ,
bool & ) ;
162 void doRset(
const std::string & line ,
bool & ) ;
163 void doUser(
const std::string & line ,
bool & ) ;
164 void doPass(
const std::string & line ,
bool & ) ;
165 void doNoop(
const std::string & line ,
bool & ) ;
166 void doNothing(
const std::string & line ,
bool & ) ;
167 void doApop(
const std::string & line ,
bool & ) ;
168 void doTop(
const std::string & line ,
bool & ) ;
169 void doCapa(
const std::string & line ,
bool & ) ;
170 void doStls(
const std::string & line ,
bool & ) ;
171 void doAuth(
const std::string & line ,
bool & ) ;
172 void doAuthData(
const std::string & line ,
bool & ) ;
173 void doAuthComplete(
const std::string & line ,
bool & ) ;
174 void doUidl(
const std::string & line ,
bool & ) ;
177 void sendError(
const std::string & ) ;
179 static const std::string & crlf() ;
180 Event commandEvent(
const std::string & )
const ;
181 int commandNumber(
const std::string & ,
int , std::size_t index = 1U )
const ;
182 void sendList(
const std::string & ,
bool ) ;
183 std::string commandWord(
const std::string & )
const ;
184 std::string commandParameter(
const std::string & , std::size_t index = 1U )
const ;
185 std::string commandPart(
const std::string & , std::size_t index )
const ;
187 bool sendContentLine( std::string & ,
bool & ) ;
188 void sendLine( std::string ) ;
189 void sendLines( std::ostringstream & ) ;
191 std::string mechanisms()
const ;
192 bool mechanismsIncludePlain()
const ;
195 const Text & m_text ;
197 Security & m_security ;
199 StoreLock m_store_lock ;
200 std::unique_ptr<GAuth::SaslServer> m_sasl_server ;
204 std::unique_ptr<std::istream> m_content ;
208 bool m_sasl_server_init_apop ;
228 std::string greeting()
const override ;
229 std::string quit()
const override ;
230 std::string capa()
const override ;
231 std::string user(
const std::string &
id )
const override ;
An interface used by GAuth::SaslServer to obtain authentication secrets.
The GNet::Address class encapsulates a TCP/UDP transport address.
A default implementation for the ServerProtocol::Text interface.
ServerProtocolText(const GNet::Address &peer)
Constructor.
An interface used by ServerProtocol to enable TLS.
An interface used by ServerProtocol to send protocol replies.
An interface used by ServerProtocol to provide response text strings.
Implements the POP server-side protocol.
void resume()
Called when the Sender can send again.
void secure()
Called when the server connection becomes secure.
void init()
Starts the protocol.
void apply(const std::string &line)
Called on receipt of a string from the client.
ServerProtocol(Sender &sender, Security &security, Store &store, const GAuth::SaslServerSecrets &server_secrets, const std::string &sasl_server_config, const Text &text, const GNet::Address &peer_address, const Config &config)
Constructor.
A structure containing configuration parameters for ServerProtocol, currently empty.