2 * Copyright (c) 2014 <copyright holder> <email>
4 * For license details, see the LICENSE file in the root of this project.
12 * gss_wrap_type function;
16 GSSBuffer inputMessage;
17 GSSBuffer outputMessage;
21 OM_uint32 minor_status;
25 bool GSSWrap::loadParameters(JSONObject *params)
28 std::string sQopReq, sConfReq, sInputMessage;
39 if ( ! params->get("arguments").get("conf_req").isNull() )
41 if (params->get("arguments").get("conf_req").isString())
43 sConfReq = params->get("arguments").get("conf_req").string();
44 if (sConfReq == "TRUE")
46 else if (sConfReq == "FALSE")
49 throw std::invalid_argument( std::string("Invalid QOP type given: ") + sConfReq );
50 } else if (params->get("arguments").get("conf_req").isInteger())
51 this->conf_req = (gss_cred_usage_t)( params->get("arguments").get("conf_req").integer() );
53 throw std::invalid_argument( "Unrecognized argument type for conf_req." );
59 if ( ! params->get("arguments").get("qop_req").isNull() )
61 if (params->get("arguments").get("qop_req").isString())
63 sQopReq = params->get("arguments").get("qop_req").string();
64 if (sQopReq == "GSS_C_QOP_DEFAULT")
65 this->qop_req = GSS_C_QOP_DEFAULT;
67 throw std::invalid_argument( std::string("Invalid QOP type given: ") + sQopReq );
68 } else if (params->get("arguments").get("qop_req").isInteger())
69 this->qop_req = (gss_cred_usage_t)( params->get("arguments").get("qop_req").integer() );
71 throw std::invalid_argument( "Unrecognized argument type for qop_req." );
77 if ( ! params->get("arguments").get("input_message").isNull() )
79 sInputMessage = params->get("arguments").get("input_message").string();
80 this->inputMessage.setValue(sInputMessage);
88 GSSWrap::GSSWrap ( JSONObject* params, gss_wrap_type fn )
91 loadParameters(params);
100 void GSSWrap::execute()
103 gss_buffer_desc output_buf;
106 &(this->minor_status),
110 this->inputMessage.toGss(),
115 this->outputMessage.setValue( (char *)output_buf.value, output_buf.length );
118 /* Desired JSON output:
121 * "command": "gss_wrap",
126 * "conf_state": "TRUE",
127 * "output_message": "asdf"
131 JSONObject *GSSWrap::toJSON()
134 const char *conf_state;
135 JSONObject *ret = new JSONObject();
136 JSONObject *values = new JSONObject();
145 values->set("major_status", this->retVal);
146 values->set("minor_status", this->minor_status);
148 conf_state = (this->conf_state) ? "TRUE" : "FALSE";
149 values->set("conf_state", conf_state);
153 this->outputMessage.toString().c_str()
156 // Put it all together.
157 ret->set("command", "gss_wrap");
158 ret->set("return_values", *values);