2 * Copyright (c) 2014 <copyright holder> <email>
4 * For license details, see the LICENSE file in the root of this project.
9 #include <cache/GSSContextCache.h>
11 GSSUnwrap::GSSUnwrap ( JSONObject* params, gss_unwrap_type fn )
14 loadParameters(params);
17 bool GSSUnwrap::loadParameters(JSONObject *params)
20 std::string sInputMessage;
31 if ( ! params->get("arguments").get("input_message").isNull() )
33 sInputMessage = params->get("arguments").get("input_message").string();
34 this->inputMessage.setValue(sInputMessage);
40 if ( ! params->get("arguments").get("context_handle").isNull() )
42 sInputMessage = params->get("arguments").get("context_handle").string();
43 GSSContext ctx = GSSContextCache::instance()->retrieve(sInputMessage);
44 this->context = ctx.getContext();
53 void GSSUnwrap::execute()
56 gss_buffer_desc output_buf;
59 &(this->minor_status),
61 this->inputMessage.toGss(),
67 this->outputMessage.setValue( (char *)output_buf.value, output_buf.length );
70 JSONObject* GSSUnwrap::toJSON()
73 const char *conf_state;
74 JSONObject *ret = new JSONObject();
75 JSONObject *values = new JSONObject();
84 values->set("major_status", this->retVal);
85 values->set("minor_status", this->minor_status);
87 values->set("qop_state", this->qop_state);
89 conf_state = (this->conf_state) ? "TRUE" : "FALSE";
90 values->set("conf_state", conf_state);
94 this->outputMessage.toString().c_str()
97 // Put it all together.
98 ret->set("command", "gss_wrap");
99 ret->set("return_values", *values);