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);
53 * "gss_name": "base64_encoded_string"
57 JSONObject *GSSImportName::toJSON()
60 JSONObject *values = new JSONObject();
67 values->set("major_status", this->retVal);
68 values->set("minor_status", this->minor_status);
69 values->set("gss_name", this->outputName.getKey().c_str() );
77 GSSImportName::GSSImportName ( gss_imp_name_type fn )
82 inputNameType.setValue(GSSBuffer("{ 1 2 840 113554 1 2 1 4 }"));
85 GSSImportName::GSSImportName(JSONObject *params, gss_imp_name_type fn) : GSSCommand(params)
91 loadParameters(params);
98 bool GSSImportName::loadParameters(JSONObject *params)
106 /* Main processing */
107 // Easy stuff(*params)
108 if ( params->isNull() )
111 if ( !params->get("input_name").isNull() )
113 if ( params->get("input_name").isString() )
115 std::string input_name = params->get("input_name").string();
116 this->inputName.setValue( input_name );
120 if ( !params->get("input_name_type").isNull() )
122 if ( params->get("input_name_type").isString() )
124 std::string input_name_type = params->get("input_name_type").string();
125 this->inputNameType.setValue( input_name_type );