SDSS WAYF patch for multi-federation support
[java-idp.git] / webApplication / wayf.jsp
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
3         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html>
5
6 <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
7 <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
8
9 <logic:present name="showComments" scope="Request">
10
11 <!-- TO CONFIGURE THIS FOR A SPECIFIC SITE
12      =====================================
13
14      Before you deploy this jsp you need to look for CONFIG below.
15      These mark places where you should make changes. 
16
17      If you want to make more profound changes but only to the jsp,
18      you should read the sections marked PROGRAMMING NOTE below.-->
19
20 <!-- PROGRAMMING NOTE
21
22      "requestURL" contains the URL that was specified to get the
23      WAYF going.  The jsp uses it mostly for submitting result back to
24      the WAYF and error reporting -->
25
26 </logic:present>
27
28     <jsp:useBean id="requestURL" scope="request" class="java.lang.String"/>
29
30 <logic:present name="showComments" scope="Request">
31
32 <!-- PROGRAMMING NOTE
33
34      shire, target, provider and time are all part of the Shibboleth
35      protocol and need to be specified as parameters to the WAYF. -->
36
37 </logic:present>
38
39
40     <jsp:useBean id="shire" scope="request" class="java.lang.String"/>
41     <jsp:useBean id="target" scope="request" class="java.lang.String"/>
42     <jsp:useBean id="providerId" scope="request" class="java.lang.String"/>
43     <jsp:useBean id="time" scope="request" class="java.lang.String"/>
44
45 <logic:present name="showComments" scope="Request">
46 <!-- PROGRAMMING NOTE
47
48      In addition to the above.  The WAYF also supplies the following to
49      the jsp.
50
51      "cookieList" If this exists it represents the contents of the
52          _saml_idp cookie (possibly filtered to remove IdPs which
53          cannot serve the SP).  It is a Collection of IdPSite objects,
54          which themselves have the following properties:
55
56        "name" The uri for the IdP, which needs to be returned to the
57               WAYF in the "origin" parameter.
58
59        "displayName" User friendly name (taken from its alias)
60
61        "addressFor" The (ungarnished) URL for the IdP. This could be
62               used to create a direct hyperlink to the IdP
63
64      "sites" If this exists it contains all the possible IdPs for for
65          the SP (possibly filtered).  It is a Collection of IdPSite
66          Objects which are described above.  This is only present if
67          provideList was defined true in the configuration.
68
69      "siteLists" If this exists it contains all the possible metadata
70          files which can service for the SP (possibly filtered).  It
71          is a collection of IdPSiteSetEntry Objects which have two
72          properties:
73
74          "name" This is the displayName from the Metadata element in
75             the WAYF configuration file
76
77          "sites" This represents the IdPs.  Again it is a collection
78             of IdPSite Objects
79
80          It is only present if provideListOfList was defined true in
81          the configuration.
82
83      "singleSiteList" if this is present, then there is only one
84          IdPSiteSetEntry Object in "siteLists".
85
86      "searchresultempty" If this is present then it means that a
87          search was performed, but no suitable IdPs were returned.
88
89      "searchresults" If this is present it represents the list of IdPs
90          which matched a previous search.  It is a Collection of
91          IdPSite Objects. -->
92
93 <!-- PROGRAMMING NOTE
94
95      The jsp communicates back to the WAYF via the parameters listed
96      above, and:
97
98         "action" what the WAYF has to do.  Possible contents are:
99
100             "lookup" - refresh the screen.
101             "search" - perform a search on the contents parameter "string"
102             "selection" - redirect to the IdP with the uri "origin"
103
104         "cache" preserve any selection in the _saml_idp cookie. A
105             value of "session" makes the cookie last for the browser
106             session, "perm" gives it the lifetime specified in the
107             configuration file.  -->
108
109 </logic:present>
110
111 <head>
112     <link rel="stylesheet" title="normal" type="text/css"
113     href="wayf.css" /> <title>Identity Provider Selection</title>
114     </head>
115
116 <body>
117     <div class="head">
118         <h1>
119
120 Select an identity provider
121
122         </h1>
123     </div>
124
125     <div class="selector">
126     <p class="text">
127
128 <!--CONFIG-->
129
130 The Service you are trying to reach requires that you
131 authenticate with your home institution, please select it from the
132 list below.
133
134     </p>
135     <logic:present name="cookieList" scope="request">
136
137         <h2>
138
139 Recently used institutions:
140
141         </h2>   
142
143 <logic:present name="showComments" scope="Request">
144
145 <!-- PROGRAMMING NOTE
146  
147      Generate a hyperlink back to the WAYF.  Note that we are
148      simulating the user having specified a permanent cookie -->
149
150 </logic:present>
151
152         <logic:iterate id="site" name="cookieList">
153             <p  class="text">
154                 <a href="<bean:write name="requestURL" />?target=<bean:write name="target" />&shire=<bean:write name="shire" />&providerId=<bean:write name="providerId" />&time=value=<bean:write name="time" />&cache=perm&action=selection&origin=<jsp:getProperty name="site" property="name" />">
155                     <jsp:getProperty name="site"
156                     property="displayName" />
157                 </a>
158             </p>
159         </logic:iterate>
160
161 <logic:present name="showComments" scope="Request">
162
163 <!-- PROGRAMMING NOTE
164
165      We defined the ClearCache.Wayf service in wayfconfig.  So we know
166      it is here.  This will empty the cookie and loop -->
167
168 </logic:present>
169
170         <form method="get" action="ClearCache.wayf" />
171             <input type="hidden" name="shire" value="<bean:write name="shire" />" />
172             <input type="hidden" name="target" value="<bean:write name="target" />" />
173             <logic:present name="providerId" scope="request">
174                <input type="hidden" name="providerId" value="<bean:write name="providerId" />" />
175             </logic:present>
176             <logic:present name="time" scope="request">
177                 <input type="hidden" name="time" value="<bean:write name="time" />" />
178             </logic:present>
179             <input type="submit" value="Clear" />
180         </form>
181
182     </logic:present>
183
184     <div class="list">
185
186         <h2>
187
188 Choose from a list:
189
190         </h2>
191
192         <logic:present name="sites" scope="request">
193         <logic:notPresent name="siteLists" scope="request">
194
195             <form method="get" action="<bean:write name="requestURL" />">
196                     <input type="hidden" name="shire" value="<bean:write name="shire" />" />
197                     <input type="hidden" name="target" value="<bean:write name="target" />" />
198                     <logic:present name="providerId" scope="request">
199                         <input type="hidden" name="providerId" value="<bean:write name="providerId" />" />
200                     </logic:present>
201                     <logic:present name="time" scope="request">
202                         <input type="hidden" name="time" value="<bean:write name="time" />" />
203                     </logic:present>
204                     <input type="hidden" name="action" value="selection" />
205                     <select name="origin">      
206                         <logic:iterate id="site" name="sites">
207                             <option value="<jsp:getProperty name="site" property="name" />">
208                                 <jsp:getProperty name="site" property="displayName" />
209                             </option>
210                         </logic:iterate>
211                     </select>
212                     <input type="submit" value="Select" />
213                     <select name="cache">
214                         <option value="false"> Do not remember
215                         <option value="session" selected> Remember for session
216                         <option value="perm"> Remember for a week
217                     </select>
218             </form>
219         </logic:notPresent>
220         </logic:present>
221
222 <logic:present name="showComments" scope="Request">
223
224 <!-- PROGRAMMING NOTE
225      Build two tables side by side, one with the Federation names and 'ALL' (if apposite)
226      and the other will be dynamically populated with the members of that federation.
227
228      This needs to work in the face of no javascript, so we initially populate the 
229      Right hand list with all the IdPs.  The first Selection in the Left hand Table will
230      shrink this list
231
232      The 'lists of all IdPs' is derived from the one which java gives us (if it did)
233      otherwise it is derived by a double iteration through the List of Lists.  This
234      makes for complicated looking code, but it's dead simple really.
235
236  -->
237
238 </logic:present>
239
240         <logic:present name="siteLists" scope="request">
241           <form method="get" action="<bean:write name="requestURL" />">
242             <input type="hidden" name="shire" value="<bean:write name="shire" />" />
243             <input type="hidden" name="target" value="<bean:write name="target" />" />
244
245             <logic:present name="providerId" scope="request">
246               <input type="hidden" name="providerId" value="<bean:write name="providerId" />" />
247             </logic:present>
248
249             <logic:present name="time" scope="request">
250               <input type="hidden" name="time" value="<bean:write name="time" />" />
251             </logic:present>
252
253             <table name="tab">
254                <th>Federation </th>
255                <th>Institution</th>
256                <tr>
257                  <td><select name="FedSelector" size="10" id="FedSelect" 
258                              onChange="changedFed(this.form.origin,
259                                                   this.form.FedSelector[this.form.FedSelector.selectedIndex].value);">
260                    <logic:iterate id="siteset" name="siteLists">
261                      <logic:present name="singleSiteList" scope="request">
262
263                        <!-- Only One site so select it -->
264
265                        <option value="<jsp:getProperty name="siteset" property="name"/>" SELECTED>
266                          <jsp:getProperty name="siteset" property="name"/>
267                        </option>
268                      </logic:present>
269                      <logic:notPresent name="singleSiteList" scope="request">
270                        <option value="<jsp:getProperty name="siteset" property="name"/>">
271                          <jsp:getProperty name="siteset" property="name"/>
272                        </option>
273                      </logic:notPresent>
274                    </logic:iterate>
275
276                    <logic:notPresent name="singleSiteList" scope="request">
277
278                      <!-- More than one site so select the 'All' -->
279
280                      <option value="ALL" selected>
281                          All Sites
282                      </option>
283                    </logic:notPresent>
284                 </select></td>
285
286                  <td>
287                    <input type="hidden" name="action" value="selection" />
288                    <select name="origin" size="10" id="originIdp"> 
289                      <logic:present name="sites" scope="request">
290                        <logic:iterate id="site" name="sites">
291                          <option value="<jsp:getProperty name="site" property="name" />">
292                            <jsp:getProperty name="site" property="displayName" />
293                          </option>
294                        </logic:iterate>
295                      </logic:present>
296
297                      <logic:notPresent name="sites" scope="request">
298                        <logic:iterate id="siteset" name="siteLists">
299                          <logic:iterate id="site" name="siteset" property="sites">
300                            <option value="<jsp:getProperty name="site" property="name" />">
301                              <jsp:getProperty name="site" property="displayName" />
302                            </option>
303                          </logic:iterate>
304                        </logic:iterate>        
305                      </logic:notPresent>
306                    </select>
307                    
308                  </td>
309                </tr>
310              </table>
311              <p>
312                <input type="submit" value="Select" />
313                <select name="cache">
314                  <option value="false"> Do not remember
315                  <option value="session" selected> Remember for session
316                  <option value="perm"> Remember for a week
317                </select>
318              </p>
319            </form>
320         </logic:present>
321         </div>
322         <div class="search">
323             <span class="option">or</span>
324
325             <h2>
326
327 Search by keyword:
328
329             </h2>
330
331             <form method="get" action="<bean:write name="requestURL" />">
332                 <p>
333                     <input type="hidden" name="shire" value="<bean:write name="shire" />" />
334                     <input type="hidden" name="target" value="<bean:write name="target" />" />
335                     <logic:present name="providerId" scope="request">
336                         <input type="hidden" name="providerId" value="<bean:write name="providerId" />" />
337                     </logic:present>
338                     <logic:present name="time" scope="request">
339                         <input type="hidden" name="time" value="<bean:write name="time" />" />
340                     </logic:present>
341                     <input type="hidden" name="action" value="search" />
342                     <input type="text" name="string" />
343                     <input type="submit" value="Search" />
344                 </p>
345             </form>
346
347             <logic:present name="searchResultsEmpty" scope="request">
348                 <p class="error">
349
350 No provider was found that matches your search criteria, please try again.
351
352                 </p>
353             </logic:present>
354
355             <logic:present name="searchresults" scope="request">
356                 <h3>
357
358 Search results:
359
360                 </h3>
361                 <form method="get" action="<bean:write name="requestURL" />">
362                     <ul>
363                         <logic:iterate id="currResult" name="searchresults">
364                             <li>
365                                 <input type="radio" name="origin" value="<jsp:getProperty name="currResult" property="name" />" />
366                                 <jsp:getProperty name="currResult" property="displayName" />
367                             </li>
368                         </logic:iterate>
369                     </ul>
370                     <p>
371                         <input type="hidden" name="shire" value="<bean:write name="shire" />" />
372                         <input type="hidden" name="target" value="<bean:write name="target" />" />
373                         <logic:present name="providerId" scope="request">
374                             <input type="hidden" name="providerId" value="<bean:write name="providerId" />" />
375                         </logic:present>
376                         <logic:present name="time" scope="request">
377                             <input type="hidden" name="time" value="<bean:write name="time" />" />
378                         </logic:present>
379                         <input type="hidden" name="action" value="selection" />
380                         <input type="submit" value="Select" />
381                         <select name="cache">
382                             <option value="false"> Do not remember
383                             <option value="session" selected> Remember for session
384                             <option value="perm"> Remember for a week
385                         </select>
386                     </p>
387                 </form>     
388             </logic:present>
389         </div>
390     </div>
391
392     <div class="footer">
393         <p class="text">
394 <!--CONFIG-->
395 Need assistance? Send mail to <a href="mailto:user@domain"> administrator's name</a> with description.
396         </p>
397         <div class="logo"><img src="images/internet2.gif" alt="InQueue" /></div>
398     </div>
399
400 <logic:present name="showComments" scope="Request">
401
402 <!--PROGRAMMING NOTE
403   
404   We need to program the on changed selector.  Note that option.InnterText only
405   works on IE, options.remove doesn't work on Firefox, and that
406   options.add doesn't work on Safari.  Hence the somewhat strange manipulations
407   to delete & populate the list of options.
408
409   X        is the select object for the right hand table
410   Selected is the name selected in the left hand table
411
412 -->
413
414 </logic:present>
415
416 <logic:present name="siteLists" scope="request">
417 <script language="javascript" type="text/javascript">
418 <!--
419
420 function changedFed(X, Selected) {
421
422   <logic:notPresent name="singleSiteList" scope="request">
423
424      while (X.length > 0) {
425         X.options[(X.length-1)] = null;
426      }
427   
428   
429     <logic:iterate id="siteset" name="siteLists">
430       if (Selected == "<jsp:getProperty name="siteset" property="name"/>") {
431         var opt;
432         <logic:iterate id="site" name="siteset" property="sites">
433           opt = new Option ("<jsp:getProperty name="site" property="displayName" />");
434           X.options[X.length] = opt;
435           opt.value = "<jsp:getProperty name="site" property="name" />";
436         </logic:iterate>
437       }
438     </logic:iterate>
439   
440       if (Selected == "ALL") {
441         var opt;
442   
443       <logic:present name="sites" scope="request">
444           <logic:iterate id="site" name="sites">
445             opt = new Option("<jsp:getProperty name="site" property="displayName" />");
446             X.options[X.length] = opt;
447             opt.value = "<jsp:getProperty name="site" property="name" />";
448           </logic:iterate>
449       </logic:present>
450   
451       <logic:notPresent name="sites" scope="request">
452           <logic:iterate id="siteset" name="siteLists">
453             <logic:iterate id="site" name="siteset" property="sites">
454               opt = new Option ("<jsp:getProperty name="site" property="displayName" />");
455               X.options[X.length] = opt;
456               opt.value = "<jsp:getProperty name="site" property="name" />";
457             </logic:iterate>
458           </logic:iterate>
459       </logic:notPresent>
460     }
461   
462   </logic:notPresent>
463    
464   
465 }
466 -->
467 </script>
468 </logic:present>
469  
470   
471 </body>
472 </html>
473