14 #include "nonsaslauth.h"
25 NonSaslAuth::Query::Query(
const std::string& user )
26 : StanzaExtension(
ExtNonSaslAuth ), m_user( user ), m_digest( true )
30 NonSaslAuth::Query::Query(
const Tag* tag )
33 if( !tag || tag->name() !=
"query" || tag->xmlns() != XMLNS_AUTH )
36 m_digest = tag->hasChild(
"digest" );
39 NonSaslAuth::Query* NonSaslAuth::Query::newInstance(
const std::string& user,
40 const std::string& sid,
41 const std::string& pwd,
42 const std::string& resource )
const
44 Query* q =
new Query( user );
45 if( m_digest && !sid.empty() )
55 q->m_resource = resource;
56 q->m_digest = m_digest;
60 const std::string& NonSaslAuth::Query::filterString()
const
62 static const std::string filter =
"/iq/query[@xmlns='" +
XMLNS_AUTH +
"']";
66 Tag* NonSaslAuth::Query::tag()
const
71 Tag* t =
new Tag(
"query" );
72 t->setXmlns( XMLNS_AUTH );
73 new Tag( t,
"username", m_user );
75 if( !m_pwd.empty() && !m_resource.empty() )
77 new Tag( t, m_digest ?
"digest" :
"password", m_pwd );
78 new Tag( t,
"resource", m_resource );
86 NonSaslAuth::NonSaslAuth(
Client* parent )
109 const std::string&
id = m_parent->
getID();
113 m_parent->
send( iq,
this, TrackRequestAuthFields );
147 case TrackRequestAuthFields:
153 const std::string&
id = m_parent->
getID();
159 m_parent->
send( re,
this, TrackSendAuth );
164 m_parent->connected();
const std::string getID()
void setAuthFailure(AuthenticationError e)
void setAuthed(bool authed)
virtual const std::string & username() const
void removeIqHandler(IqHandler *ih, int exttype)
void removeIDHandler(IqHandler *ih)
bool removeStanzaExtension(int ext)
virtual const std::string & password() const
void registerIqHandler(IqHandler *ih, int exttype)
void registerStanzaExtension(StanzaExtension *ext)
This class implements a basic Jabber/XMPP Client.
A stanza error abstraction implemented as a StanzaExtension.
StanzaError error() const
An abstraction of an IQ stanza.
const std::string & server() const
const std::string & resource() const
void doAuth(const std::string &sid)
virtual void handleIqID(const IQ &iq, int context)
void addExtension(const StanzaExtension *se)
const Error * error() const
const StanzaExtension * findExtension(int type) const
The namespace for the gloox library.
@ ConnAuthenticationFailed
@ StanzaErrorNotAuthorized
@ StanzaErrorNotAcceptable
const std::string XMLNS_AUTH