35 bool init(
const std::string & mechanism ) ;
36 bool authenticated(
const std::string & ,
const std::string & ) ;
37 bool mustChallenge()
const ;
38 std::string challenge() ;
39 std::string id()
const ;
40 std::string mechanisms()
const ;
41 bool sensitive()
const ;
45 unique_ptr<GAuth::SaslServer> m_sasl ;
51 GPop::AuthImp::AuthImp(
const Secrets & secrets ) :
53 m_sasl(
GAuth::SaslServerFactory::newSaslServer(secrets,true)) ,
56 m_sasl->init(
"APOP" ) ;
59 bool GPop::AuthImp::valid()
const
61 return m_secrets.valid() && m_sasl->active() ;
64 bool GPop::AuthImp::init(
const std::string & mechanism )
66 G_DEBUG(
"GPop::AuthImp::init: mechanism " << mechanism ) ;
76 if( mechanism ==
"APOP" )
80 return m_sasl->init( mechanism ) ;
83 bool GPop::AuthImp::authenticated(
const std::string & p1 ,
const std::string & p2 )
86 std::string challenge_1 = m_sasl->apply( p1 , done_1 ) ;
89 return challenge_1.empty() && m_sasl->authenticated() ;
94 std::string challenge_2 = m_sasl->apply( p2 , done_2 ) ;
95 return done_2 && challenge_2.empty() && m_sasl->authenticated() ;
99 bool GPop::AuthImp::mustChallenge()
const
101 return m_sasl->mustChallenge() ;
104 std::string GPop::AuthImp::challenge()
106 return m_sasl->initialChallenge() ;
109 std::string GPop::AuthImp::id()
const
111 return m_sasl->id() ;
114 std::string GPop::AuthImp::mechanisms()
const
116 return m_sasl->mechanisms() ;
119 bool GPop::AuthImp::sensitive()
const
121 return m_sasl->requiresEncryption() ;
138 return m_imp->valid() ;
143 return m_imp->init(mechanism) ;
148 return m_imp->authenticated(p1,p2) ;
153 return m_imp->mustChallenge() ;
158 return m_imp->challenge() ;
168 return m_imp->mechanisms() ;
173 return m_imp->sensitive() ;
A simple interface to a store of secrets as used in authentication.
std::string mechanisms() const
Returns a space-separated list of standard, supported SASL mechanisms (so not including APOP)...
bool mustChallenge() const
Returns true if the init()ialised mechanism requires an initial challenge.
bool init(const std::string &mechanism)
Initialises or reinitialises with the specified mechanism.
std::string challenge()
Returns an initial challenge appropriate to the current mechanism.
std::string id() const
Returns the authenticated user id.
bool sensitive() const
Returns true if the implementation requires authentication to be restricted to encrypted transports...
bool authenticated(const std::string &rsp1, const std::string &rsp2)
Authenticates a one-step (APOP,PLAIN) or two-step (LOGIN) challenge-response sequence.
A private pimple-pattern implementation class used by GPop::Auth.
bool valid() const
Returns true if the secrets are valid.
SASL authentication classes.
Auth(const Secrets &)
Constructor.