-console.log('Loading navigator.gss.js - #8');
+/*
+ * Copyright (c) 2014, JANET(UK)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+console.log('Loading navigator.gss.js - #9');
/* This file gets injected into the web page verbatim */
-
-
var GSSEap = (function ()
{
function GSSEap(config)
{
// Public attributes
this.version = "0.0.1";
- this.implemented_methods = ["gss_import_name"];
+ this.implemented_methods = ["gss_import_name", "gss_init_sec_context", "gss_acquire_cred"];
+ // MRW -- combine success/error callback hashes?
this.callbacks = {};
- this.methods = {};
this.errors = {};
this.appTag = config.appTag || "";
this.default_error = config.error ||
nonce = event.data.cookies.navigator_gss_tag;
event.data.cookies.navigator_gss_tag = undefined;
callback = this.callbacks[nonce];
- if ("undefined" == typeof (callback) ||
- this.methods[nonce] != method) {
+ if ("undefined" == typeof (callback)) {
return;
}
}
};
+
+ GSSEap.prototype.init_sec_context = function (params)
+ {
+ /* variables */
+ // internal variables
+ var nonce;
+
+ // Required parameters
+ var target_name = params.target_name;
+ var callback = params.success || this.success;
+
+ // Optional & defaulted parameters (some are defaulted at lower layer)
+ var context_handle = params.context_handle;
+ var cred_handle = params.cred_handle;
+ var mech_type = params.mech_type;
+ var req_flags = params.req_flags;
+ var time_req = params.time_req;
+ var input_token = params.input_token;
+
+ var error = params.error || this.default_error;
+ var app_tag = params.app_tag || this.appTag;
+
+ /* Error checking */
+ // Call an error if we don't have the required parameters.
+ // - name
+ // - success()
+ if ( "undefined" == typeof(target_name) ||
+ "undefined" == typeof(callback) )
+ {
+ error(-1, -1,
+ "init_sec_context called missing either target_name or success callback"
+ );
+ return;
+ }
+
+ /* Setup */
+ nonce = navigator.generateNonce();
+
+ /* Main processing */
+ // Save our callback, method name, and error function
+ this.callbacks[nonce] = callback;
+ this.errors[nonce] = error;
+
+ // Now pass the request on to the C code
+ window.postMessage({
+ "method":"gss_init_sec_context",
+ "arguments":
+ {
+ "target_name": target_name,
+ "context_handle": context_handle,
+ "cred_handle": cred_handle,
+ "mech_type": mech_type,
+ "req_flags": req_flags,
+ "time_req": time_req,
+ "input_token": input_token
+
+ },
+ "cookies":
+ {
+ "navigator_gss_tag": nonce,
+ "app_tag": app_tag
+ }
+ }, "*");
+
+ };
+
GSSEap.prototype.import_name = function (params)
{
/* variables */
/* Main processing */
// Save our callback, method name, and error function
this.callbacks[nonce] = callback;
- this.methods[nonce] = "gss_import_name";
this.errors[nonce] = error;
// Now pass the request on to the C code
function doInitSecContext() {
gss = gss || new navigator.gss_eap({
appTag: "TestApp",
- success: function(data, appTag) {
- $('#init_sec_context_context_handle').attr("value",
- data.context_handle);
- report("Output token: " + data.output_token,
- '#init_sec_context_response');
- }
});
gss.error = function(major, minor, errMsg, appTag)
{
};
var params = {
- target_name: document.getElementById('init_sec_context_target_name').value
+ target_name: document.getElementById('init_sec_context_target_name').value,
+ success: function(data, appTag) {
+ $('#init_sec_context_context_handle').attr("value",
+ data.context_handle);
+ report("Output token: " + data.output_token,
+ '#init_sec_context_response');
+ }
};
gss.init_sec_context(params);
}
#include <stdlib.h>
#include <string.h>
+#include "utils/base64.h"
+
typedef OM_uint32 (*init_sec_context)(
OM_uint32 *, /* minor_status */
gss_cred_id_t, /* claimant_cred_handle */
/* Return */
}
-#if 0
const char* GSSInitSecContext::getTargetDisplayName()
{
/* Variables */
/* return */
return( ret );
}
-#endif
bool GSSInitSecContext::loadParameters(JSONObject *params)
{
/* Variables */
std::string key;
+ std::string token;
+ size_t len;
/* Error checking */
if ( params->isNull() )
// input_token
if ( ! params->get("input_token").isNull() )
{
- key = params->get("input_token").string();
- this->input_token.value = (void *)key.c_str();
- this->input_token.length = key.length();
+ token = params->get("input_token").string();
+ token = (char *)base64_decode(token, &len);
+ this->input_token.value = (void *)token.c_str();
+ this->input_token.length = token.length();
}
/* Cleanup */
{
/* Variables */
// MRW -- values should be scoped to the class, so execute can set error values?
+ std::string output_str;
JSONObject *values = new JSONObject();
/* Error checking */
values->set("minor_status", this->minor_status);
values->set("context_handle", this->contextKey.c_str());
values->set("actual_mech_type", this->getActualMechType().toString().c_str());
- values->set("output_token", (const char *)this->output_token.value);
+ // MRW -- is output_token.value guaranteed to be null-terminated?
+ output_str = (char *)output_token.value;
+ values->set("output_token", base64_encode(output_str));
values->set("ret_flags", this->ret_flags);
values->set("time_rec", this->time_rec);
// MRW -- modify for new error handling