Project

General

Profile

1 6543 leinfelder
<%@ page language="java"%>
2 7390 leinfelder
<%@page import="org.dataone.client.D1Client"%>
3
<%@page import="java.net.URL"%>
4 6543 leinfelder
<%
5
	/**
6
	 *  '$RCSfile$'
7
	 *      Authors: Matt Jones
8
	 *    Copyright: 2008 Regents of the University of California and the
9
	 *               National Center for Ecological Analysis and Synthesis
10
	 *  For Details: http://www.nceas.ucsb.edu/
11
	 *
12
	 *   '$Author$'
13
	 *     '$Date$'
14
	 * '$Revision$'
15
	 *
16
	 * This is an HTML document for loading an xml document into Oracle
17
	 *
18
	 * This program is free software; you can redistribute it and/or modify
19
	 * it under the terms of the GNU General Public License as published by
20
	 * the Free Software Foundation; either version 2 of the License, or
21
	 * (at your option) any later version.
22
	 *
23
	 * This program is distributed in the hope that it will be useful,
24
	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
	 * GNU General Public License for more details.
27
	 *
28
	 * You should have received a copy of the GNU General Public License
29
	 * along with this program; if not, write to the Free Software
30
	 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31
	 */
32
%>
33
34
<%@ include file="../../common/common-settings.jsp"%>
35
<%@ include file="../../common/configure-check.jsp"%>
36
<%@page import="edu.ucsb.nceas.metacat.service.SessionService"%>
37
<%
38
39 7390 leinfelder
//get the CN environment, dynamically
40
String cnURL = D1Client.getCN().getNodeBaseServiceUrl();
41
String portalURL = cnURL.substring(0, cnURL.lastIndexOf(new URL(cnURL).getPath())) + "/portal";
42
//String portalURL =  "https://cn.dataone.org/portal";
43
44 6543 leinfelder
// what was the given DataONE identity?
45
String d1Identity = request.getParameter("d1Identity");
46
String token = request.getParameter("token");
47
48
// look up the username from the given session
49
String sessionId = request.getParameter("sessionId");
50
if (sessionId == null) {
51 6545 leinfelder
	if (request.getSession() != null) {
52
		sessionId = request.getSession().getId();
53
	}
54 6543 leinfelder
}
55 6545 leinfelder
if (sessionId == null || !SessionService.getInstance().isSessionRegistered(sessionId)) {
56 6543 leinfelder
	// redirect to the login page
57 7394 leinfelder
	response.sendRedirect(STYLE_SKINS_URL + "/dataone/login.jsp");
58 6543 leinfelder
	return;
59
}
60
String userName = SessionService.getInstance().getRegisteredSession(sessionId).getUserName();
61
%>
62
63
<html>
64
<head>
65
<title>Map legacy account to DataONE</title>
66
67
<link rel="stylesheet" type="text/css" href="<%=STYLE_COMMON_URL%>/jquery/jqueryui/css/smoothness/jquery-ui-1.8.6.custom.css">
68
<link rel="stylesheet" type="text/css" href="dataone.css" />
69
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/jquery/jquery.js"></script>
70
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/jquery/jqueryui/js/jquery-ui-1.8.6.custom.min.js"></script>
71
<script type="text/javascript">
72
73 7391 leinfelder
74
function makeAjaxCall(url, formId, divId, callback) {
75
	$('#' + divId).load(
76
		url, //url
77
		$("#" + formId).serialize(), //data
78
		function(response, status, xhr) {
79
			if (status == "error") {
80
				var msg = "Sorry but there was an error: ";
81
				$("#error").html(msg + response);
82
				$("#error").dialog('open');
83
			} else {
84
				// call the callback
85
				if (callback) {
86
					setTimeout(callback, 0);
87
				}
88
			}
89
		}
90
	);
91
}
92
function performMapping() {
93
	$('#mapForm [name="action"]').val('mapIdentity');
94
	makeAjaxCall(
95
			'performMapping.jsp',
96
			'mapForm',
97
			'result',
98
			function() { $("#result").dialog('open'); });
99
100
}
101 6543 leinfelder
function lookupToken() {
102
	var data = $('#tokenFrame').contents();
103
	$('#mapForm [name="token"]').val(data);
104
	alert('Loaded token: ' + data);
105
106
107
}
108
function lookupSubject() {
109
	var subjectFrame = $('#subjectFrame');
110
	var data = $('#subjectFrame').val();
111
	$('#mapForm [name="primarySubject"]').val(data);
112
	alert('Loaded subject: ' + data);
113
}
114 7391 leinfelder
function initDialogs() {
115
	// make the result section a dialog (popup)
116
	$("#result").dialog(
117
			{	autoOpen: false,
118
				title: "Results",
119
				width: 450
120
			}
121
		);
122
	$("#error").dialog(
123
			{	autoOpen: false,
124
				title: "Error",
125
				width: 450
126
			}
127
		);
128
}
129 6543 leinfelder
function initTabs() {
130
	$(function() {
131
		$("#tabs").tabs();
132
		$("#tabs").tabs("add", "#mapping", "Legacy account mapping");
133
	});
134
}
135
function init() {
136
	initTabs();
137 7391 leinfelder
	initDialogs();
138 6543 leinfelder
	//lookupToken();
139
	//lookupSubject();
140
}
141
</script>
142
143
</head>
144
<body onload="init()">
145
<!-- dataone logo header -->
146
<div class="logoheader">
147
	<h1></h1>
148
</div>
149
150 7391 leinfelder
<!-- load AJAX results here -->
151
<div id="result"></div>
152
<div id="error"></div>
153
154 6543 leinfelder
<div id="tabs">
155
	<!-- place holder for tabs -->
156
	<ul></ul>
157
158
	<div id="mapping">
159 7394 leinfelder
		<p>
160 7500 leinfelder
		Use this form to connect your old <i>ecoinformatics account</i> to your new <i>CILogon identity</i>.
161
		(<a href="<%=portalURL %>/index.jsp">register</a> with DataONE)
162 7394 leinfelder
		</p>
163
164 7500 leinfelder
		Your current ecoinformatics account (<a href="<%=SERVLET_URL %>?action=logout&qformat=dataone">switch</a> to another account):
165 6543 leinfelder
		<div>
166
		<%=userName %>
167
		</div>
168 7394 leinfelder
169 6543 leinfelder
		<br/>
170 6547 leinfelder
171 7500 leinfelder
		Will be mapped to this CILogon identity (<a href="<%=portalURL %>/startRequest?target=<%=STYLE_SKINS_URL%>/dataone/index.jsp">login</a>):
172
		<iframe style="body {font-weight: bold}" id="subjectFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="<%=portalURL %>/identity?action=getSubject">
173 6543 leinfelder
		</iframe>
174 7500 leinfelder
175 6547 leinfelder
		<hr/>
176
177 7500 leinfelder
		Enter this temporary token:
178 7390 leinfelder
		<iframe id="tokenFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="<%=portalURL %>/identity?action=getToken">
179 6547 leinfelder
		</iframe>
180
		<br/>
181
182 7391 leinfelder
		<form action="" method="POST" id="mapForm">
183 7500 leinfelder
			In the box below:
184 6543 leinfelder
			<br/>
185
			<input type="text" name="token" size="50">
186
			<input type="hidden" name="secondarySubject" value="<%=userName %>">
187
			<input type="hidden" name="action" value="mapIdentity">
188 7391 leinfelder
			<input type="button" value="Map Identity" onclick="performMapping()">
189 6543 leinfelder
		</form>
190 6547 leinfelder
191
		<hr/>
192
193 6543 leinfelder
	</div>
194
195
</div>
196
</body>
197
</html>