Project

General

Profile

Revision 5071

Added by daigle over 10 years ago

Change sanparks skin to log in with browser session instead of metacat client session so session can be validated on other pages.

View differences:

lib/style/skins/sanparks/sanparksLogin.xsl
1
<?xml version="1.0"?>
2
<!--
3
  *  '$RCSfile$'
4
  *      Authors: Jivka Bojilova
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *
9
  *   '$Author: leinfelder $'
10
  *     '$Date: 2008-06-17 13:16:32 -0700 (Tue, 17 Jun 2008) $'
11
  * '$Revision: 4006 $'
12
  * 
13
  * This program is free software; you can redistribute it and/or modify
14
  * it under the terms of the GNU General Public License as published by
15
  * the Free Software Foundation; either version 2 of the License, or
16
  * (at your option) any later version.
17
  *
18
  * This program is distributed in the hope that it will be useful,
19
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
  * GNU General Public License for more details.
22
  *
23
  * You should have received a copy of the GNU General Public License
24
  * along with this program; if not, write to the Free Software
25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
  *
27
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
28
  * convert an XML file with information about login action
29
  * into an HTML format suitable for rendering with modern web browsers.
30
-->
31

  
32
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
33

  
34
 <xsl:output method="html"/>
35
 <xsl:param name="contextURL"/>
36
 <xsl:param name="servletURL"/>
37
 <xsl:param name="cgi-prefix"/>
38
 <xsl:param name="qformat">sanparks</xsl:param>
39
 <xsl:template match="/">
40
  	<xsl:choose>
41
  	<xsl:when test="count(login) &gt; 0">
42
		<h3>Welcome, <xsl:value-of select="login/name"/>  </h3>
43
		<form name="logoutForm" onsubmit="submitLogoutFormIntoDiv('{$servletURL}', this, 'loginSection')">
44
			<input name="qformat" value="sanparks" type="hidden" />
45
			<input name="action" type="hidden" value="logout"/>
46
			<table>
47
				<tr valign="top">
48
					<td><p class="regtext">You are currently logged in.</p></td>
49
					<td align="right">
50
						<input name="action" type="submit" value="Logout" class="button_login" />
51
					</td>
52
			</tr>
53
			<tr valign="top">
54
				<td colspan="2"><p class="regtext">(<xsl:value-of select="login/message"/>)</p></td>
55
			</tr>	
56
			<tr>	
57
				<td colspan="2" class="regtext" align="center" valign="top">				
58
					<!-- reset pass --> 
59
					<a href="{$cgi-prefix}/ldapweb.cgi?cfg=sanparks&amp;stage=resetpass" target="_parent">
60
						reset your password
61
					</a>
62
					|
63
					<!-- change pass --> 
64
					<a href="{$cgi-prefix}/ldapweb.cgi?cfg=sanparks&amp;stage=changepass" target="_parent">
65
						change your password
66
					</a>
67
				</td>
68
			</tr>
69
		</table>
70
		</form>
71
		
72
		<!-- File Upload Form --> 
73
		<br/>		
74
		<h3>Data Package Upload</h3>
75
		
76
		<table width="100%">
77
		<tr valign="top">
78
			<td align="right">
79
				<form method="post" action="{$contextURL}/style/skins/sanparks/upload.jsp">
80
					<input type="submit" value="Go >" class="button_login" />
81
				</form>
82
			</td>
83
		</tr>
84
	</table>
85
	</xsl:when>
86
  	<xsl:otherwise>
87
		<h3>Login
88
		<a href="{$contextURL}/cgi-bin/ldapweb.cgi?cfg=sanparks" target="_new" />
89
			<span class="regtext"> (request an account...)</span>
90
		</h3>
91
		<form name="loginForm" id="loginForm" onsubmit="submitLoginFormIntoDiv('{$servletURL}', this, 'loginSection')">
92
			<input name="qformat" type="hidden" value="sanparks" />
93
			<input name="action" type="hidden" value="login"/>
94
			<table>
95
				<tr valign="top">
96
					<td><span class="required">User name</span></td>
97
					<td><input name="shortusername" type="text" value="" style="width: 140" /></td>
98
					<td><input name="username" type="hidden" value="" /></td>
99
					
100
				</tr>
101
				<tr>
102
					<td><span class="required">Organization</span></td>
103
					<td><select name="organization" style="width: 140">
104
						<option value="SANParks" selected="">SANParks</option>
105
						<option value="SAEON">SAEON</option>
106
						<option value="NCEAS">NCEAS</option>
107
						<option value="unaffiliated">unaffiliated</option>
108
						</select></td>
109
				</tr>
110
				<tr>
111
					<td><span class="required">Password</span></td>
112
					<td><input name="password" value="" type="password"
113
						style="width: 140" maxlength="50" /></td>
114
				</tr>
115
				<tr>
116
					<td colspan="2" align="center">
117
						<input name="action" value="login" type="submit" class="button_login" />
118
					</td>
119
				</tr>
120
			</table>
121
		</form>
122
		
123
		<!-- File Upload Form --> 
124
		<br/>		
125
		<h3>Data Package Upload</h3>
126
		<p class="regtext">You must be logged into your user account before uploading a data set.</p>
127
		
128
	</xsl:otherwise>
129

  
130
	</xsl:choose>
131
  </xsl:template>
132
</xsl:stylesheet>
133

  
0 134

  
lib/style/skins/sanparks/SaeonLogin.jspx
3 3

  
4 4
	<!-- to change the content type or response encoding change the following line -->
5 5
	<jsp:directive.page contentType="text/html;charset=UTF-8" />
6
	<jsp:directive.page
6
	<!--  jsp:directive.page
7 7
		import="edu.ucsb.nceas.metacat.clientview.ClientView" />
8 8
	<jsp:directive.page
9 9
		import="edu.ucsb.nceas.metacat.clientview.ClientViewHelper" />
......
12 12

  
13 13
	<jsp:declaration>
14 14
        private ClientViewHelper clientViewHelper = null;
15
    </jsp:declaration>
15
    </jsp:declaration -->
16 16

  
17 17
<jsp:directive.include file="settings.jsp" />
18 18

  
......
70 70
	
71 71
<body>
72 72
	<div class="templatecontentareaclass" style="background: #FFFFFF;">
73
		<jsp:useBean id="clientViewBean" scope="session" class="edu.ucsb.nceas.metacat.clientview.ClientView" /> 
73
		<!-- jsp:useBean id="clientViewBean" scope="session" class="edu.ucsb.nceas.metacat.clientview.ClientView" /> 
74 74
		<jsp:setProperty name="clientViewBean" property="*" /> 
75
		<jsp:scriptlet>
75
		jsp:scriptlet>
76 76
			clientViewHelper = ClientViewHelper.clientViewHelperInstance(request);
77 77
			clientViewHelper.clientRequest(request, response);
78
        </jsp:scriptlet>
79
		<script type="text/javascript" >		
78
        </jsp:scriptlet -->
79
		<!-- script type="text/javascript" >		
80 80
				setCookie('JSESSIONID','<jsp:getProperty name="clientViewBean" property="sessionid" />','<jsp:expression>request.getContextPath()</jsp:expression>');
81
		</script>
81
		</script -->
82 82

  
83 83
	<table>
84 84
	<tr>
......
278 278
		Welcome,
279 279
		<jsp:expression>clientViewBean.getUsername()</jsp:expression>  
280 280
	</h3>
281
	<form name="logoutForm" method="post" action="./">
281
	<form name="logoutForm" id="logoutForm" onsubmit="submitFormIntoDiv('<%= SERVLET_URL %>', 'logoutForm', 'loginSection')">
282 282
	<input name="qformat" value="sanparks" type="hidden" />
283
	<input name="action" type="hidden" value="logout"/>
283 284
	<table>
284 285
		<tr valign="top">
285 286
			<td>
lib/style/skins/sanparks/index.jsp
40 40
        </script>
41 41
        
42 42
        <!-- Main content -->
43
        <jsp:include page="SaeonLogin.jspx" />
43
        <jsp:include page="sanparksLogin.jsp" />
44 44
        
45 45
        <!-- wrap it up with the closing -->
46 46
        <script language="JavaScript">
lib/style/skins/sanparks/sanparks.xml
12 12
    <target publicid="-//W3C//HTML//EN">/style/common/scheduledWorkflowResultset.xsl</target>
13 13
  </doctype>
14 14

  
15
  <!-- doctype publicid="-//NCEAS//login//EN">
16
    <target publicid="-//W3C//HTML//EN">/style/skins/sanparks/knp-login.xsl</target>
17
  </doctype -->
15 18
  <doctype publicid="-//NCEAS//login//EN">
16
    <target publicid="-//W3C//HTML//EN">/style/skins/sanparks/knp-login.xsl</target>
19
    <target publicid="-//W3C//HTML//EN">/style/skins/sanparks/sanparksLogin.xsl</target>
17 20
  </doctype>
21
  <doctype publicid="-//NCEAS//logout//EN">
22
    <target publicid="-//W3C//HTML//EN">/style/skins/sanparks/sanparksLogin.xsl</target>
23
  </doctype>
18 24
  <doctype publicid="-//NCEAS//unauth_login//EN">
19 25
    <target publicid="-//W3C//HTML//EN">/style/skins/sanparks/knp-login.xsl</target>
20 26
  </doctype>
lib/style/skins/sanparks/sanparksLogin.js
1
 /*
2
  *   '$RCSfile$'
3
  *     Purpose: Default style sheet for SANPark project login pages 
4
  *              Using this stylesheet rather than placing styles directly in 
5
  *              the KNP web documents allows us to globally change the 
6
  *              formatting styles of the entire site in one easy place.
7
  *   Copyright: 2009 Regents of the University of California and the
8
  *               National Center for Ecological Analysis and Synthesis
9
  *     Authors: Matt Jones
10
  *
11
  *    '$Author: daigle $'
12
  *      '$Date: 2009-09-04 15:12:17 -0700 (Fri, 04 Sep 2009) $'
13
  *  '$Revision: 5057 $'
14
  *
15
  * This program is free software; you can redistribute it and/or modify
16
  * it under the terms of the GNU General Public License as published by
17
  * the Free Software Foundation; either version 2 of the License, or
18
  * (at your option) any later version.
19
  *
20
  * This program is distributed in the hope that it will be useful,
21
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
  * GNU General Public License for more details.
24
  *
25
  * You should have received a copy of the GNU General Public License
26
  * along with this program; if not, write to the Free Software
27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
  */
29

  
30
function submitLoginFormIntoDiv(servletUrl, formObj, divId) {
31

  
32
	//var formObj = document.getElementById(formId);
33
	var shortUserName = formObj.shortusername.value;
34
	//alert("starting userName: " + shortUserName);
35
	var organization = formObj.organization.value;
36
	//alert("organization: " + organization);
37
	formObj.username.value = createLdapString(shortUserName, organization);
38
	//alert("ending userName: " + formObj.username.value);
39
	var loggingInContent = "<table><tr><td width='600px' align='center'><p>logging in</p></td></tr></table>"
40
	document.getElementById(divId).innerHTML = loggingInContent;
41
	
42
	submitFormObjIntoDiv(servletUrl, formObj, divId);
43

  
44
}
45

  
46
function submitLogoutFormIntoDiv(servletUrl, formObj, divId) {
47
	var loggingOutContent = "<table><tr><td width='600px' align='center'><p>logging out</p></td></tr></table>"
48
	document.getElementById(divId).innerHTML = loggingOutContent;
49
	
50
	submitFormObjIntoDiv(servletUrl, formObj, divId);
51

  
52
}
53

  
54
function createLdapString(userName, organization) {
55
    var ldapTemplate = "uid=%1s,o=%2s,dc=ecoinformatics,dc=org";
56
    var tmp = ldapTemplate.replace("%1s", userName);
57
    var ldapUserName = tmp.replace("%2s", organization);
58
 
59
 	return ldapUserName;
60
}
61

  
0 62

  
lib/style/skins/sanparks/sanparks.js
92 92
// Location of the search box that will be displayed above the  
93 93
//  results on the results page (optional)
94 94
var SEARCHBOX_URL = "";  //= "searchform.html"
95
//var SEARCHBOX_URL = "style/skins/sanparks/SaeonLogin.jspx";
96 95

  
97 96
//  Location of the header that will be displayed at the top of the page
98 97
var LEFTCOL_URL = "style/skins/sanparks/leftnav.jsp";
lib/style/skins/sanparks/sanparksLogin.jsp
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<!-- to change the content type or response encoding change the following line -->
4
<%@page contentType="text/html"%>
5
<%@page pageEncoding="UTF-8"%>
6
<%@ page import="edu.ucsb.nceas.metacat.clientview.ClientView" %>
7
<%@ page import="edu.ucsb.nceas.metacat.clientview.ClientViewHelper" %>
8
<%@ page import="edu.ucsb.nceas.metacat.clientview.ClientHtmlHelper" %>
9
<%@ page import="edu.ucsb.nceas.metacat.service.SessionService" %>
10

  
11
<%@ include file="settings.jsp" %>
12

  
13
<% 	
14
    ClientViewHelper clientViewHelper = null;
15
%>
16

  
17
<html xmlns="http://www.w3.org/1999/xhtml">
18
<head>
19
	<title>SANParks - South African National Park Data Repository</title>
20
	<link rel="stylesheet" type="text/css" href="<%= CONTEXT_URL %>/style/skins/sanparks/sanparks.css"/>
21
	<script language="JavaScript" type="text/JavaScript" src="<%=STYLE_COMMON_URL%>/prototype-1.5.1.1/prototype.js"></script>
22
	<script language="JavaScript" type="text/JavaScript" src="<%=STYLE_COMMON_URL%>/ajax-utils.js"></script>
23
	<script language="JavaScript" type="text/JavaScript" src="<%=STYLE_SKINS_URL%>/sanparks/sanparksLogin.js"></script>
24
</head>
25
	
26
<body>
27
	<div class="templatecontentareaclass" style="background: #FFFFFF;">
28
	<jsp:useBean id="clientViewBean" scope="session" class="edu.ucsb.nceas.metacat.clientview.ClientView" /> 
29
	<jsp:setProperty name="clientViewBean" property="*" /> 
30
	<% clientViewHelper = ClientViewHelper.clientViewHelperInstance(request); %>
31
		
32
	<table>
33
	<tr>
34
		<td colspan="3">
35
			<p class="regtext">
36
			Welcome to the SANParks Data Repository. 
37
			This is the primary source for comprehensive information about scientific 
38
			and research data sets collected throughout the South African National Park System.
39
			</p>
40
		</td>
41
	</tr>
42
	<tr valign="top">
43
	<td>
44
	
45
	<h2>Search for SANParks Data</h2>
46
	
47
	<p class="emphasis">Searching: 
48
		<%
49
			String organizationScope = request.getParameter("organizationScope");
50
			if (organizationScope == null) {
51
				organizationScope = "";
52
			}
53
			if (!organizationScope.equals("")) {
54
		%>
55
			<!-- set the map to use the correct scope -->
56
			<script type="text/javascript" >
57
				var dropDownTimer = null;
58
				
59
				//this syncs the map based on the input string location
60
				function setMapLocation(strLocation) {
61
				
62
					var mapFrameDocument = document.getElementById("mapFrame").contentDocument;
63
					if (!mapFrameDocument) {
64
						//alert("IE");
65
						mapFrameDocument = document.getElementById("mapFrame").contentWindow;
66
						if (mapFrameDocument.document) {
67
							mapFrameDocument = mapFrameDocument.document;
68
						}
69
						
70
					}
71
					//alert("mapFrame=" + mapFrameDocument.name);
72
					//alert("locations=" + mapFrameDocument.getElementsByTagName('locations'));
73
					
74
					//check if the dropdown is loaded in DOM
75
					if (mapFrameDocument.getElementsByName('locations').length == 0) {
76
						dropDownTimer = setTimeout("setMapLocation('" + strLocation + "')", 100);
77
						return false;
78
					}
79
					clearTimeout(dropDownTimer);
80
					
81
					var locationMenu = mapFrameDocument.getElementsByName('locations')[0];
82
					//alert("locationMenu=" + locationMenu);
83
					var locationOptions = locationMenu.options;
84
					//alert("locationOptions=" + locationOptions);
85
					//loop through the options to find the correct location based on input string
86
					for (var i=0; i &lt; locationOptions.length; i++) {
87
						if (locationOptions[i].text == strLocation) {
88
							//set as selected
89
							locationMenu.selectedIndex = i;
90
							break;
91
						}
92
					}
93
					//alert("Focusing on selected location: " + locationMenu.options[locationMenu.selectedIndex].text);
94
					
95
					//the onchange command from select object
96
					locationMenu.onchange();
97
					//mapFrameDocument.config.objects.locationsSelect.setAoi(locationMenu.options[locationMenu.selectedIndex].value,'mainMap');
98
				
99
				}
100
				
101
				//kick it off
102
				dropDownTimer = 
103
					setTimeout(
104
					"setMapLocation('<%= organizationScope %>')",
105
					 100);
106
				
107
			</script>
108
			
109
			<%= organizationScope %>
110
		<%
111
			} else {
112
		%>
113
			All Organizations	
114
		<%
115
			}
116
		%>
117
	</p>
118
	
119
	<form id="searchform" name="searchform" method="post" 
120
			action="<%= SERVLET_URL %>" target="_top"
121
			onsubmit="setQueryFormField()">
122
		<p class="regtext">
123
		The repository search system is used to locate data sets of interest by 
124
		searching through existing registered data sets. 
125
		Presently the search covers all fields, including author, title, abstract, 
126
		keywords, and other documentation for each data set. 
127
		<br />
128
		Use a '%' symbol as a wildcard in searches (e.g., '%herbivore%' 
129
		would locate any phrase with the word herbivore embedded within it).
130
		</p>
131
		<input name="organizationScope" id="organizationScope" type="hidden" value="organizationScope" />
132
		<input name="sessionid" id="sessionid" type="hidden" value="<%= request.getSession().getId() %>" />
133
		<input name="anyfield" type="text" id="anyfield" value="" size="14" />
134
		<input name="query" type="hidden" id="query" />
135
		<input name="qformat" type="hidden" value="sanparks"/>
136
		<input name="action" type="hidden" value="squery" />  
137
		<input type="submit" value="Search"  />
138
		<br/>
139
		<input type="checkbox" id="searchAll" name="searchAll" />Search all fields (slower)
140
		<p class="regtext">
141
		-Or-
142
		<br />
143
		Browse all existing data sets by title. This operation can be slow.
144
		</p>
145
		<input type="button" value="Browse All" onclick="setBrowseAll();form.submit()" />
146
	</form>
147
	
148
	</td>
149
	<td>
150
	
151
	<div id="loginSection">
152
<%
153
	if (!clientViewHelper.isLoggedIn()) {
154
%>
155
		<h3>Login
156
		<a href="<%= CONTEXT_URL %>/cgi-bin/ldapweb.cgi?cfg=sanparks" target="_new" />
157
		<span class="regtext"> (request an account...)</span>
158
		</h3>
159
		<form name="loginForm" id="loginForm" onsubmit="submitLoginFormIntoDiv('<%= SERVLET_URL %>', this, 'loginSection')">
160
		  <input name="qformat" type="hidden" value="sanparks" />
161
		  <input name="action" type="hidden" value="login"/>
162
		  <table>
163
		    <tr valign="top">
164
		      <td><span class="required">User name</span></td>
165
		      <td><input name="shortusername" type="text" value="" style="width: 140" /></td>
166
		      <td><input name="username" type="hidden" value="" /></td>
167
		    </tr>
168
		    <tr>
169
		      <td><span class="required">Organization</span></td>
170
		      <td><select name="organization" style="width: 140">
171
		            <option value="SANParks" selected="">SANParks</option>
172
		            <option value="SAEON">SAEON</option>
173
		            <option value="NCEAS">NCEAS</option>
174
		            <option value="unaffiliated">unaffiliated</option>
175
		          </select></td>
176
		    </tr>
177
		    <tr>
178
		      <td><span class="required">Password</span></td>
179
		      <td><input name="password" value="" type="password" style="width: 140" maxlength="50" /></td>
180
		    </tr>
181
		    <tr>
182
		      <td colspan="2" align="center">
183
		        <input name="loginSubmit" value="login" type="submit" class="button_login" />
184
		      </td>
185
		    </tr>
186
		  </table>
187
		</form>
188
<%
189
	} else {
190
%>
191
		<h3>Welcome,<%= clientViewBean.getUsername() %></h3>
192
		<form name="logoutForm" id="logoutForm" onsubmit="submitLogoutFormIntoDiv('<%= SERVLET_URL %>', this, 'loginSection')">
193
		  <input name="qformat" value="sanparks" type="hidden" />
194
		  <input name="action" type="hidden" value="logout"/>
195
		  <table>
196
			   <tr valign="top">
197
			     <td><p class="regtext">You are currently logged in.</p></td>
198
			     <td align="right"><input name="action" type="submit" value="logout" class="button_login" /></td>
199
			   </tr>
200
		    <tr valign="top">
201
		      <td colspan="2" width="600px"><p class="regtext"></p></td>
202
		      <!--  td colspan="2">< p class="regtext">(< % = clientViewBean.getMessage(ClientView.LOGIN_MESSAGE) % >)< / p ></td -->
203
			</tr>
204
			<tr>	
205
			   <td colspan="2" class="regtext" align="center" valign="top">		
206
		      <!-- reset pass -->
207
		        <a href="<%= CGI_URL %>/ldapweb.cgi?cfg=sanparks&amp;stage=resetpass" target="_parent">
208
		          reset your password
209
		        </a>
210
		        |
211
		        <!-- change pass -->
212
		        <a href="<%= CGI_URL %>/ldapweb.cgi?cfg=sanparks&amp;stage=changepass" target="_parent">
213
		          change your password
214
		        </a>
215
		      </td>
216
		    </tr>
217
		  </table>
218
		</form>
219
<%		
220
	}
221
%>
222
	
223
	<!-- File Upload Form --> 
224
	<br />
225
	<h3>Data Package Upload</h3>
226
	
227
	<%
228
		if (clientViewHelper.isLoggedIn()) {
229
	%>
230
	<table width="100%">
231
		<tr valign="top">
232
			<td align="right">
233
				<form method="post" action="<%= CONTEXT_URL %>/style/skins/sanparks/upload.jsp">
234
					<input type="submit" value="Go >" class="button_login" />
235
				</form>
236
			</td>
237
		</tr>
238
	</table>			
239
	<%
240
		} else {
241
	%>
242
	
243
	<p class="regtext">
244
		You must be logged into your user account before uploading a data set.
245
	</p>
246
	<%
247
		}
248
	%>
249
	
250
	</div>
251
	</td>
252
	
253
	<!-- so the map frame doesn't overlap content -->
254
	<td width="50px"></td>
255
	
256
	</tr>
257
	
258
	<tr>
259
	<td colspan="2" align="center">
260
	
261
	
262
	<!-- Map here --> 
263
	<br />
264
	<h3>Spatial Search</h3>
265
	
266
		<!-- map frame -->
267
        <script language="JavaScript">
268
            insertMap("<%= CONTEXT_URL %>");
269
        </script>
270
	</td>
271
	
272
	<!-- so the map frame doesn't overlap content -->
273
	<td width="50px"></td>
274
	
275
	</tr>
276
	
277
	</table>
278
	
279
	</div>
280
</body>
281
</html>
0 282

  
src/edu/ucsb/nceas/metacat/MetaCatServlet.java
932 932
				PrintWriter out = response.getWriter();
933 933
				handleGetAccessControlAction(out, params, response, userName, groupNames);
934 934
				out.close();
935
			} else if (action.equals("isauthorized")) {
936
				PrintWriter out = response.getWriter();
937
				DocumentUtil.isAuthorized(out, params, request, response);
938
				out.close();
935 939
			} else if (action.equals("getprincipals")) {
936 940
				PrintWriter out = response.getWriter();
937 941
				handleGetPrincipalsAction(out, userName, password);
......
1081 1085
				PrintWriter out = response.getWriter();
1082 1086
				out.println("<?xml version=\"1.0\"?>");
1083 1087
				out.println("<error>");
1084
				out.println("Error: action not registered.  Please report this error.");
1088
				out.println("Error: action: " + action + " not registered.  Please report this error.");
1085 1089
				out.println("</error>");
1086 1090
				out.close();
1087 1091
			}
......
1325 1329
        String pw = (params.get("password"))[0];
1326 1330
        
1327 1331
        String qformat = "xml";
1328
        if(params.get("qformat") != null){
1332
        if (params.get("qformat") != null) {
1329 1333
            qformat = (params.get("qformat"))[0];
1330 1334
        }
1331 1335
        
......
1344 1348
        if (isValid) {
1345 1349
            HttpSession session = sess.getSessions();
1346 1350
            String id = session.getId();
1351
            
1347 1352
            logMetacat.debug("Store session id " + id
1348 1353
                    + " which has username" + session.getAttribute("username")
1349 1354
                    + " into hash in login method");
1350 1355
            try {
1351
				SessionService.registerSession(id, (String) session
1352
						.getAttribute("username"), (String[]) session
1353
						.getAttribute("groupnames"), (String) session
1354
						.getAttribute("password"));
1356
				SessionService.registerSession(id, 
1357
						(String) session.getAttribute("username"), 
1358
						(String[]) session.getAttribute("groupnames"), 
1359
						(String) session.getAttribute("password"), 
1360
						(String) session.getAttribute("name"));
1355 1361
			} catch (ServiceException se) {
1356 1362
				String errorMsg = "MetacatServlet.handleLoginAction()- service problem registering session: "
1357 1363
						+ se.getMessage();
1358 1364
				logMetacat.error(errorMsg);
1359 1365
				out.println(errorMsg);
1360 1366
				return;
1361
			} 
1362
//			catch (PropertyNotFoundException pnfe) {
1363
//				String errorMsg = "MetacatServlet.handleLoginAction() - problem getting application context: "
1364
//					+ pnfe.getMessage();
1365
//				logMetacat.error(errorMsg);
1366
//				out.println(errorMsg);
1367
//				return;
1368
//			}
1369
			
1367
			} 			
1370 1368
        }
1371
        
1369
                
1372 1370
        // format and transform the output
1373 1371
        if (qformat.equals("xml")) {
1374 1372
            response.setContentType("text/xml");
src/edu/ucsb/nceas/metacat/clientview/ClientViewHelper.java
19 19
import edu.ucsb.nceas.metacat.client.MetacatFactory;
20 20
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
21 21
import edu.ucsb.nceas.metacat.properties.PropertyService;
22
import edu.ucsb.nceas.metacat.service.SessionService;
23
import edu.ucsb.nceas.metacat.util.RequestUtil;
24
import edu.ucsb.nceas.metacat.util.SessionData;
22 25
import edu.ucsb.nceas.utilities.XMLUtilities;
23 26
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
24 27
import java.io.BufferedReader;
......
34 37
import java.util.Stack;
35 38
import java.util.TreeMap;
36 39
import java.util.Vector;
40
import javax.servlet.http.Cookie;
37 41
import javax.servlet.http.HttpServletRequest;
38 42
import javax.servlet.http.HttpServletResponse;
39 43
import javax.servlet.http.HttpSession;
......
78 82
    public ClientViewHelper(HttpServletRequest request) throws MetacatInaccessibleException {
79 83
        String                              host, context;
80 84
        
81
        clientSession = request.getSession();
85
        clientSession = request.getSession(false);
82 86
        host = request.getHeader("host");
83 87
        context = request.getContextPath();
84 88
        init(host, context);
......
122 126
    public String clientRequest(HttpServletRequest request, HttpServletResponse response)  {
123 127
        String                              result = null, action, contentType;
124 128
        MultipartParser                     multipartParser;
125
        HashMap                             responseMap;
129
        HashMap<String, String>             responseMap;
126 130
        
131
        getMetacatClient().setSessionId(request.getSession().getId());
132
        
127 133
        if (clientViewBean == null) {
128 134
            clientViewBean = (ClientView) clientSession.getAttribute(ClientView.CLIENT_VIEW_BEAN);
129 135
            
......
159 165
                    responseMap = handleClientRequest(null);
160 166
                    //*** Now that the action has been processed, clear it.
161 167
                    clientViewBean.setAction("");
168
                    if (isLoggedIn()) {
169
//                    	HttpSession session = request.getSession(false);                 	
170
//                    	session.setAttribute("ClientViewHelper", this);
171
                    	Cookie jSessionCookie = new Cookie("JSESSIONID", clientViewBean.getSessionid());
172
                    	response.addCookie(jSessionCookie);
173
                    }
162 174
                } else if (action.equals("Logout")) {
163 175
                    responseMap = handleClientRequest(null);
164 176
                    clientViewBean.setAction("");
......
168 180
                        multipartParser = new MultipartParser(request, sizeLimit * 1024 * 1024);
169 181
                        responseMap = handleClientRequest(multipartParser);
170 182
                    } catch (IOException ex) {
171
                        responseMap = new HashMap();
183
                        responseMap = new HashMap<String, String>();
172 184
                        responseMap.put("message", ex.getMessage());
173 185
                    }
174 186
                    clientViewBean.setAction("");
......
177 189
                    try {
178 190
                        handleDownloadResponse(responseMap, response);
179 191
                    } catch (IOException ex) {
180
                        responseMap = new HashMap();
192
                        responseMap = new HashMap<String, String>();
181 193
                        responseMap.put("message", ex.getMessage());
182 194
                    }
183 195
                    
......
206 218
     * the action is Download, than this will contain all needed values
207 219
     * to pass to handleDownloadResponse.
208 220
     */
209
    public HashMap handleClientRequest(MultipartParser multipartParser)  {
221
    public HashMap<String, String> handleClientRequest(MultipartParser multipartParser)  {
210 222
        String                              result = "", serverResponse;
211
        String                              button, posted_ldapUserName, tmp, action;
212
        HashMap                             responseMap = new HashMap();
213
        int                                 fileIdx;
223
        String                              posted_ldapUserName, tmp, action;
224
        HashMap<String, String>             responseMap = new HashMap<String, String>();
214 225
        
215 226
        
216 227
        if (clientViewBean != null) {
......
221 232
                        tmp = LDAP_TEMPLATE.replaceFirst("%1s", clientViewBean.getUsername());
222 233
                        posted_ldapUserName = tmp.replaceFirst("%2s", clientViewBean.getOrganization());
223 234
                        
235
//                        if (metacatSessionId != null) {
236
//                        	metacatClient.setSessionId(metacatSessionId);
237
//                        }                       
224 238
                        serverResponse = metacatClient.login(posted_ldapUserName, clientViewBean.getPassword());
225 239
                        setLoggedIn(serverResponse);
226 240
                        result = parseXml("message", serverResponse);
......
229 243
                        clientViewBean.setMessage(ClientView.UPLOAD_MESSAGE, "");
230 244
                        if (isLoggedIn()) {
231 245
                            clientViewBean.setSessionid(metacatClient.getSessionId());
246
                            
232 247
                        }
233 248
                    } else if (action.equals("Logout")) {
234 249
                        result = metacatClient.logout();
......
294 309
     * @return ClientViewHelper instance.
295 310
     */
296 311
    public static ClientViewHelper clientViewHelperInstance(HttpServletRequest request) {
297
        ClientViewHelper                        result;
312
        ClientViewHelper result;
298 313
        
314
        String sessionId = request.getSession(false).getId();
315
        
299 316
        result = (ClientViewHelper) request.getSession().getAttribute("ClientViewHelper");
300 317
        if (result == null) {
301 318
            try {
......
306 323
            }
307 324
        }
308 325
        
326
        if (result.clientViewBean == null) {
327
        	result.clientViewBean = (ClientView) request.getSession().getAttribute(ClientView.CLIENT_VIEW_BEAN);
328
            
329
            if (result.clientViewBean == null) {
330
            	//make a new one and shove it in the session
331
            	result.clientViewBean = new ClientView();
332
            	request.getSession().setAttribute(ClientView.CLIENT_VIEW_BEAN, result.clientViewBean);
333
            }
334
        }
335
        
336
        boolean oldLoginValue = result.loggedIn;
337
        result.setLoggedIn(SessionService.validateSession(sessionId));
338
        if (result.isLoggedIn()) {
339
        	SessionData sessionData = SessionService.getRegisteredSession(sessionId);
340
        	result.setUserName(sessionData.getName());
341
        }
342
        
343
        if (!oldLoginValue || result.loggedIn) {
344
        	result.clientViewBean.setMessage(ClientView.UPLOAD_MESSAGE, "");
345
        }
346
        
309 347
        return(result);
310 348
    }
311 349
    
......
331 369
        loggedIn = (serverResponse != null && serverResponse.indexOf("login") > -1);
332 370
    }
333 371
    
372
    public void setLoggedIn(boolean isLoggedIn) {
373
        this.loggedIn = isLoggedIn;
374
    }
375
    
376
    public void setUserName(String userName) {
377
        clientViewBean.setUsername(userName);
378
    }
379
    
334 380
    public String parseXml(String elementName, String xml) {
335 381
        String                      result = null;
336 382
        Document                    doc;
......
979 1025
        return(result);
980 1026
    }
981 1027
    
982
    private HashMap download(ClientView bean) {
1028
    private HashMap<String, String> download(ClientView bean) {
983 1029
        Properties                      args;
984 1030
        InputStream                     inStream;
985 1031
        String                          docId, metaId, fNm = null, pth, txtLst[];
......
987 1033
        Node                            branchRoot, metaRoot;
988 1034
        ByteArrayOutputStream           outStream;
989 1035
        int                             intMe;
990
        HashMap                         responseMap = new HashMap();
1036
        HashMap<String, String>         responseMap = new HashMap<String, String>();
991 1037
        
992 1038
        docId = bean.getDocId();
993 1039
        metaId = bean.getMetaFileDocId();
......
1066 1112
                }
1067 1113
                
1068 1114
                //*** Now, write the output stream to the response.
1069
                responseMap.put("outputStream", outStream);
1115
                responseMap.put("outputStream", outStream.toString());
1070 1116
                
1071 1117
                //*** Finally, set the message for the user interface to display.
1072 1118
                msg = msg.replaceFirst("~", fNm);

Also available in: Unified diff