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>
12 #include <mit-krb5/gssapi/gssapi.h>
14 GSSGetMic::GSSGetMic ( JSONObject* params, gss_get_mic_type fn )
17 loadParameters(params);
22 * "context_handle": "#######",
23 * "qop_req": "GSS_C_QOP_DEFAULT",
24 * "input_message": "mary had a little lamb"
28 bool GSSGetMic::loadParameters ( JSONObject* params )
30 std::string sQopReq, sConfReq, sInputMessage;
41 if ( ! params->get("qop_req").isNull() )
43 if (params->get("qop_req").isString())
45 sQopReq = params->get("qop_req").string();
46 if (sQopReq == "GSS_C_QOP_DEFAULT")
47 this->qop_req = GSS_C_QOP_DEFAULT;
49 throw std::invalid_argument( std::string("Invalid QOP type given: ") + sQopReq );
50 } else if (params->get("qop_req").isInteger())
51 this->qop_req = (gss_cred_usage_t)( params->get("qop_req").integer() );
53 throw std::invalid_argument( "Unrecognized argument type for qop_req." );
59 if ( ! params->get("input_message").isNull() )
61 sInputMessage = params->get("input_message").string();
62 this->inputMessage.setValue(sInputMessage);
68 if ( ! params->get("context_handle").isNull() )
70 sInputMessage = params->get("context_handle").string();
71 GSSContext ctx = GSSContextCache::instance()->retrieve(sInputMessage);
72 this->context = ctx.getContext();
80 void GSSGetMic::execute()
82 gss_buffer_desc output;
84 this->retVal = this->function(
85 &(this->minor_status),
88 this->inputMessage.toGss(),
92 this->outputToken.setValue( (char *)(output.value), output.length );
95 JSONObject* GSSGetMic::toJSON()
98 JSONObject *values = new JSONObject();
107 values->set("major_status", this->retVal);
108 values->set("minor_status", this->minor_status);
112 this->outputToken.toString().c_str()