Add copyright comment headers to appropriate files
[gssweb.git] / browsers / test / test.html
1 <html>
2   <!-- 
3       Copyright (c) 2014, 2015 JANET(UK)
4       All rights reserved.
5
6       Redistribution and use in source and binary forms, with or without
7       modification, are permitted provided that the following conditions
8       are met:
9
10       1. Redistributions of source code must retain the above copyright
11          notice, this list of conditions and the following disclaimer.
12
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.
16
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.
20
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.
33
34   -->
35   <head>
36     <title>GSSApi Tester Application</title>
37
38     <!-- Latest compiled and minified CSS -->
39     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
40
41     <!-- Optional theme -->
42     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
43
44   </head>
45   <body>
46   <div class="container-fluid">
47     <div class="row">
48       <div class="col-xs-4">
49         <!-- left column -->
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"
54                  id="import_name_name"
55                  value="HTTP@localhost.localdomain" />
56         </div>
57         <div class="form-group">
58           <label for="import_name_mech">Mechanism:</label>
59           <input name="import_name_mech"
60                  id="import_name_mech"
61                  value="{1 2 840 113554 1 2 1 4 }" />
62         </div>
63         <button id="import_name">gss_import_name</button>
64         <div id='import_response' style="overflow: auto;"></div>
65       </div>
66
67
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">
74           </select>
75         </div>
76
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>
83           </select>
84         </div>
85
86         <div class="form-group">
87           <label for="acquire_cred_time_req">
88             Requested lifetime in seconds (0 for default 2 hours):
89           </label>
90           <input name="acquire_cred_time_req"
91                  id="acquire_cred_time_req"
92                  value="0"/>
93         </div>
94
95         <div class="form-group">
96           <label for="acquire_cred_desired_mechs">
97             Desired mechanisms (comma separated, blank for default):
98           </label>
99           <input name="acquire_cred_desired_mechs"
100                  id="acquire_cred_desired_mechs"
101                  value=""/>
102         </div>
103
104         <button id="acquire_cred">gss_acquire_cred</button>
105         <div id="acquire_response" style="overflow: auto;"></div>
106
107       </div>
108
109
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"
117                   class="gss_name">
118           </select>
119         </div>
120
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"/>
125         </div>
126
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"/>
131         </div>
132
133         <div class="form-group">
134           <label for="init_sec_context_mech_type">
135             Mechanism type (blank for default):
136           </label>
137           <input name="init_sec_context_mech_type"
138                  id="init_sec_context_mech_type"/>
139         </div>
140
141         <div class="form-group">
142           <label for="init_sec_context_time_req">
143             Requested lifetime in seconds (0 for default 2 hours):
144           </label>
145           <input name="init_sec_context_time_req"
146                  id="init_sec_context_time_req" value="0" />
147         </div>
148
149         <div class="form-group">
150           <label for="init_sec_context_req_flags">
151             Request flags (0 unless you know what you're doing):
152           </label>
153           <input name="init_sec_context_req_flags" 
154                  id="init_sec_context_req_flags" value="0" />
155         </div>
156
157         <button id="init_sec_context">gss_init_sec_context</button>
158         <div id="init_sec_context_response" style="overflow: auto;"></div>
159
160       </div> 
161    </div>
162
163    <div class="row">
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">
170           </select>
171         </div>
172
173         <button id="display_name">gss_display_name</button>
174         <div id="display_name_response" style="overflow: auto;"></div>
175
176       </div>
177    </div>
178
179     <div class="row">
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" 
185                  value="/gss/" />
186         </div>
187
188         <button id="authenticate">authenticate</button>
189         <div id='authenticate_response' style="overflow: auto;"></div>
190       </div>
191     </div>
192
193   </div>
194   
195    <!-- Scripts! ------------------------------------------------------------------------------>
196    <!-- Required JQuery -->
197    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
198
199    <!-- Latest compiled and minified JavaScript -->
200    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
201
202    <!-- GSS Web script -->
203    <script src="navigator.gssweb.js"></script>
204
205     <script language="javascript">
206       var gss;
207       var gssweb;
208
209       function report(msg, elemId) {
210         var element = $(elemId);
211         element.prepend('<p>' + msg + '</p>');
212       }
213
214       function doImportName() {
215         gss = gss || new navigator.gss({
216           appTag: "TestApp"
217         });
218         gss.error = function(major, minor, errMsg, appTag) 
219         {
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');
224         };
225         gss.import_name({
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);
235                      }
236         });
237       } // doImportName
238
239       function doDisplayName() {
240         gss = gss || new navigator.gss({
241           appTag: "TestApp"
242         });
243         gss.error = function(major, minor, errMsg, appTag) 
244         {
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');
249         };
250         gss.display_name({
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);
259                      },
260           error: function(major, minor, errMsg, appTag) 
261         {
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');
266         }
267         });
268       } // doDisplayName
269
270
271       function doAcquireCred() {
272         gss = gss || new navigator.gss({
273           appTag: "TestApp"
274         });
275         gss.error = function(major, minor, errMsg, appTag) 
276         {
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');
281         };        
282
283         var params = {
284           desired_name: document.getElementById('import_name_name').value,
285           cred_usage: document.getElementById('import_name_name').value
286         };
287         if (document.getElementById("acquire_cred_time_req").value > 0)
288         {
289           params.time_req = document.getElementById("acquire_cred_time_req").value;
290         }
291         if ("" != document.getElementById("acquire_cred_desired_mechs").value)
292         {
293           params.desired_mechs = 
294             document.getElementById("acquire_cred_desired_mechs").value;
295         }
296         
297         gss.acquire_cred(params);
298       }
299
300       /********************************************************
301        *  Call the init_sec_context routine
302        ********************************************************/
303       function doInitSecContext() {
304         gss = gss || new navigator.gss({
305           appTag: "TestApp",
306         });
307         gss.error = function(major, minor, errMsg, appTag) 
308         {
309           report("Error",
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');
317         };        
318
319 /* context_handle, mech_type, req_flags, time_req, input_token */
320
321         var params = {
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');
333           }
334         };
335         gss.init_sec_context(params);
336       }
337
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');
344                       },
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');
351                       }
352         });
353         gssweb.authenticate();
354       } // doAuthenticate
355       
356       document.addEventListener('DOMContentLoaded', function () {
357         <!-- Listen for the import name button click -->
358         document.getElementById('import_name').addEventListener(
359           'click', doImportName
360         );
361
362         <!-- Listen for the import name button click -->
363         document.getElementById('display_name').addEventListener(
364           'click', doDisplayName
365         );
366
367         <!-- Listen for the acquire cred button click -->
368         document.getElementById('acquire_cred').addEventListener(
369           'click', doAcquireCred
370         );
371
372         <!-- Listen for the import name button click -->
373         document.getElementById('init_sec_context').addEventListener(
374           'click', doInitSecContext
375         );
376
377
378         <!-- Listen for the authenticate button click -->
379         document.getElementById('authenticate').addEventListener(
380           'click', doAuthenticate
381         );
382
383       });
384
385     </script>
386
387   </body>
388 </html>