/* Main processing */
// Easy stuff(*params)
- this->time_req = (*params)["arguments"]["time_req"].integer();
+ this->time_req = (*params)["time_req"].integer();
/**************
* cred_usage *
#include "GSSAcquireCred.h"
#include "command_mocks/MockAcquireCred.h"
#include <datamodel/GSSName.h>
+#include <cache/GSSNameCache.h>
#include <gssapi.h>
#include <stdexcept>
gss_cred_usage_t cred_usage = 2;
GSSOID mech( (char *)"{ 1 2 840 113554 1 2 1 4 }" );
std::stringstream input;
+ char *desired_name = (char *)"HTTP@localhost\0";
+ GSSName desired;
+ OM_uint32 major, minor;
+ gss_name_t des;
+
+
+ major = gss_import_name(&minor, GSSBuffer(desired_name).toGss(), GSS_C_NT_HOSTBASED_SERVICE, &des);
+ if (GSS_ERROR(major))
+ {
+ OM_uint32 min, context;
+ gss_buffer_desc buf;
+
+ std::cout << "Error in importing name." << std::endl;
+ gss_display_status(&min, major, GSS_C_GSS_CODE, GSS_C_NT_HOSTBASED_SERVICE, &context, &buf);
+ std::cout << " message: " << (char *)buf.value << std::endl;
+ }
+ CPPUNIT_ASSERT_MESSAGE(
+ "Could not generate a name to test GSSCreateSecContext JSON parsing.",
+ !GSS_ERROR(major)
+ );
+ desired.setValue(des);
+ std::string key = GSSNameCache::instance()->store(desired);
// The JSON string
input <<
- "{\"method\" : \"gss_acquire_cred\", \
- \"arguments\": \
- {\"desired_name\" : \"#################\", \
- \"time_req\" : " << time_req << ", \
- \"cred_usage\" : " << cred_usage << ", \
- \"desired_mechs\": [\"" << mech.toString() << "\"] \
- } \
+ "{\"desired_name\" : \"" << key << "\", \
+ \"time_req\" : " << time_req << ", \
+ \"cred_usage\" : " << cred_usage << ", \
+ \"desired_mechs\": [\"" << mech.toString() << "\"] \
}";
// The JSON itself
cmd.getCredUsage()
);
- json["arguments"].set( "cred_usage", "GSS_C_INITIATE" );
+ json.set( "cred_usage", "GSS_C_INITIATE" );
cmd.loadParameters(&json);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"GSSAcquireCred's cred_usage was not loaded correctly",
);
// CPPUNIT_ASSERT_THROW(expression, exception);
- json["arguments"].set( "cred_usage", "GSS_C_INITIATOR" );
+ json.set( "cred_usage", "GSS_C_INITIATOR" );
CPPUNIT_ASSERT_THROW_MESSAGE(
"GSSAcquireCred's JSON parsing is admitting invalid strings.",
cmd.loadParameters(&json),
// std::cout << "\n" << result->dump() << "\n";
- CPPUNIT_ASSERT_EQUAL_MESSAGE(
- "The command name is incorrect",
- std::string("gss_acquire_cred"),
- std::string( (*result)["command"].string() )
- );
-
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)MockAcquireCred::retVal,
- (int)( (*result)["return_values"]["major_status"].integer() )
+ (int)( (*result)["major_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)MockAcquireCred::minor_status,
- (int)( (*result)["return_values"]["minor_status"].integer() )
+ (int)( (*result)["minor_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The gss_name was reported incorrectly",
std::string("{ 1 2 3 4 }"),
- std::string( (*result)["return_values"]["actual_mechs"][(size_t)0].string() )
+ std::string( (*result)["actual_mechs"][(size_t)0].string() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The gss_name was reported incorrectly",
std::string("{ 1 5 6 7 8 }"),
- std::string( (*result)["return_values"]["actual_mechs"][(size_t)1].string() )
+ std::string( (*result)["actual_mechs"][(size_t)1].string() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)MockAcquireCred::time_rec,
- (int)( (*result)["return_values"]["time_rec"].integer() )
+ (int)( (*result)["time_rec"].integer() )
);
GSSContext context((gss_ctx_id_t)rand(), true);
std::string key = GSSContextCache::instance()->store(context);
- std::string input = "{\"method\": \"gss_get_mic\", \
- \"arguments\": \
- { \
+ std::string input = "{ \
\"context_handle\": \"" + key + "\", \
\"qop_req\": \"GSS_C_QOP_DEFAULT\", \
\"input_message\": \"mary had a little lamb\" \
- }\
- }";
+ }";
json_error_t jsonErr;
JSONObject json = JSONObject::load(input.c_str(), 0, &jsonErr);
// std::cout << "\nGSSGetMic JSON: \n" << result->dump() << "\n";
CPPUNIT_ASSERT_EQUAL_MESSAGE(
- "The command name is incorrect",
- std::string("gss_get_mic"),
- std::string( (*result)["command"].string() )
- );
-
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)MockGetMic::retVal,
- (int)( (*result)["return_values"]["major_status"].integer() )
+ (int)( (*result)["major_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)MockGetMic::minor_status,
- (int)( (*result)["return_values"]["minor_status"].integer() )
+ (int)( (*result)["minor_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The output message was reported incorrectly",
output,
- std::string( (*result)["return_values"]["output_token"].string() )
+ std::string( (*result)["output_token"].string() )
);
GSSContext context( (gss_ctx_id_t)rand(), true );
std::string key = GSSContextCache::instance()->store(context);
- std::string input = "{\"method\": \"gss_pseudo_random\", \
- \"arguments\": \
- { \
+ std::string input = "{ \
\"context_handle\": \"" + key + "\", \
\"prf_key\": 1234567890, \
\"prf_in\": \"mary had a little lamb\", \
\"desired_output_len\": 256 \
- }\
- }";
+ }";
json_error_t jsonErr;
JSONObject json = JSONObject::load(input.c_str(), 0, &jsonErr);
// std::cout << "\nGSSWrap JSON: \n" << result->dump() << "\n";
CPPUNIT_ASSERT_EQUAL_MESSAGE(
- "The command name is incorrect",
- std::string("gss_pseudo_random"),
- std::string( (*result)["command"].string() )
- );
-
- CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)MockPseudoRandom::retVal,
- (int)( (*result)["return_values"]["major_status"].integer() )
+ (int)( (*result)["major_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)MockPseudoRandom::minor_status,
- (int)( (*result)["return_values"]["minor_status"].integer() )
+ (int)( (*result)["minor_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The random bytes were reported incorrectly",
MockPseudoRandom::outputMessageBuffer.toString(),
- std::string( (*result)["return_values"]["random_bytes"].string() )
+ std::string( (*result)["random_bytes"].string() )
);
/* Variables */
GSSContext context((gss_ctx_id_t)rand(), true);
std::string key = GSSContextCache::instance()->store(context);
- std::string input = "{\"method\": \"gss_wrap\", \
- \"arguments\": \
- { \
+ std::string input = "{ \
\"context_handle\": \"" + key + "\", \
\"input_message\": \"mary had a little lamb\" \
- }\
- }";
+ }";
json_error_t jsonErr;
JSONObject json = JSONObject::load(input.c_str(), 0, &jsonErr);
result = cmd.toJSON();
// std::cout << "\nGSSUnwrap JSON: \n" << result->dump() << "\n";
- CPPUNIT_ASSERT_EQUAL_MESSAGE(
- "The command name is incorrect",
- std::string("gss_wrap"),
- std::string( (*result)["command"].string() )
- );
-
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)MockUnwrap::retVal,
- (int)( (*result)["return_values"]["major_status"].integer() )
+ (int)( (*result)["major_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)MockUnwrap::minor_status,
- (int)( (*result)["return_values"]["minor_status"].integer() )
+ (int)( (*result)["minor_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The output message was reported incorrectly",
MockUnwrap::outputMessageBuffer.toString(),
- std::string( (*result)["return_values"]["output_message"].string() )
+ std::string( (*result)["output_message"].string() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)qopState,
- (int)( (*result)["return_values"]["qop_state"].integer() )
+ (int)( (*result)["qop_state"].integer() )
);
GSSContext context( (gss_ctx_id_t)rand(), true );
std::string key = GSSContextCache::instance()->store(context);
- std::string input = "{\"method\": \"gss_wrap\", \
- \"arguments\": \
- { \
+ std::string input = "{ \
\"context_handle\": \"" + key + "\", \
\"conf_req\": \"TRUE\", \
\"qop_req\": \"GSS_C_QOP_DEFAULT\", \
\"input_message\": \"mary had a little lamb\" \
- }\
- }";
+ }";
json_error_t jsonErr;
JSONObject json = JSONObject::load(input.c_str(), 0, &jsonErr);
result = cmd.toJSON();
// std::cout << "\nGSSWrap JSON: \n" << result->dump() << "\n";
- CPPUNIT_ASSERT_EQUAL_MESSAGE(
- "The command name is incorrect",
- std::string("gss_wrap"),
- std::string( (*result)["command"].string() )
- );
-
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The return value was reported incorrectly",
(int)MockWrap::retVal,
- (int)( (*result)["return_values"]["major_status"].integer() )
+ (int)( (*result)["major_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The minor_status value was reported incorrectly",
(int)MockWrap::minor_status,
- (int)( (*result)["return_values"]["minor_status"].integer() )
+ (int)( (*result)["minor_status"].integer() )
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"The output message was reported incorrectly",
MockWrap::outputMessageBuffer.toString(),
- std::string( (*result)["return_values"]["output_message"].string() )
+ std::string( (*result)["output_message"].string() )
);