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>
13 * gss_wrap_type function;
17 GSSBuffer inputMessage;
18 GSSBuffer outputMessage;
22 OM_uint32 minor_status;
26 bool GSSWrap::loadParameters(JSONObject *params)
29 std::string sQopReq, sConfReq, sInputMessage;
40 if ( ! params->get("conf_req").isNull() )
42 if (params->get("conf_req").isString())
44 sConfReq = params->get("conf_req").string();
45 if (sConfReq == "TRUE")
47 else if (sConfReq == "FALSE")
50 throw std::invalid_argument( std::string("Invalid QOP type given: ") + sConfReq );
51 } else if (params->get("conf_req").isInteger())
52 this->conf_req = (gss_cred_usage_t)( params->get("conf_req").integer() );
54 throw std::invalid_argument( "Unrecognized argument type for conf_req." );
60 if ( ! params->get("qop_req").isNull() )
62 if (params->get("qop_req").isString())
64 sQopReq = params->get("qop_req").string();
65 if (sQopReq == "GSS_C_QOP_DEFAULT")
66 this->qop_req = GSS_C_QOP_DEFAULT;
68 throw std::invalid_argument( std::string("Invalid QOP type given: ") + sQopReq );
69 } else if (params->get("qop_req").isInteger())
70 this->qop_req = (gss_cred_usage_t)( params->get("qop_req").integer() );
72 throw std::invalid_argument( "Unrecognized argument type for qop_req." );
78 if ( ! params->get("input_message").isNull() )
80 sInputMessage = params->get("input_message").string();
81 this->inputMessage.setValue(sInputMessage);
87 if ( ! params->get("context_handle").isNull() )
89 std::string contextKey = params->get("context_handle").string();
90 GSSContext ctx = GSSContextCache::instance()->retrieve(contextKey);
91 this->context = ctx.getContext();
99 GSSWrap::GSSWrap ( JSONObject* params, gss_wrap_type fn )
102 loadParameters(params);
111 void GSSWrap::execute()
114 gss_buffer_desc output_buf;
117 &(this->minor_status),
121 this->inputMessage.toGss(),
126 this->outputMessage.setValue( (char *)output_buf.value, output_buf.length );
129 /* Desired JSON output:
134 * "conf_state": "TRUE",
135 * "output_message": "asdf"
139 JSONObject *GSSWrap::toJSON()
142 const char *conf_state;
143 JSONObject *values = new JSONObject();
152 values->set("major_status", this->retVal);
153 values->set("minor_status", this->minor_status);
155 conf_state = (this->conf_state) ? "TRUE" : "FALSE";
156 values->set("conf_state", conf_state);
160 this->outputMessage.toString().c_str()