json_gssapi/build
json_gssapi/debug
json_gssapi/manual
-test/
\ No newline at end of file
+./test/
\ No newline at end of file
void GSSImportName::execute()
{
this->outputName = GSSName(inputName, inputNameType, function);
+ this->retVal = this->outputName.getMajorStatus();
+ this->minor_status = this->outputName.getMinorStatus();
+ this->outputName.setKey("constant for now");
}
JSONObject *GSSImportName::toJSON()
{
- return new JSONObject();
+ /* Variables */
+ JSONObject *ret = new JSONObject();
+ JSONObject *values = new JSONObject();
+
+ /* Error checking */
+
+ /* Setup */
+
+ /* Main */
+ values->set("major_status", this->retVal);
+ values->set("minor_status", this->minor_status);
+ values->set("gss_name", this->outputName.getKey().c_str() );
+ ret->set("command", "gss_import_name");
+ ret->set("return_values", *values);
+
+ /* Cleanup */
+
+ /* Return */
+ return(ret);
}
GSSImportName::GSSImportName(JSONObject *params, gss_imp_name_type fn) : GSSCommand(params)
void GSSName::init(const GSSBuffer namestr, GSSOID name_type, gss_imp_name_type fn)
{
/* Variables */
- OM_uint32 major, minor;
/* Error checking */
/* Setup */
/* Main */
- major = fn(&minor, namestr.toGss(), name_type.toGss(), &name);
- if ( GSS_ERROR(major) )
+ this->major_status = fn(&(this->minor_status), namestr.toGss(), name_type.toGss(), &name);
+ if ( GSS_ERROR(this->major_status) )
{
std::string errMsg;
errMsg += "Cannot import name: ";
errMsg += namestr.toString();
- throw GSSException(errMsg.c_str(), major, minor, name_type.toGss());
+ throw GSSException(errMsg.c_str(), this->major_status, this->minor_status, name_type.toGss());
}
/* Cleanup */
std::string toString();
bool setValue(gss_name_t newName);
+ bool setKey(std::string key) { this->hashKey = key; }
+ std::string getKey() const { return this->hashKey; }
+
+ OM_uint32 getMajorStatus() const { return this->major_status; }
+ OM_uint32 getMinorStatus() const { return this->minor_status; }
private:
+ OM_uint32 major_status, minor_status;
gss_name_t name;
gss_imp_name_type function;
+ std::string hashKey;
void init(const GSSBuffer namestr, GSSOID name_type, gss_imp_name_type fn);
void release();
void GSSImportNameTest::testJSONMarshal()
{
/* Variables */
- GSSImportName cmd = GSSImportName();
+ std::string name("dns@google.com");
+ std::string type("{ 1 2 840 113554 1 2 1 4 }");
+ JSONObject *result;
+ GSSImportName cmd = GSSImportName(&mock_import_name);
/* Error checking */
/* Setup */
+ cmd.setInputName(name);
+ cmd.setInputNameType(type);
+ MockImportName::minor_status = 0;
+ MockImportName::retVal = 0;
+ MockImportName::output_name.setValue(GSS_C_NO_NAME);
+
/* Main */
+ cmd.execute();
+ result = cmd.toJSON();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "The command name is incorrect",
+ std::string("gss_import_name"),
+ std::string( (*result)["command"].string() )
+ );
+
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "The return value was reported incorrectly",
+ (int)MockImportName::retVal,
+ (int)( (*result)["return_values"]["major_status"].integer() )
+ );
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "The minor_status value was reported incorrectly",
+ (int)MockImportName::minor_status,
+ (int)( (*result)["return_values"]["minor_status"].integer() )
+ );
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "The gss_name was reported incorrectly",
+ std::string("constant for now"),
+ std::string( (*result)["return_values"]["gss_name"].string() )
+ );
+
/* Cleanup */
/* Return */