summaryrefslogtreecommitdiffstats
path: root/src/Common/Requests
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/Requests')
-rw-r--r--src/Common/Requests/GSSAPIAuthRequest.cpp37
-rw-r--r--src/Common/Requests/GSSAPIAuthRequest.h8
2 files changed, 31 insertions, 14 deletions
diff --git a/src/Common/Requests/GSSAPIAuthRequest.cpp b/src/Common/Requests/GSSAPIAuthRequest.cpp
index 05fb373..7f4617a 100644
--- a/src/Common/Requests/GSSAPIAuthRequest.cpp
+++ b/src/Common/Requests/GSSAPIAuthRequest.cpp
@@ -19,6 +19,7 @@
#include "GSSAPIAuthRequest.h"
#include "../Logger.h"
+#include "../XmlPacket.h"
#include <Net/Connection.h>
#include <cstring>
@@ -65,7 +66,11 @@ void GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t reques
return;
}
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, requestId, buffer.value, buffer.length))) {
+ XmlPacket ret;
+ ret.setType("AuthGSSAPI");
+ ret.addBinary("authToken", buffer.value, buffer.length);
+
+ if(!connection->send(ret.encode(requestId))) {
gss_release_buffer(&minStat, &buffer);
return;
}
@@ -73,8 +78,8 @@ void GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t reques
gss_release_buffer(&minStat, &buffer);
}
-void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(packet.getType() != Net::Packet::GSSAPI_AUTH) {
+void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, uint16_t requestId, const XmlPacket &packet) {
+ if(packet.getType() != "AuthGSSAPI") {
finishWithError(Exception(Exception::UNEXPECTED_PACKET));
return; // TODO Logging
}
@@ -85,9 +90,11 @@ void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Pac
// 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_init_sec_context(&minStat, GSS_C_NO_CREDENTIAL, &gssContext, gssServiceName, GSS_C_NO_OID, GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_INTEG_FLAG,
0, GSS_C_NO_CHANNEL_BINDINGS, &recvBuffer, 0, &sendBuffer, 0, 0);
@@ -103,7 +110,11 @@ void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Pac
return;
}
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ XmlPacket ret;
+ ret.setType("AuthGSSAPI");
+ ret.addBinary("authToken", sendBuffer.value, sendBuffer.length);
+
+ if(!connection->send(ret.encode(requestId))) {
gss_release_buffer(&minStat, &sendBuffer);
return;
}
@@ -111,9 +122,11 @@ void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Pac
gss_release_buffer(&minStat, &sendBuffer);
}
else {
- recvBuffer.length = packet.getLength();
+ const void *pkgData;
+ packet["certMic"].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);
const gnutls_datum_t *cert = connection->getPeerCertificate();
@@ -137,14 +150,18 @@ void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Pac
return;
}
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ XmlPacket ret;
+ ret.setType("AuthGSSAPI");
+ ret.addBinary("authToken", sendBuffer.value, sendBuffer.length);
+
+ if(!connection->send(ret.encode(requestId))) {
gss_release_buffer(&minStat, &sendBuffer);
return;
}
gss_release_buffer(&minStat, &sendBuffer);
- finish();
+ finish(XmlPacket());
}
}
diff --git a/src/Common/Requests/GSSAPIAuthRequest.h b/src/Common/Requests/GSSAPIAuthRequest.h
index 8f2328b..d9f5c9c 100644
--- a/src/Common/Requests/GSSAPIAuthRequest.h
+++ b/src/Common/Requests/GSSAPIAuthRequest.h
@@ -20,7 +20,7 @@
#ifndef MAD_COMMON_REQUESTS_GSSAPIAUTHREQUEST_H_
#define MAD_COMMON_REQUESTS_GSSAPIAUTHREQUEST_H_
-#include "../Request.h"
+#include "../XmlRequest.h"
#include <string>
#include <gssapi/gssapi.h>
@@ -30,7 +30,7 @@ namespace Requests {
// TODO Logging & error handling!
-class GSSAPIAuthRequest : public Request<> {
+class GSSAPIAuthRequest : public XmlRequest {
private:
std::string serviceName;
gss_name_t gssServiceName;
@@ -39,11 +39,11 @@ class GSSAPIAuthRequest : public Request<> {
bool gssContinue;
virtual void sendRequest(Net::Connection *connection, uint16_t requestId);
- virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet);
+ virtual void handlePacket(Net::Connection *connection, uint16_t requestId, const XmlPacket &packet);
public:
GSSAPIAuthRequest(const std::string &serviceName0, slot_type slot)
- : Request<>(slot), serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {}
+ : XmlRequest(slot), serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {}
virtual ~GSSAPIAuthRequest();
};