3 Copyright (c) 2014, 2015 JANET(UK)
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 3. Neither the name of JANET(UK) nor the names of its contributors
18 may be used to endorse or promote products derived from this software
19 without specific prior written permission.
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
32 OF THE POSSIBILITY OF SUCH DAMAGE.
36 <title>GSSApi Tester Application</title>
38 <!-- Latest compiled and minified CSS -->
39 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
41 <!-- Optional theme -->
42 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
46 <div class="container-fluid">
48 <div class="col-xs-4">
50 <h2>GSS Import Name</h2>
51 <div class="form-group">
52 <label for="import_name_name">Name:</label>
53 <input name="import_name_name"
55 value="HTTP@localhost.localdomain" />
57 <div class="form-group">
58 <label for="import_name_mech">Mechanism:</label>
59 <input name="import_name_mech"
61 value="{1 2 840 113554 1 2 1 4 }" />
63 <button id="import_name">gss_import_name</button>
64 <div id='import_response' style="overflow: auto;"></div>
68 <div class="col-xs-4">
69 <!-- middle column -->
70 <h2>GSS Acquire Cred</h2>
71 <div class="form-group">
72 <label for="acquire_cred_desired_name">Desired name:</label>
73 <select name="acquire_cred_desired_name" class="gss_name">
77 <div class="form-group">
78 <label for="acquire_cred_cred_usage">Cred Usage:</label>
79 <select name="acquire_cred_cred_usage">
80 <option value="GSS_C_INITIATE">GSS_C_INITIATE</option>
81 <option value="GSS_C_ACCEPT">GSS_C_ACCEPT</option>
82 <option value="GSS_C_BOTH">GSS_C_BOTH</option>
86 <div class="form-group">
87 <label for="acquire_cred_time_req">
88 Requested lifetime in seconds (0 for default 2 hours):
90 <input name="acquire_cred_time_req"
91 id="acquire_cred_time_req"
95 <div class="form-group">
96 <label for="acquire_cred_desired_mechs">
97 Desired mechanisms (comma separated, blank for default):
99 <input name="acquire_cred_desired_mechs"
100 id="acquire_cred_desired_mechs"
104 <button id="acquire_cred">gss_acquire_cred</button>
105 <div id="acquire_response" style="overflow: auto;"></div>
110 <div class="col-xs-4">
111 <!-- right column -->
112 <h2>GSS Init Sec Context</h2>
113 <div class="form-group">
114 <label for="init_sec_context_target_name">Target name:</label>
115 <select name="init_sec_context_target_name"
116 id="init_sec_context_target_name"
121 <div class="form-group">
122 <label for="init_sec_context_context_handle">Context handle:</label>
123 <input name="init_sec_context_context_handle"
124 id="init_sec_context_context_handle"/>
127 <div class="form-group">
128 <label for="init_sec_context_input_token">Input token:</label>
129 <input name="init_sec_context_input_token"
130 id="init_sec_context_input_token"/>
133 <div class="form-group">
134 <label for="init_sec_context_mech_type">
135 Mechanism type (blank for default):
137 <input name="init_sec_context_mech_type"
138 id="init_sec_context_mech_type"/>
141 <div class="form-group">
142 <label for="init_sec_context_time_req">
143 Requested lifetime in seconds (0 for default 2 hours):
145 <input name="init_sec_context_time_req"
146 id="init_sec_context_time_req" value="0" />
149 <div class="form-group">
150 <label for="init_sec_context_req_flags">
151 Request flags (0 unless you know what you're doing):
153 <input name="init_sec_context_req_flags"
154 id="init_sec_context_req_flags" value="0" />
157 <button id="init_sec_context">gss_init_sec_context</button>
158 <div id="init_sec_context_response" style="overflow: auto;"></div>
164 <div class="col-xs-4">
165 <!-- middle column -->
166 <h2>GSS Display Name</h2>
167 <div class="form-group">
168 <label for="display_name_name">Name:</label>
169 <select name="display_name_name" id="display_name_name" class="gss_name">
173 <button id="display_name">gss_display_name</button>
174 <div id="display_name_response" style="overflow: auto;"></div>
180 <div class="col-xs-12">
181 <div class="form-group">
182 <label for="authenticate_server_path">Server Path:</label>
183 <input name="authenticate_server_path"
184 id="authenticate_server_path"
188 <button id="authenticate">authenticate</button>
189 <div id='authenticate_response' style="overflow: auto;"></div>
195 <!-- Scripts! ------------------------------------------------------------------------------>
196 <!-- Required JQuery -->
197 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
199 <!-- Latest compiled and minified JavaScript -->
200 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
202 <!-- GSS Web script -->
203 <script src="navigator.gssweb.js"></script>
205 <script language="javascript">
209 function report(msg, elemId) {
210 var element = $(elemId);
211 element.prepend('<p>' + msg + '</p>');
214 function doImportName() {
215 gss = gss || new navigator.gss({
218 gss.error = function(major, minor, errMsg, appTag)
220 report("Error", '#import_response');
221 report("Major: " + major + "; Minor: " + minor, '#import_response');
222 report("<blockquote>" + errMsg + "</blockquote>", '#import_response');
223 report("appTag: " + appTag, '#import_response');
226 name: document.getElementById('import_name_name').value,
227 name_type: document.getElementById('import_name_mech').value,
228 success: function(data, appTag) {
229 report("GSS imported name: " + data.gss_name, '#import_response');
230 report("appTag: " + appTag, '#import_response');
231 newOption = $('<option></option>');
232 newOption.attr('value', data.gss_name);
233 newOption.append(document.getElementById('import_name_name').value);
234 $('.gss_name').append(newOption);
239 function doDisplayName() {
240 gss = gss || new navigator.gss({
243 gss.error = function(major, minor, errMsg, appTag)
245 report("Error", '#display_response');
246 report("Major: " + major + "; Minor: " + minor, '#display_response');
247 report("<blockquote>" + errMsg + "</blockquote>", '#display_response');
248 report("appTag: " + appTag, '#display_response');
251 input_name: document.getElementById('display_name_name').value,
252 success: function(data, appTag) {
253 report("GSS displayed name: " + data.gss_name, '#display_response');
254 report("appTag: " + appTag, '#display_response');
255 newOption = $('<option></option>');
256 newOption.attr('value', data.gss_name);
257 newOption.append(document.getElementById('display_name_name').value);
258 $('.gss_name').append(newOption);
260 error: function(major, minor, errMsg, appTag)
262 report("Error", '#display_response');
263 report("Major: " + major + "; Minor: " + minor, '#display_response');
264 report("<blockquote>" + errMsg + "</blockquote>", '#display_response');
265 report("appTag: " + appTag, '#display_response');
271 function doAcquireCred() {
272 gss = gss || new navigator.gss({
275 gss.error = function(major, minor, errMsg, appTag)
277 report("Error", '#acquire_response');
278 report("Major: " + major + "; Minor: " + minor, '#acquire_response');
279 report("<blockquote>" + errMsg + "</blockquote>", '#acquire_response');
280 report("appTag: " + appTag, '#acquire_response');
284 desired_name: document.getElementById('import_name_name').value,
285 cred_usage: document.getElementById('import_name_name').value
287 if (document.getElementById("acquire_cred_time_req").value > 0)
289 params.time_req = document.getElementById("acquire_cred_time_req").value;
291 if ("" != document.getElementById("acquire_cred_desired_mechs").value)
293 params.desired_mechs =
294 document.getElementById("acquire_cred_desired_mechs").value;
297 gss.acquire_cred(params);
300 /********************************************************
301 * Call the init_sec_context routine
302 ********************************************************/
303 function doInitSecContext() {
304 gss = gss || new navigator.gss({
307 gss.error = function(major, minor, errMsg, appTag)
310 '#init_sec_context_response');
311 report("Major: " + major + "; Minor: " + minor,
312 '#init_sec_context_response');
313 report("<blockquote>" + errMsg + "</blockquote>",
314 '#init_sec_context_response');
315 report("appTag: " + appTag,
316 '#init_sec_context_response');
319 /* context_handle, mech_type, req_flags, time_req, input_token */
322 context_handle: document.getElementById('init_sec_context_context_handle').value,
323 target_name: document.getElementById('init_sec_context_target_name').value,
324 mech_type: document.getElementById('init_sec_context_mech_type').value,
325 req_flags: document.getElementById('init_sec_context_req_flags').value,
326 time_req: document.getElementById('init_sec_context_time_req').value,
327 input_token: document.getElementById('init_sec_context_input_token').value,
328 success: function(data, appTag) {
329 $('#init_sec_context_context_handle').attr("value",
330 data.context_handle);
331 report("Output token: " + data.output_token,
332 '#init_sec_context_response');
335 gss.init_sec_context(params);
338 function doAuthenticate() {
339 gssweb = gssweb || new navigator.gssweb({
340 serverPath: document.getElementById('authenticate_server_path').value,
341 appTag: "Authentication Test",
342 error: function(errMsg) {
343 report(errMsg, '#authenticate_response');
345 success: function(appData, contentType, appTag) {
346 report(contentType, '#authenticate_response');
347 report("Content-Type:", '#authenticate_response');
348 report(appData, '#authenticate_response');
349 report("Found app data:", '#authenticate_response');
350 report("Success!", '#authenticate_response');
353 gssweb.authenticate();
356 document.addEventListener('DOMContentLoaded', function () {
357 <!-- Listen for the import name button click -->
358 document.getElementById('import_name').addEventListener(
359 'click', doImportName
362 <!-- Listen for the import name button click -->
363 document.getElementById('display_name').addEventListener(
364 'click', doDisplayName
367 <!-- Listen for the acquire cred button click -->
368 document.getElementById('acquire_cred').addEventListener(
369 'click', doAcquireCred
372 <!-- Listen for the import name button click -->
373 document.getElementById('init_sec_context').addEventListener(
374 'click', doInitSecContext
378 <!-- Listen for the authenticate button click -->
379 document.getElementById('authenticate').addEventListener(
380 'click', doAuthenticate