summaryrefslogtreecommitdiffstats
path: root/src/Core/RequestHandlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/RequestHandlers')
-rw-r--r--src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp40
-rw-r--r--src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h6
2 files changed, 32 insertions, 14 deletions
diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
index e459511..d9694c8 100644
--- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
+++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
@@ -18,9 +18,10 @@
*/
#include "GSSAPIAuthRequestHandler.h"
+#include <Common/Exception.h>
#include <Common/Logger.h>
+#include <Common/XmlPacket.h>
#include <Net/Connection.h>
-#include <Net/Packets/ErrorPacket.h>
#include <cstring>
@@ -30,10 +31,15 @@ namespace RequestHandlers {
// TODO Error handling
-void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(packet.getType() != Net::Packet::GSSAPI_AUTH) {
+void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet) {
+ if(packet.getType() != "AuthGSSAPI") {
Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
- connection->send(Net::Packets::ErrorPacket(Net::Packet::ERROR, packet.getRequestId(), Common::Exception(Common::Exception::UNEXPECTED_PACKET)));
+
+ Common::XmlPacket ret;
+ ret.setType("Error");
+ ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET);
+
+ connection->send(ret.encode(requestId));
signalFinished().emit();
return;
@@ -45,9 +51,11 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
// Needs error handling!
if(gssContinue) {
- recvBuffer.length = packet.getLength();
+ const void *pkgData;
+ packet["authToken"].getBinaryData(&pkgData, &recvBuffer.length);
+
recvBuffer.value = std::malloc(recvBuffer.length);
- std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
+ std::memcpy(recvBuffer.value, pkgData, recvBuffer.length);
majStat = gss_accept_sec_context(&minStat, &gssContext, GSS_C_NO_CREDENTIAL, &recvBuffer, GSS_C_NO_CHANNEL_BINDINGS, 0, 0, &sendBuffer, 0, 0, 0);
@@ -62,7 +70,11 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
return;
}
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ Common::XmlPacket ret;
+ ret.setType("AuthGSSAPI");
+ ret.addBinary("authToken", sendBuffer.value, sendBuffer.length);
+
+ if(!connection->send(ret.encode(requestId))) {
gss_release_buffer(&minStat, &sendBuffer);
return;
}
@@ -70,7 +82,7 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
gss_release_buffer(&minStat, &sendBuffer);
}
else if(!sentSignature) {
- if(packet.getLength() != 0)
+ if(!packet["binary"].isEmpty())
return;
const gnutls_datum_t *cert = connection->getCertificate();
@@ -85,7 +97,11 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
return;
}
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ Common::XmlPacket ret;
+ ret.setType("AuthGSSAPI");
+ ret.addBinary("certMic", sendBuffer.value, sendBuffer.length);
+
+ if(!connection->send(ret.encode(requestId))) {
gss_release_buffer(&minStat, &sendBuffer);
return;
}
@@ -95,9 +111,11 @@ void GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const N
sentSignature = true;
}
else {
- recvBuffer.length = packet.getLength();
+ const void *pkgData;
+ packet["authToken"].getBinaryData(&pkgData, &recvBuffer.length);
+
recvBuffer.value = std::malloc(recvBuffer.length);
- std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
+ std::memcpy(recvBuffer.value, pkgData, recvBuffer.length);
majStat = gss_process_context_token(&minStat, gssContext, &recvBuffer);
diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h
index e222fef..7f8ce3b 100644
--- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h
+++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h
@@ -20,21 +20,21 @@
#ifndef MAD_CORE_REQUESTHANDLERS_GSSAPIAUTHREQUESTHANDLER_H_
#define MAD_CORE_REQUESTHANDLERS_GSSAPIAUTHREQUESTHANDLER_H_
-#include <Common/RequestHandler.h>
+#include <Common/XmlRequestHandler.h>
#include <gssapi/gssapi.h>
namespace Mad {
namespace Core {
namespace RequestHandlers {
-class GSSAPIAuthRequestHandler : public Common::RequestHandler {
+class GSSAPIAuthRequestHandler : public Common::XmlRequestHandler {
private:
gss_ctx_id_t gssContext;
bool gssContinue, sentSignature;
protected:
- virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
+ virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const Common::XmlPacket &packet);
public:
GSSAPIAuthRequestHandler() : gssContext(GSS_C_NO_CONTEXT), gssContinue(true), sentSignature(false) {}