summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Client')
-rw-r--r--Swiften/Client/Client.cpp3
-rw-r--r--Swiften/Client/ClientError.h1
-rw-r--r--Swiften/Client/ClientSession.cpp18
-rw-r--r--Swiften/Client/ClientSession.h1
4 files changed, 16 insertions, 7 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index 2bd039a..874e23b 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -138,12 +138,15 @@ void Client::handleSessionFinished(boost::shared_ptr<Error> error) {
ClientError clientError;
if (boost::shared_ptr<ClientSession::Error> actualError = boost::dynamic_pointer_cast<ClientSession::Error>(error)) {
switch(actualError->type) {
case ClientSession::Error::AuthenticationFailedError:
clientError = ClientError(ClientError::AuthenticationFailedError);
break;
+ case ClientSession::Error::ServerVerificationFailedError:
+ clientError = ClientError(ClientError::ServerVerificationFailedError);
+ break;
case ClientSession::Error::NoSupportedAuthMechanismsError:
clientError = ClientError(ClientError::NoSupportedAuthMechanismsError);
break;
case ClientSession::Error::UnexpectedElementError:
clientError = ClientError(ClientError::UnexpectedElementError);
break;
diff --git a/Swiften/Client/ClientError.h b/Swiften/Client/ClientError.h
index d4f280c..55c57fc 100644
--- a/Swiften/Client/ClientError.h
+++ b/Swiften/Client/ClientError.h
@@ -8,12 +8,13 @@ namespace Swift {
DomainNameResolveError,
ConnectionError,
ConnectionReadError,
ConnectionWriteError,
XMLError,
AuthenticationFailedError,
+ ServerVerificationFailedError,
NoSupportedAuthMechanismsError,
UnexpectedElementError,
ResourceBindError,
SessionStartError,
TLSError,
ClientCertificateLoadError,
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index fb80754..960af70 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -127,20 +127,24 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
stream->writeElement(boost::shared_ptr<AuthResponse>(new AuthResponse(authenticator->getResponse())));
}
else {
finishSession(Error::AuthenticationFailedError);
}
}
- else if (dynamic_cast<AuthSuccess*>(element.get())) {
- // TODO: Check success data with authenticator
+ else if (AuthSuccess* authSuccess = dynamic_cast<AuthSuccess*>(element.get())) {
checkState(Authenticating);
- state = WaitingForStreamStart;
- delete authenticator;
- authenticator = NULL;
- stream->resetXMPPParser();
- sendStreamHeader();
+ if (!authenticator->setChallenge(authSuccess->getValue())) {
+ finishSession(Error::ServerVerificationFailedError);
+ }
+ else {
+ state = WaitingForStreamStart;
+ delete authenticator;
+ authenticator = NULL;
+ stream->resetXMPPParser();
+ sendStreamHeader();
+ }
}
else if (dynamic_cast<AuthFailure*>(element.get())) {
delete authenticator;
authenticator = NULL;
finishSession(Error::AuthenticationFailedError);
}
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h
index f3bc119..5e5acbc 100644
--- a/Swiften/Client/ClientSession.h
+++ b/Swiften/Client/ClientSession.h
@@ -31,12 +31,13 @@ namespace Swift {
Finished
};
struct Error : public Swift::Error {
enum Type {
AuthenticationFailedError,
+ ServerVerificationFailedError,
NoSupportedAuthMechanismsError,
UnexpectedElementError,
ResourceBindError,
SessionStartError,
TLSClientCertificateError,
TLSError,