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>
11 #include <datamodel/GSSDisplayStatus.h>
14 typedef OM_uint32 (*gss_imp_name_type)(
15 OM_uint32 *, /* minor_status */
16 gss_buffer_t, /* input_name_buffer */
17 gss_OID, /* input_name_type(used to be const) */
18 gss_name_t *); /* output_name */
22 void GSSImportName::execute()
32 retVal = function(&minor_status, inputName.toGss(), inputNameType.toGss(), &name);
33 // if ( GSS_ERROR(this->retVal) )
36 GSSDisplayStatus ds(retVal, minor_status, inputNameType.toGss());
37 errors.set("major_status_message", ds.getMajorMessage().c_str());
38 errors.set("minor_status_message", ds.getMinorMessage().c_str());
39 values->set("errors", errors);
44 this->outputName.setValue(name);
45 key = GSSNameCache::instance()->store(this->outputName);
46 // std::cout << "Storing key: " << key << std::endl;
47 this->outputName.setKey(key);
58 * "gss_name": "base64_encoded_string"
62 JSONObject *GSSImportName::toJSON()
70 values->set("major_status", this->retVal);
71 values->set("minor_status", this->minor_status);
72 values->set("gss_name", this->outputName.getKey().c_str() );
80 GSSImportName::GSSImportName ( gss_imp_name_type fn )
84 inputName = string("");
85 inputNameType.setValue(GSSBuffer( string("{ 1 2 840 113554 1 2 1 4 }") ));
86 values = new JSONObject();
89 GSSImportName::GSSImportName(JSONObject *params, gss_imp_name_type fn) : GSSCommand(params)
95 values = new JSONObject();
96 loadParameters(params);
103 bool GSSImportName::loadParameters(JSONObject *params)
111 /* Main processing */
112 // Easy stuff(*params)
113 if ( params->isNull() )
116 if ( !params->get("input_name").isNull() )
118 if ( params->get("input_name").isString() )
120 std::string input_name = params->get("input_name").string();
121 this->inputName.setValue( input_name );
125 if ( !params->get("input_name_type").isNull() )
127 if ( params->get("input_name_type").isString() )
129 std::string input_name_type = params->get("input_name_type").string();
130 this->inputNameType.setValue( input_name_type );