2 * Copyright (c) 2014 <copyright holder> <email>
4 * For license details, see the LICENSE file in the root of this project.
11 #include <mit-krb5/gssapi/gssapi.h>
13 GSSGetMic::GSSGetMic ( JSONObject* params, gss_get_mic_type fn )
16 loadParameters(params);
20 * {"method": "gss_get_mic",
23 * "context_handle": "#######",
24 * "qop_req": "GSS_C_QOP_DEFAULT",
25 * "input_message": "mary had a little lamb"
30 bool GSSGetMic::loadParameters ( JSONObject* params )
32 std::string sQopReq, sConfReq, sInputMessage;
43 if ( ! params->get("arguments").get("qop_req").isNull() )
45 if (params->get("arguments").get("qop_req").isString())
47 sQopReq = params->get("arguments").get("qop_req").string();
48 if (sQopReq == "GSS_C_QOP_DEFAULT")
49 this->qop_req = GSS_C_QOP_DEFAULT;
51 throw std::invalid_argument( std::string("Invalid QOP type given: ") + sQopReq );
52 } else if (params->get("arguments").get("qop_req").isInteger())
53 this->qop_req = (gss_cred_usage_t)( params->get("arguments").get("qop_req").integer() );
55 throw std::invalid_argument( "Unrecognized argument type for qop_req." );
61 if ( ! params->get("arguments").get("input_message").isNull() )
63 sInputMessage = params->get("arguments").get("input_message").string();
64 this->inputMessage.setValue(sInputMessage);
72 void GSSGetMic::execute()
74 gss_buffer_desc output;
76 this->retVal = this->function(
77 &(this->minor_status),
80 this->inputMessage.toGss(),
84 this->outputToken.setValue( (char *)(output.value), output.length );
87 JSONObject* GSSGetMic::toJSON()
90 const char *conf_state;
91 JSONObject *ret = new JSONObject();
92 JSONObject *values = new JSONObject();
101 values->set("major_status", this->retVal);
102 values->set("minor_status", this->minor_status);
106 this->outputToken.toString().c_str()
109 // Put it all together.
110 ret->set("command", "gss_get_mic");
111 ret->set("return_values", *values);