{
// Public attributes
this.version = "0.0.1";
- this.implemented_methods = ["gss_import_name", "gss_init_sec_context", "gss_acquire_cred"];
+ this.implemented_methods = ["gss_import_name", "gss_display_name", "gss_init_sec_context", "gss_acquire_cred"];
// MRW -- combine success/error callback hashes?
this.callbacks = {};
this.errors = {};
};
+ GSSEap.prototype.display_name = function(params)
+ {
+ /* Variables */
+ // required parameters
+ var input_name = params.input_name;
+ var callback = params.success;
+
+ if ( "undefined" == typeof(name) ||
+ "undefined" == typeof(callback) )
+ {
+ error(-1, -1,
+ "import_name called missing either name or success callback"
+ );
+ return;
+ }
+
+ var error = params.error || this.default_error;
+ var app_tag = params.app_tag || this.appTag;
+
+ /* 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_display_name",
+ "arguments":
+ {
+ "input_name": input_name,
+ },
+ "cookies":
+ {
+ "navigator_gss_tag": nonce,
+ "app_tag": app_tag
+ }
+ }, "*");
+
+ }
+
GSSEap.prototype.import_name = function (params)
{
/* variables */
</div>
</div>
+ <div class="row">
+ <div class="col-xs-4">
+ <!-- middle column -->
+ <h2>GSS Display Name</h2>
+ <div class="form-group">
+ <label for="display_name_name">Name:</label>
+ <select name="display_name_name" id="display_name_name" class="gss_name">
+ </select>
+ </div>
+
+ <button id="display_name">gss_display_name</button>
+ <div id="display_name_response" style="overflow: auto;"></div>
+
+ </div>
+ </div>
+
<div class="row">
<div class="col-xs-12">
<div class="form-group">
});
} // doImportName
+ function doDisplayName() {
+ gss = gss || new navigator.gss_eap({
+ appTag: "TestApp"
+ });
+ gss.error = function(major, minor, errMsg, appTag)
+ {
+ report("Error", '#display_response');
+ report("Major: " + major + "; Minor: " + minor, '#display_response');
+ report("<blockquote>" + errMsg + "</blockquote>", '#display_response');
+ report("appTag: " + appTag, '#display_response');
+ };
+ gss.display_name({
+ input_name: document.getElementById('display_name_name').value,
+ success: function(data, appTag) {
+ report("GSS displayed name: " + data.gss_name, '#display_response');
+ report("appTag: " + appTag, '#display_response');
+ newOption = $('<option></option>');
+ newOption.attr('value', data.gss_name);
+ newOption.append(document.getElementById('display_name_name').value);
+ $('.gss_name').append(newOption);
+ },
+ error: function(major, minor, errMsg, appTag)
+ {
+ report("Error", '#display_response');
+ report("Major: " + major + "; Minor: " + minor, '#display_response');
+ report("<blockquote>" + errMsg + "</blockquote>", '#display_response');
+ report("appTag: " + appTag, '#display_response');
+ }
+ });
+ } // doDisplayName
+
+
function doAcquireCred() {
gss = gss || new navigator.gss_eap({
appTag: "TestApp"
'click', doImportName
);
+ <!-- Listen for the import name button click -->
+ document.getElementById('display_name').addEventListener(
+ 'click', doDisplayName
+ );
+
<!-- Listen for the acquire cred button click -->
document.getElementById('acquire_cred').addEventListener(
'click', doAcquireCred
src/commands/GSSCommand.cpp
src/commands/GSSImportName.cpp
src/commands/GSSAcquireCred.cpp
+ src/commands/GSSDisplayName.cpp
src/commands/GSSPseudoRandom.cpp
src/commands/GSSWrap.cpp
src/commands/GSSUnwrap.cpp
#include "commands/GSSAcquireCred.h"
#include "commands/GSSInitSecContext.h"
#include "commands/GSSImportName.h"
+#include "commands/GSSDisplayName.h"
#include "GSSRequest.h"
using std::bad_alloc;
{
cmd = new GSSAcquireCred ( &arguments );
}
+ else if ( "gss_display_name" == method )
+ {
+ cmd = new GSSDisplayName ( &arguments );
+ }
else
{
string error_message = string("Unrecognized command: ") + method;
--- /dev/null
+/*
+ * 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.
+ *
+ */
+
+#include "GSSDisplayName.h"
+#include "cache/GSSNameCache.h"
+
+
+using std::string;
+
+GSSDisplayName::GSSDisplayName()
+{
+
+}
+
+GSSDisplayName::~GSSDisplayName()
+{
+
+}
+
+JSONObject* GSSDisplayName::toJSON()
+{
+ JSONObject *values = new JSONObject;
+ values->set("major_status", (json_int_t)0);
+ values->set("minor_status", (json_int_t)0);
+ values->set("output_name", inputName.toString().c_str());
+
+ return(values);
+}
+
+void GSSDisplayName::execute()
+{
+ // Execution is a side effect of the toJSON calls
+}
+
+bool GSSDisplayName::loadParameters ( const JSONObject* params )
+{
+ /* Variables */
+ string key;
+
+ /* Error checking */
+ if ( params->isNull() )
+ return true;
+
+ /* Setup */
+
+ /* Main processing */
+ // MRW -- finish parsing all of the variables
+ // claimant_cred_handle
+
+ // input_name
+ if (!(params->get("input_name").isNull() ||
+ (params->get("input_name").isString() &&
+ string("") == params->get("input_name").string())))
+ {
+ if (params->get("input_name").isString())
+ {
+ key = params->get("input_name").string();
+ this->inputName = GSSNameCache::instance()->retrieve( key.c_str() );
+ }
+ }
+ return(true);
+}
+
+
+GSSDisplayName::GSSDisplayName ( JSONObject *params )
+{
+ loadParameters(params);
+}
--- /dev/null
+/*
+ * 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.
+ *
+ */
+
+#ifndef GSSDISPLAYNAME_H
+#define GSSDISPLAYNAME_H
+
+#include <commands/GSSCommand.h>
+#include <datamodel/GSSName.h>
+
+class GSSDisplayName : public GSSCommand
+{
+public:
+ GSSDisplayName();
+ GSSDisplayName ( JSONObject *params );
+ ~GSSDisplayName();
+ virtual JSONObject* toJSON();
+ virtual void execute();
+
+private:
+ GSSName inputName;
+ bool loadParameters( const JSONObject *params );
+};
+
+#endif // GSSDISPLAYNAME_H
{
/* Variables */
// MRW -- values should be scoped to the class, so execute can set error values?
- std::string output_str;
+ std::string output_str((char *)output_token.value, output_token.length);
JSONObject *values = new JSONObject();
/* Error checking */
values->set("context_handle", this->contextKey.c_str());
values->set("actual_mech_type", this->getActualMechType().toString().c_str());
// MRW -- is output_token.value guaranteed to be null-terminated?
- output_str = (char *)output_token.value;
+ //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);