summaryrefslogtreecommitdiffstats
path: root/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp')
-rw-r--r--src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
index 94098b9..d65da7e 100644
--- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
+++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
@@ -19,6 +19,7 @@
#include "GSSAPIAuthRequestHandler.h"
#include <Net/Connection.h>
+#include <Net/Packets/ErrorPacket.h>
#include <cstring>
@@ -30,13 +31,20 @@ namespace RequestHandlers {
// TODO Error handling
-bool GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(packet.getType() != Net::Packet::GSSAPI_AUTH)
- return false; // TODO Logging
+void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(packet.getType() != Net::Packet::GSSAPI_AUTH) {
+ std::cerr << "Received an unexpected packet." << std::endl;
+ connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
+
+ signalFinished().emit();
+ return;
+ }
OM_uint32 majStat, minStat;
gss_buffer_desc recvBuffer, sendBuffer;
+ // Needs error handling!
+
if(gssContinue) {
recvBuffer.length = packet.getLength();
recvBuffer.value = std::malloc(recvBuffer.length);
@@ -52,19 +60,19 @@ bool GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
}
else if(majStat != GSS_S_CONTINUE_NEEDED) {
gss_release_buffer(&minStat, &sendBuffer);
- return false;
+ return;
}
if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
gss_release_buffer(&minStat, &sendBuffer);
- return false;
+ return;
}
gss_release_buffer(&minStat, &sendBuffer);
}
else if(!sentSignature) {
if(packet.getLength() != 0)
- return false;
+ return;
const gnutls_datum_t *cert = connection->getCertificate();
@@ -75,12 +83,12 @@ bool GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
if(majStat != GSS_S_COMPLETE) {
gss_release_buffer(&minStat, &sendBuffer);
- return false;
+ return;
}
if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
gss_release_buffer(&minStat, &sendBuffer);
- return false;
+ return;
}
gss_release_buffer(&minStat, &sendBuffer);
@@ -97,12 +105,10 @@ bool GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
std::free(recvBuffer.value);
if(majStat != GSS_S_COMPLETE)
- return false;
+ return;
signalFinished().emit();
}
-
- return true;
}
}