Update the tester page for GSSWeb
[gssweb.git] / chrome / test / test.html
1 <html>
2   <head>
3     <title>GSSApi Tester Application</title>
4
5     <!-- Latest compiled and minified CSS -->
6     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
7
8     <!-- Optional theme -->
9     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
10
11   </head>
12   <body>
13   <div class="container-fluid">
14     <div class="row">
15       <div class="col-xs-4">
16         <!-- left column -->
17         <h2>GSS Import Name</h2>
18         <div class="form-group">
19           <label for="import_name_name">Name:</label>
20           <input name="import_name_name" id="import_name_name" value="HTTP@localhost.localdomain" />
21         </div>
22         <div class="form-group">
23           <label for="import_name_mech">Mechanism:</label>
24           <input name="import_name_mech"
25                  id="import_name_mech"
26                  value="{1 2 840 113554 1 2 1 4 }" />
27         </div>
28         <button id="import_name">gss_import_name</button>
29         <div id='import_response' style="overflow: auto;"></div>
30       </div>
31
32
33       <div class="col-xs-4">
34         <!-- middle column -->
35         <h2>GSS Acquire Cred</h2>
36         <div class="form-group">
37           <label for="acquire_cred_desired_name">Desired name:</label>
38           <select name="acquire_cred_desired_name" class="gss_name">
39           </select>
40         </div>
41
42         <div class="form-group">
43           <label for="acquire_cred_cred_usage">Cred Usage:</label>
44           <select name="acquire_cred_cred_usage">
45             <option value="GSS_C_INITIATE">GSS_C_INITIATE</option>
46             <option value="GSS_C_ACCEPT">GSS_C_ACCEPT</option>
47             <option value="GSS_C_BOTH">GSS_C_BOTH</option>
48           </select>
49         </div>
50
51         <div class="form-group">
52           <label for="acquire_cred_time_req">Requested lifetime in seconds (0 for default 2 hours):</label>
53           <input name="acquire_cred_time_req" value="0"/>
54         </div>
55
56         <div class="form-group">
57           <label for="acquire_cred_desired_mechs">Desired mechanisms (comma separated, blank for default):</label>
58           <input name="acquire_cred_time_req" value=""/>
59         </div>
60
61       </div>
62
63
64       <div class="col-xs-4">
65         <!-- right column -->
66         <h2>GSS Init Sec Context</h2>
67         <div class="form-group">
68           <label for="init_sec_context_target_name">Target name:</label>
69           <select name="init_sec_context_target_name" class="gss_name">
70           </select>
71         </div>
72
73         <div class="form-group">
74           <label for="init_sec_context_context_handle">Context handle:</label>
75           <input name="init_sec_context_context_handle"/>
76         </div>
77
78         <div class="form-group">
79           <label for="init_sec_context_input_token">Input token:</label>
80           <input name="init_sec_context_input_token"/>
81         </div>
82
83         <div class="form-group">
84           <label for="init_sec_context_mech_type">Mechanism type (blank for default):</label>
85           <input name="init_sec_context_mech_type"/>
86         </div>
87
88         <div class="form-group">
89           <label for="init_sec_context_time_req">Requested lifetime in seconds (0 for default 2 hours):</label>
90           <input name="init_sec_context_time_req" value="0" />
91         </div>
92
93         <div class="form-group">
94           <label for="init_sec_context_req_flags">Request flags (0 unless you know what you're doing):</label>
95           <input name="init_sec_context_req_flags" value="0" />
96         </div>
97
98       </div> 
99    </div>
100
101     <div class="row">
102       <div class="col-xs-12">
103         <div class="form-group">
104           <label for="authenticate_server_path">Server Path:</label>
105           <input name="authenticate_server_path" value="/gss" />
106         </div>
107
108         <button id="authenticate">authenticate</button>
109         <div id='authenticate_response' style="overflow: auto;"></div>
110       </div>
111     </div>
112
113   </div>
114   
115    <!-- Scripts! ------------------------------------------------------------------------------>
116    <!-- Required JQuery -->
117    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
118
119    <!-- Latest compiled and minified JavaScript -->
120    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
121
122    <!-- GSS Web script -->
123    <script src="navigator.gssweb.js"></script>
124
125     <script language="javascript">
126       var gss;
127       var gssweb;
128
129       function report(msg, elemId) {
130         var element = $(elemId);
131         element.prepend('<p>' + msg + '</p>');
132       }
133
134       function doImportName() {
135         gss = gss || new navigator.gss_eap({
136           appTag: "TestApp",
137           error:  function(major, minor, errMsg, appTag) 
138                   {
139                     report("Error", '#import_response');
140                     report("Major: " + major + "; Minor: " + minor, '#import_response');
141                     report("<blockquote>" + errMsg + "</blockquote>", '#import_response');
142                     report("appTag: " + appTag, '#import_response');
143                   }
144         });
145         gss.import_name({
146           name:      document.getElementById('import_name_name').value,
147           name_type: document.getElementById('import_name_mech').value,
148           success:   function(data, appTag) {
149                        report("GSS imported name: " + data.gss_name, '#import_response');
150                        report("appTag: " + appTag, '#import_response');
151                        newOption = $('<option></option>');
152                        newOption.attr('value', data.gss_name);
153                        newOption.append(document.getElementById('import_name_name').value);
154                        $('.gss_name').append(newOption);
155                      }
156         });
157       } // doImportName
158
159       function doAuthenticate() {
160         gssweb = gssweb || new navigator.gssweb({
161           serverPath: "/gss",
162           appTag:     "Authentication Test",
163           error:      function(errMsg) {
164                         report(errMsg, '#authenticate_response');
165                       },
166           success:    function(appData, contentType, appTag) {
167                         report(contentType, '#authenticate_response');
168                         report("Content-Type:", '#authenticate_response');
169                         report(appData, '#authenticate_response');
170                         report("Found app data:", '#authenticate_response');
171                         report("Success!", '#authenticate_response');
172                       }
173         });
174         gssweb.authenticate();
175       } // doAuthenticate
176       
177       document.addEventListener('DOMContentLoaded', function () {
178         <!-- Listen for the import name button click -->
179         document.getElementById('import_name').addEventListener(
180           'click', doImportName
181         );
182
183         <!-- Listen for the authenticate button click -->
184         document.getElementById('authenticate').addEventListener(
185           'click', doAuthenticate
186         );
187
188       });
189
190     </script>
191
192   </body>
193 </html>