2 * Copyright (c) 2014 <copyright holder> <email>
4 * For license details, see the LICENSE file in the root of this project.
8 #include "GSSImportName.h"
9 #include "GSSException.h"
10 #include <cache/GSSNameCache.h>
13 typedef OM_uint32 (*gss_imp_name_type)(
14 OM_uint32 *, /* minor_status */
15 gss_buffer_t, /* input_name_buffer */
16 gss_OID, /* input_name_type(used to be const) */
17 gss_name_t *); /* output_name */
21 void GSSImportName::execute()
31 retVal = function(&minor_status, inputName.toGss(), inputNameType.toGss(), &name);
32 if ( GSS_ERROR(this->retVal) )
35 errMsg += "Cannot import name: ";
36 errMsg += inputName.toString();
37 throw GSSException(errMsg.c_str(), this->retVal, this->minor_status, inputNameType.toGss());
39 this->outputName.setValue(name);
40 key = GSSNameCache::instance()->store(this->outputName);
41 // std::cout << "Storing key: " << key << std::endl;
42 this->outputName.setKey(key);
51 * "command": "gss_import_name",
56 * "gss_name": "base64_encoded_string"
61 JSONObject *GSSImportName::toJSON()
64 JSONObject *ret = new JSONObject();
65 JSONObject *values = new JSONObject();
72 values->set("major_status", this->retVal);
73 values->set("minor_status", this->minor_status);
74 values->set("gss_name", this->outputName.getKey().c_str() );
75 ret->set("command", "gss_import_name");
76 ret->set("return_values", *values);
84 GSSImportName::GSSImportName ( gss_imp_name_type fn )
89 inputNameType.setValue(GSSBuffer("{ 1 2 840 113554 1 2 1 4 }"));
92 GSSImportName::GSSImportName(JSONObject *params, gss_imp_name_type fn) : GSSCommand(params)
98 loadParameters(params);
105 bool GSSImportName::loadParameters(JSONObject *params)
113 /* Main processing */
114 // Easy stuff(*params)
115 if ( params->get("arguments").isNull() )
118 if ( !params->get("arguments").get("input_name").isNull() )
120 if ( params->get("arguments").get("input_name").isString() )
122 std::string input_name = params->get("arguments").get("input_name").string();
123 this->inputName.setValue( input_name );
127 if ( !params->get("arguments").get("input_name_type").isNull() )
129 if ( params->get("arguments").get("input_name_type").isString() )
131 std::string input_name_type = params->get("arguments").get("input_name_type").string();
132 this->inputNameType.setValue( input_name_type );
145 // if ( ! params->get("arguments").get("qop_req").isNull() )
147 // if (params->get("arguments").get("qop_req").isString())
149 // sQopReq = params->get("arguments").get("qop_req").string();
150 // if (sQopReq == "GSS_C_QOP_DEFAULT")
151 // this->qop_req = GSS_C_QOP_DEFAULT;
153 // throw std::invalid_argument( std::string("Invalid QOP type given: ") + sQopReq );
154 // } else if (params->get("arguments").get("qop_req").isInteger())
155 // this->qop_req = (gss_cred_usage_t)( params->get("arguments").get("qop_req").integer() );
157 // throw std::invalid_argument( "Unrecognized argument type for qop_req." );
160 // /*****************
162 // *****************/
163 // if ( ! params->get("arguments").get("input_message").isNull() )
165 // sInputMessage = params->get("arguments").get("input_message").string();
166 // this->inputMessage.setValue(sInputMessage);