Merge branch 'next' of ssh://down.oryx.com/oryx/aox into next
[aox:aox.git] / sasl / sasllogin.cpp
1 // Copyright 2009 The Archiveopteryx Developers <info@aox.org>
2
3 #include "sasllogin.h"
4
5
6 /*! \class SaslLogin sasllogin.h
7     Implement SASL LOGIN authentication.
8
9     LOGIN is a non-standard SASL authentication mechanism, described in
10     the now-abandoned draft-murchison-sasl-login-*.txt
11
12     We issue the standard "User Name" and "Password" challenges, not the
13     permitted alternative "Username:" and "Password:".
14
15     (This class is not named just "Login" because of the IMAP command of
16     the same name.)
17 */
18
19
20 /*! Creates a new SaslLogin object on behalf of \a c. */
21
22 SaslLogin::SaslLogin( EventHandler * c )
23     : SaslMechanism( c, SaslMechanism::Login )
24 {
25 }
26
27
28 EString SaslLogin::challenge()
29 {
30     if ( login().isEmpty() )
31         return "Username:";
32     else
33         return "Password:";
34 }
35
36
37 void SaslLogin::parseResponse( const EString &s )
38 {
39     if ( login().isEmpty() ) {
40         if ( s.isEmpty() ) {
41             setState( Failed );
42         }
43         else {
44             setLogin( s );
45             setState( IssuingChallenge );
46         }
47     }
48     else {
49         setSecret( s );
50         setState( Authenticating );
51     }
52     execute();
53 }