Revision 6543
Added by ben leinfelder about 13 years ago
lib/style/skins/dataone/performMapping.jsp | ||
---|---|---|
1 |
<%@ page language="java"%> |
|
2 |
<% |
|
3 |
/** |
|
4 |
* '$RCSfile$' |
|
5 |
* Authors: Matt Jones |
|
6 |
* Copyright: 2008 Regents of the University of California and the |
|
7 |
* National Center for Ecological Analysis and Synthesis |
|
8 |
* For Details: http://www.nceas.ucsb.edu/ |
|
9 |
* |
|
10 |
* '$Author$' |
|
11 |
* '$Date$' |
|
12 |
* '$Revision$' |
|
13 |
* |
|
14 |
* This is an HTML document for loading an xml document into Oracle |
|
15 |
* |
|
16 |
* This program is free software; you can redistribute it and/or modify |
|
17 |
* it under the terms of the GNU General Public License as published by |
|
18 |
* the Free Software Foundation; either version 2 of the License, or |
|
19 |
* (at your option) any later version. |
|
20 |
* |
|
21 |
* This program is distributed in the hope that it will be useful, |
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24 |
* GNU General Public License for more details. |
|
25 |
* |
|
26 |
* You should have received a copy of the GNU General Public License |
|
27 |
* along with this program; if not, write to the Free Software |
|
28 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
29 |
*/ |
|
30 |
%> |
|
31 |
<%@page import="edu.ucsb.nceas.metacat.service.SessionService"%> |
|
32 |
<%@page import="org.dataone.client.D1Client"%> |
|
33 |
<%@page import="java.net.URL"%> |
|
34 |
<%@page import="java.io.InputStream"%> |
|
35 |
<%@page import="org.apache.commons.io.IOUtils"%> |
|
36 |
<%@page import="org.dataone.service.types.v1.Subject"%> |
|
37 |
<%@page import="org.dataone.service.types.v1.Session"%> |
|
38 |
<%@page import="edu.ucsb.nceas.metacat.dataone.MNodeService"%> |
|
39 |
<% |
|
40 |
|
|
41 |
boolean success = false; |
|
42 |
|
|
43 |
//gather the input |
|
44 |
String primarySubject = null; // retrieved from portal service |
|
45 |
String secondarySubject = request.getParameter("secondarySubject"); |
|
46 |
String token = request.getParameter("token"); |
|
47 |
|
|
48 |
// check the metacat session |
|
49 |
String sessionId = request.getParameter("sessionid"); |
|
50 |
if (sessionId == null) { |
|
51 |
sessionId = request.getSession().getId(); |
|
52 |
} |
|
53 |
boolean isMetacatSessionValid = SessionService.getInstance().validateSession(sessionId); |
|
54 |
|
|
55 |
// TODO: dynamic portal lookup |
|
56 |
//String cnURL = D1Client.getCN().getNodeBaseServiceUrl(); |
|
57 |
//String portalURL = cnURL.substring(0, cnURL.lastIndexOf(new URL(cnURL).getPath())) + "/portal/identity"; |
|
58 |
String portalURL = "https://cn-dev.dataone.org/portal/identity"; |
|
59 |
|
|
60 |
//check the DataONE token |
|
61 |
String tokenURL = portalURL + "?action=isAuthenticated&token=" + token; |
|
62 |
InputStream tokenInputStream = new URL(tokenURL).openStream(); |
|
63 |
String tokenContent = IOUtils.toString(tokenInputStream, "UTF-8"); |
|
64 |
boolean isD1SessionValid = Boolean.parseBoolean(tokenContent); |
|
65 |
|
|
66 |
// look up the D1 subject |
|
67 |
String subjectURL = portalURL + "?action=getSubject&token=" + token; |
|
68 |
InputStream subjectStream = new URL(subjectURL).openStream(); |
|
69 |
primarySubject = IOUtils.toString(subjectStream, "UTF-8"); |
|
70 |
|
|
71 |
// call the mapping method as the MN |
|
72 |
if (isMetacatSessionValid && isD1SessionValid) { |
|
73 |
Session mnSession = new Session(); |
|
74 |
mnSession.setSubject(MNodeService.getInstance(request).getCapabilities().getSubject(0)); |
|
75 |
// TODO: set up the certificate for this node |
|
76 |
Subject s1 = new Subject(); |
|
77 |
s1.setValue(primarySubject); |
|
78 |
Subject s2 = new Subject(); |
|
79 |
s2.setValue(secondarySubject); |
|
80 |
|
|
81 |
success = D1Client.getCN().mapIdentity(mnSession, s1, s2); |
|
82 |
} |
|
83 |
|
|
84 |
if (success) { |
|
85 |
%> |
|
86 |
Mapping set from <%=primarySubject %> to <%=secondarySubject %> |
|
87 |
<% |
|
88 |
} |
|
89 |
%> |
|
0 | 90 |
lib/style/skins/dataone/dataone.css | ||
---|---|---|
1 |
/***** Begin the "DataONE" header at the top of each page *****/ |
|
2 |
div.logoheader { |
|
3 |
background: transparent url("images/preface-wrapper-bg.png") repeat-x top left; |
|
4 |
height: 101px; |
|
5 |
} |
|
6 |
div.logoheader h1 { |
|
7 |
background: transparent url("images/logo.png") no-repeat top left; |
|
8 |
margin: 10px 9px; |
|
9 |
width: 333px; |
|
10 |
height: 77px; |
|
11 |
float: left; |
|
12 |
} |
|
13 |
/***** End the "DataONE" header at the top of each page *****/ |
|
14 |
|
|
15 |
td.label { |
|
16 |
width: 150px; |
|
17 |
} |
|
18 |
|
|
0 | 19 |
lib/style/skins/dataone/index.jsp | ||
---|---|---|
1 |
<%@ page language="java"%> |
|
2 |
<% |
|
3 |
/** |
|
4 |
* '$RCSfile$' |
|
5 |
* Authors: Matt Jones |
|
6 |
* Copyright: 2008 Regents of the University of California and the |
|
7 |
* National Center for Ecological Analysis and Synthesis |
|
8 |
* For Details: http://www.nceas.ucsb.edu/ |
|
9 |
* |
|
10 |
* '$Author$' |
|
11 |
* '$Date$' |
|
12 |
* '$Revision$' |
|
13 |
* |
|
14 |
* This is an HTML document for loading an xml document into Oracle |
|
15 |
* |
|
16 |
* This program is free software; you can redistribute it and/or modify |
|
17 |
* it under the terms of the GNU General Public License as published by |
|
18 |
* the Free Software Foundation; either version 2 of the License, or |
|
19 |
* (at your option) any later version. |
|
20 |
* |
|
21 |
* This program is distributed in the hope that it will be useful, |
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24 |
* GNU General Public License for more details. |
|
25 |
* |
|
26 |
* You should have received a copy of the GNU General Public License |
|
27 |
* along with this program; if not, write to the Free Software |
|
28 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
29 |
*/ |
|
30 |
%> |
|
31 |
|
|
32 |
<%@ include file="../../common/common-settings.jsp"%> |
|
33 |
<%@ include file="../../common/configure-check.jsp"%> |
|
34 |
<%@page import="edu.ucsb.nceas.metacat.service.SessionService"%> |
|
35 |
<% |
|
36 |
|
|
37 |
// what was the given DataONE identity? |
|
38 |
String d1Identity = request.getParameter("d1Identity"); |
|
39 |
String token = request.getParameter("token"); |
|
40 |
|
|
41 |
// look up the username from the given session |
|
42 |
String sessionId = request.getParameter("sessionId"); |
|
43 |
if (sessionId == null) { |
|
44 |
sessionId = request.getSession().getId(); |
|
45 |
} |
|
46 |
if (sessionId == null) { |
|
47 |
// redirect to the login page |
|
48 |
response.sendRedirect(STYLE_SKINS_URL + "/dev/login.html"); |
|
49 |
return; |
|
50 |
} |
|
51 |
String userName = SessionService.getInstance().getRegisteredSession(sessionId).getUserName(); |
|
52 |
%> |
|
53 |
|
|
54 |
<html> |
|
55 |
<head> |
|
56 |
<title>Map legacy account to DataONE</title> |
|
57 |
|
|
58 |
<link rel="stylesheet" type="text/css" href="<%=STYLE_COMMON_URL%>/jquery/jqueryui/css/smoothness/jquery-ui-1.8.6.custom.css"> |
|
59 |
<link rel="stylesheet" type="text/css" href="dataone.css" /> |
|
60 |
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/jquery/jquery.js"></script> |
|
61 |
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/jquery/jqueryui/js/jquery-ui-1.8.6.custom.min.js"></script> |
|
62 |
<script type="text/javascript"> |
|
63 |
var portalURL = "https://cn-dev.dataone.org/portal/identity"; |
|
64 |
|
|
65 |
function lookupToken() { |
|
66 |
var data = $('#tokenFrame').contents(); |
|
67 |
$('#mapForm [name="token"]').val(data); |
|
68 |
alert('Loaded token: ' + data); |
|
69 |
|
|
70 |
|
|
71 |
} |
|
72 |
function lookupSubject() { |
|
73 |
var subjectFrame = $('#subjectFrame'); |
|
74 |
var data = $('#subjectFrame').val(); |
|
75 |
$('#mapForm [name="primarySubject"]').val(data); |
|
76 |
alert('Loaded subject: ' + data); |
|
77 |
} |
|
78 |
function initTabs() { |
|
79 |
$(function() { |
|
80 |
$("#tabs").tabs(); |
|
81 |
$("#tabs").tabs("add", "#mapping", "Legacy account mapping"); |
|
82 |
}); |
|
83 |
} |
|
84 |
function init() { |
|
85 |
initTabs(); |
|
86 |
//lookupToken(); |
|
87 |
//lookupSubject(); |
|
88 |
} |
|
89 |
</script> |
|
90 |
|
|
91 |
</head> |
|
92 |
<body onload="init()"> |
|
93 |
<!-- dataone logo header --> |
|
94 |
<div class="logoheader"> |
|
95 |
<h1></h1> |
|
96 |
</div> |
|
97 |
|
|
98 |
<div id="tabs"> |
|
99 |
<!-- place holder for tabs --> |
|
100 |
<ul></ul> |
|
101 |
|
|
102 |
<div id="mapping"> |
|
103 |
<p>Connect your old account to your new DataONE identity</p> |
|
104 |
|
|
105 |
Your current Metacat account: |
|
106 |
<div> |
|
107 |
<%=userName %> |
|
108 |
</div> |
|
109 |
<br/> |
|
110 |
Will be mapped to: |
|
111 |
<iframe id="subjectFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="https://cn-dev.dataone.org/portal/identity?action=getSubject"> |
|
112 |
</iframe> |
|
113 |
|
|
114 |
<form action="performMapping.jsp" target="right" method="POST" id="mapForm"> |
|
115 |
|
|
116 |
Simply paste in The DataONE Token you see below and submit the form |
|
117 |
<br/> |
|
118 |
<input type="text" name="token" size="50"> |
|
119 |
<input type="hidden" name="secondarySubject" value="<%=userName %>"> |
|
120 |
<input type="hidden" name="action" value="mapIdentity"> |
|
121 |
<input type="submit" value="Map Identity"> |
|
122 |
</form> |
|
123 |
|
|
124 |
DataONE Token: |
|
125 |
<iframe id="tokenFrame" frameborder="0" marginwidth="0" height="30" width="100%" src="https://cn-dev.dataone.org/portal/identity?action=getToken"> |
|
126 |
</iframe> |
|
127 |
<br/> |
|
128 |
</div> |
|
129 |
|
|
130 |
</div> |
|
131 |
</body> |
|
132 |
</html> |
|
0 | 133 |
Also available in: Unified diff
draft of legacy-to-d1 account mapping interface