2823 |
31 Oct 06 |
nicklas |
1 |
<%-- $Id$ |
2823 |
31 Oct 06 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006, 2007 Nicklas Nordborg |
2823 |
31 Oct 06 |
nicklas |
4 |
|
2823 |
31 Oct 06 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
2823 |
31 Oct 06 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
2823 |
31 Oct 06 |
nicklas |
7 |
|
2823 |
31 Oct 06 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
2823 |
31 Oct 06 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
10 |
as published by the Free Software Foundation; either version 3 |
2823 |
31 Oct 06 |
nicklas |
11 |
of the License, or (at your option) any later version. |
2823 |
31 Oct 06 |
nicklas |
12 |
|
2823 |
31 Oct 06 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
2823 |
31 Oct 06 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2823 |
31 Oct 06 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2823 |
31 Oct 06 |
nicklas |
16 |
GNU General Public License for more details. |
2823 |
31 Oct 06 |
nicklas |
17 |
|
2823 |
31 Oct 06 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
4511 |
11 Sep 08 |
jari |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2823 |
31 Oct 06 |
nicklas |
20 |
------------------------------------------------------------------ |
2823 |
31 Oct 06 |
nicklas |
21 |
|
2823 |
31 Oct 06 |
nicklas |
22 |
@author Nicklas |
2823 |
31 Oct 06 |
nicklas |
23 |
@version 2.0 |
2823 |
31 Oct 06 |
nicklas |
24 |
--%> |
5426 |
24 Sep 10 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
3061 |
15 Jan 07 |
nicklas |
26 |
import="net.sf.basedb.core.Application" |
2823 |
31 Oct 06 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
2823 |
31 Oct 06 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
2823 |
31 Oct 06 |
nicklas |
29 |
import="net.sf.basedb.core.News" |
2823 |
31 Oct 06 |
nicklas |
30 |
import="net.sf.basedb.core.ItemQuery" |
2823 |
31 Oct 06 |
nicklas |
31 |
import="net.sf.basedb.core.ItemResultList" |
2823 |
31 Oct 06 |
nicklas |
32 |
import="net.sf.basedb.core.query.Orders" |
2823 |
31 Oct 06 |
nicklas |
33 |
import="net.sf.basedb.core.query.Hql" |
6426 |
27 Feb 14 |
nicklas |
34 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
7531 |
26 Nov 18 |
nicklas |
35 |
import="net.sf.basedb.util.extensions.ActionIterator" |
2823 |
31 Oct 06 |
nicklas |
36 |
import="net.sf.basedb.clients.web.Base" |
2823 |
31 Oct 06 |
nicklas |
37 |
import="net.sf.basedb.clients.web.util.HTML" |
6426 |
27 Feb 14 |
nicklas |
38 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
6426 |
27 Feb 14 |
nicklas |
39 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
8045 |
03 Jun 22 |
nicklas |
40 |
import="net.sf.basedb.clients.web.extensions.DynamicActionAttributeSupport" |
6426 |
27 Feb 14 |
nicklas |
41 |
import="net.sf.basedb.clients.web.extensions.login.LoginFormAction" |
7536 |
28 Nov 18 |
nicklas |
42 |
import="net.sf.basedb.clients.web.extensions.login.PasswordLoginFormFactory" |
6426 |
27 Feb 14 |
nicklas |
43 |
import="net.sf.basedb.clients.web.extensions.login.FieldInfo" |
2823 |
31 Oct 06 |
nicklas |
44 |
import="net.sf.basedb.util.Values" |
7531 |
26 Nov 18 |
nicklas |
45 |
import="java.util.Map" |
7531 |
26 Nov 18 |
nicklas |
46 |
import="java.util.TreeMap" |
2823 |
31 Oct 06 |
nicklas |
47 |
%> |
2823 |
31 Oct 06 |
nicklas |
48 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
6426 |
27 Feb 14 |
nicklas |
49 |
<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
6426 |
27 Feb 14 |
nicklas |
50 |
<%! |
6426 |
27 Feb 14 |
nicklas |
51 |
// If value is null, return "", else <prefix>+<value>+<suffix> |
6426 |
27 Feb 14 |
nicklas |
52 |
String valueIfNotNull(String prefix, String value, String suffix) |
6426 |
27 Feb 14 |
nicklas |
53 |
{ |
6426 |
27 Feb 14 |
nicklas |
54 |
return value == null ? "" : prefix+value+suffix; |
6426 |
27 Feb 14 |
nicklas |
55 |
} |
6426 |
27 Feb 14 |
nicklas |
56 |
%> |
2823 |
31 Oct 06 |
nicklas |
57 |
<% |
2823 |
31 Oct 06 |
nicklas |
58 |
final String login = Values.getString(request.getParameter("login"), ""); |
7531 |
26 Nov 18 |
nicklas |
59 |
final String requestedLoginForm = Values.getString(request.getParameter("loginForm"), null); |
2823 |
31 Oct 06 |
nicklas |
60 |
|
2823 |
31 Oct 06 |
nicklas |
61 |
final SessionControl sc = Base.getSessionControl(pageContext, true); |
2823 |
31 Oct 06 |
nicklas |
62 |
final String ID = sc.getId(); |
7954 |
12 May 21 |
nicklas |
63 |
final DbControl dc = sc.newDbControl(":Switch user"); |
2823 |
31 Oct 06 |
nicklas |
64 |
try |
2823 |
31 Oct 06 |
nicklas |
65 |
{ |
6426 |
27 Feb 14 |
nicklas |
66 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext); |
8045 |
03 Jun 22 |
nicklas |
67 |
jspContext.setNeedResourcesPerExtension(true); |
7605 |
26 Feb 19 |
nicklas |
68 |
ExtensionsInvoker<LoginFormAction> invoker = ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.login-form"); |
7531 |
26 Nov 18 |
nicklas |
69 |
|
6426 |
27 Feb 14 |
nicklas |
70 |
LoginFormAction loginAction = null; |
7531 |
26 Nov 18 |
nicklas |
71 |
String selectedLoginForm = null; |
8045 |
03 Jun 22 |
nicklas |
72 |
String selectedExtension = null; |
7531 |
26 Nov 18 |
nicklas |
73 |
Map<String, String> allForms = new TreeMap<String, String>(); |
7531 |
26 Nov 18 |
nicklas |
74 |
|
7531 |
26 Nov 18 |
nicklas |
75 |
ActionIterator<LoginFormAction> it = invoker.iterate(); |
7531 |
26 Nov 18 |
nicklas |
76 |
while (it.hasNext()) |
6426 |
27 Feb 14 |
nicklas |
77 |
{ |
7531 |
26 Nov 18 |
nicklas |
78 |
LoginFormAction action = it.next(); |
6426 |
27 Feb 14 |
nicklas |
79 |
if (action != null) |
6426 |
27 Feb 14 |
nicklas |
80 |
{ |
7531 |
26 Nov 18 |
nicklas |
81 |
String formId = action.getId(); |
7531 |
26 Nov 18 |
nicklas |
82 |
if (formId == null) formId = it.getExtension().getId(); |
7531 |
26 Nov 18 |
nicklas |
83 |
String displayName = action.getDisplayName(); |
7531 |
26 Nov 18 |
nicklas |
84 |
if (displayName == null) displayName = it.getExtension().getAbout().getName(); |
7531 |
26 Nov 18 |
nicklas |
85 |
allForms.put(formId, displayName); |
7531 |
26 Nov 18 |
nicklas |
86 |
|
7531 |
26 Nov 18 |
nicklas |
87 |
if (loginAction == null || formId.equals(requestedLoginForm)) |
7531 |
26 Nov 18 |
nicklas |
88 |
{ |
7531 |
26 Nov 18 |
nicklas |
89 |
loginAction = action; |
7531 |
26 Nov 18 |
nicklas |
90 |
selectedLoginForm = formId; |
8045 |
03 Jun 22 |
nicklas |
91 |
selectedExtension = it.getExtension().getId(); |
7531 |
26 Nov 18 |
nicklas |
92 |
} |
6426 |
27 Feb 14 |
nicklas |
93 |
} |
6426 |
27 Feb 14 |
nicklas |
94 |
} |
6426 |
27 Feb 14 |
nicklas |
95 |
if (loginAction == null) |
6426 |
27 Feb 14 |
nicklas |
96 |
{ |
7536 |
28 Nov 18 |
nicklas |
97 |
loginAction = PasswordLoginFormFactory.INSTANCE; |
7536 |
28 Nov 18 |
nicklas |
98 |
selectedLoginForm = loginAction.getId(); |
6426 |
27 Feb 14 |
nicklas |
99 |
} |
6426 |
27 Feb 14 |
nicklas |
100 |
FieldInfo loginField = loginAction.getLoginField(); |
6426 |
27 Feb 14 |
nicklas |
101 |
FieldInfo passwordField = loginAction.getPasswordField(); |
7500 |
08 Aug 18 |
nicklas |
102 |
FieldInfo extraField = loginAction.getExtraField(); |
2823 |
31 Oct 06 |
nicklas |
103 |
%> |
2823 |
31 Oct 06 |
nicklas |
104 |
<base:page type="popup" title="Switch user"> |
6426 |
27 Feb 14 |
nicklas |
105 |
<base:head styles="login.css" scripts="~login.js"> |
8045 |
03 Jun 22 |
nicklas |
106 |
<ext:scripts context="<%=jspContext%>" extension="<%=selectedExtension%>" /> |
8045 |
03 Jun 22 |
nicklas |
107 |
<ext:stylesheets context="<%=jspContext%>" extension="<%=selectedExtension%>" /> |
6426 |
27 Feb 14 |
nicklas |
108 |
</base:head> |
7531 |
26 Nov 18 |
nicklas |
109 |
<base:body data-login-form="<%=HTML.encodeTags(selectedLoginForm)%>" data-requested-form="<%=HTML.encodeTags(requestedLoginForm) %>"> |
5907 |
13 Dec 11 |
nicklas |
110 |
<h1>Switch user <base:help helpid="switchuser" /></h1> |
8045 |
03 Jun 22 |
nicklas |
111 |
<form name="login" action="login.jsp" method="post" |
8045 |
03 Jun 22 |
nicklas |
112 |
<%=DynamicActionAttributeSupport.getAttributesString(loginAction)%> |
8045 |
03 Jun 22 |
nicklas |
113 |
> |
2823 |
31 Oct 06 |
nicklas |
114 |
<input type="hidden" name="ID" value="<%=ID%>"> |
2823 |
31 Oct 06 |
nicklas |
115 |
<input type="hidden" name="again" value="1"> |
3504 |
15 Jun 07 |
nicklas |
116 |
<input type="hidden" name="redirect" value=""> |
7114 |
16 Mar 16 |
nicklas |
117 |
<input type="hidden" name="useAutoStartPage" value="0"> |
7408 |
06 Oct 17 |
nicklas |
118 |
<input type="hidden" name="deviceToken" value=""> |
2823 |
31 Oct 06 |
nicklas |
119 |
|
7542 |
06 Dec 18 |
nicklas |
120 |
<div class="content"> |
7542 |
06 Dec 18 |
nicklas |
121 |
<table class="fullform input100 bottomborder" id="the-login-form" style="display: none;"> |
7531 |
26 Nov 18 |
nicklas |
122 |
<% |
7537 |
28 Nov 18 |
nicklas |
123 |
if (allForms.size() > 1) |
7531 |
26 Nov 18 |
nicklas |
124 |
{ |
7531 |
26 Nov 18 |
nicklas |
125 |
%> |
7531 |
26 Nov 18 |
nicklas |
126 |
<tr> |
7531 |
26 Nov 18 |
nicklas |
127 |
<th>Login with</th> |
7531 |
26 Nov 18 |
nicklas |
128 |
<td> |
7531 |
26 Nov 18 |
nicklas |
129 |
<select name="loginForm" id="loginForm" style="min-width: 10em;"> |
7531 |
26 Nov 18 |
nicklas |
130 |
<% |
7531 |
26 Nov 18 |
nicklas |
131 |
for (Map.Entry<String, String> entry : allForms.entrySet()) |
7531 |
26 Nov 18 |
nicklas |
132 |
{ |
7531 |
26 Nov 18 |
nicklas |
133 |
String formId = entry.getKey(); |
7531 |
26 Nov 18 |
nicklas |
134 |
%> |
7531 |
26 Nov 18 |
nicklas |
135 |
<option value="<%=formId%>" <%=formId.equals(selectedLoginForm) ? "selected" : ""%>><%=HTML.encodeTags(entry.getValue()) %> |
7531 |
26 Nov 18 |
nicklas |
136 |
<% |
7531 |
26 Nov 18 |
nicklas |
137 |
} |
7531 |
26 Nov 18 |
nicklas |
138 |
%> |
7531 |
26 Nov 18 |
nicklas |
139 |
</select> |
7531 |
26 Nov 18 |
nicklas |
140 |
</td> |
7531 |
26 Nov 18 |
nicklas |
141 |
</tr> |
7531 |
26 Nov 18 |
nicklas |
142 |
<% |
7531 |
26 Nov 18 |
nicklas |
143 |
} |
7531 |
26 Nov 18 |
nicklas |
144 |
%> |
6426 |
27 Feb 14 |
nicklas |
145 |
<tr <%=valueIfNotNull("class=\"", loginField.getClazz(), "\"")%> id="login-row"> |
6426 |
27 Feb 14 |
nicklas |
146 |
<th><%=loginField.getPrompt() %></th> |
6426 |
27 Feb 14 |
nicklas |
147 |
<td><input class="text" name="login" id="login" |
6426 |
27 Feb 14 |
nicklas |
148 |
type="<%=loginField.hasHiddenCharacters() ? "password" : "text"%>" |
6426 |
27 Feb 14 |
nicklas |
149 |
value="<%=loginAction.rememberLastLogin() ? HTML.encodeTags(login) : ""%>" |
6426 |
27 Feb 14 |
nicklas |
150 |
<%=valueIfNotNull("style=\"", loginField.getStyle(), "\"") %> |
6426 |
27 Feb 14 |
nicklas |
151 |
<%=valueIfNotNull("title=\"", loginField.getTooltip(), "\"") %> |
6426 |
27 Feb 14 |
nicklas |
152 |
<%=valueIfNotNull("placeholder=\"", loginField.getPlaceHolder(), "\"") %> |
6426 |
27 Feb 14 |
nicklas |
153 |
<%=loginAction.rememberLastLogin() ? "" : "autocomplete=\"off\""%> |
6426 |
27 Feb 14 |
nicklas |
154 |
data-use-last-login="0" |
6426 |
27 Feb 14 |
nicklas |
155 |
maxlength="100" |
8045 |
03 Jun 22 |
nicklas |
156 |
tabindex="0" |
8045 |
03 Jun 22 |
nicklas |
157 |
<%=DynamicActionAttributeSupport.getAttributesString(loginField)%> |
8045 |
03 Jun 22 |
nicklas |
158 |
> |
6426 |
27 Feb 14 |
nicklas |
159 |
</td> |
2823 |
31 Oct 06 |
nicklas |
160 |
</tr> |
6426 |
27 Feb 14 |
nicklas |
161 |
<tr <%=valueIfNotNull("class=\"", passwordField.getClazz(), "\"")%> id="password-row"> |
6426 |
27 Feb 14 |
nicklas |
162 |
<th><%=passwordField.getPrompt() %></th> |
6426 |
27 Feb 14 |
nicklas |
163 |
<td><input class="text" name="password" id="password" |
6426 |
27 Feb 14 |
nicklas |
164 |
type="<%=passwordField.hasHiddenCharacters() ? "password" : "text"%>" |
6426 |
27 Feb 14 |
nicklas |
165 |
<%=valueIfNotNull("style=\"", passwordField.getStyle(), "\"") %> |
6426 |
27 Feb 14 |
nicklas |
166 |
<%=valueIfNotNull("title=\"", passwordField.getTooltip(), "\"") %> |
6426 |
27 Feb 14 |
nicklas |
167 |
<%=valueIfNotNull("placeholder=\"", passwordField.getPlaceHolder(), "\"") %> |
6426 |
27 Feb 14 |
nicklas |
168 |
maxlength="80" |
8045 |
03 Jun 22 |
nicklas |
169 |
tabindex="0" |
8045 |
03 Jun 22 |
nicklas |
170 |
<%=DynamicActionAttributeSupport.getAttributesString(passwordField)%> |
8045 |
03 Jun 22 |
nicklas |
171 |
> |
6426 |
27 Feb 14 |
nicklas |
172 |
</td> |
2823 |
31 Oct 06 |
nicklas |
173 |
</tr> |
7500 |
08 Aug 18 |
nicklas |
174 |
<% |
7500 |
08 Aug 18 |
nicklas |
175 |
if (extraField != null) |
7500 |
08 Aug 18 |
nicklas |
176 |
{ |
7500 |
08 Aug 18 |
nicklas |
177 |
%> |
7500 |
08 Aug 18 |
nicklas |
178 |
<tr <%=valueIfNotNull("class=\"", extraField.getClazz(), "\"")%> id="extra-row"> |
7500 |
08 Aug 18 |
nicklas |
179 |
<th><%=extraField.getPrompt() %></th> |
7500 |
08 Aug 18 |
nicklas |
180 |
<td><input class="text" name="extraField" id="extraField" |
7500 |
08 Aug 18 |
nicklas |
181 |
type="<%=extraField.hasHiddenCharacters() ? "password" : "text"%>" |
7500 |
08 Aug 18 |
nicklas |
182 |
<%=valueIfNotNull("style=\"", extraField.getStyle(), "\"") %> |
7500 |
08 Aug 18 |
nicklas |
183 |
<%=valueIfNotNull("title=\"", extraField.getTooltip(), "\"") %> |
7500 |
08 Aug 18 |
nicklas |
184 |
<%=valueIfNotNull("placeholder=\"", extraField.getPlaceHolder(), "\"") %> |
7500 |
08 Aug 18 |
nicklas |
185 |
maxlength="80" |
8045 |
03 Jun 22 |
nicklas |
186 |
tabindex="0" |
8045 |
03 Jun 22 |
nicklas |
187 |
<%=DynamicActionAttributeSupport.getAttributesString(extraField)%> |
8045 |
03 Jun 22 |
nicklas |
188 |
> |
7500 |
08 Aug 18 |
nicklas |
189 |
</td> |
7500 |
08 Aug 18 |
nicklas |
190 |
</tr> |
7500 |
08 Aug 18 |
nicklas |
191 |
<% |
7500 |
08 Aug 18 |
nicklas |
192 |
} |
7500 |
08 Aug 18 |
nicklas |
193 |
%> |
3504 |
15 Jun 07 |
nicklas |
194 |
<tr> |
5907 |
13 Dec 11 |
nicklas |
195 |
<th><label for="remainOnPage">Remain on this page</label></th> |
6167 |
12 Oct 12 |
nicklas |
196 |
<td><input type="checkbox" name="remainOnPage" id="remainOnPage" checked value="1"></td> |
3504 |
15 Jun 07 |
nicklas |
197 |
</tr> |
6607 |
19 Nov 14 |
nicklas |
198 |
<% |
6607 |
19 Nov 14 |
nicklas |
199 |
if (loginAction.getHelp() != null) |
6607 |
19 Nov 14 |
nicklas |
200 |
{ |
6607 |
19 Nov 14 |
nicklas |
201 |
%> |
6607 |
19 Nov 14 |
nicklas |
202 |
<tr class="dynamic bg-filled-50 topborder"> |
6607 |
19 Nov 14 |
nicklas |
203 |
<td colspan="2"> |
6607 |
19 Nov 14 |
nicklas |
204 |
<div class="padded"> |
6607 |
19 Nov 14 |
nicklas |
205 |
<div class="messagecontainer help" style="font-style: italic;" id="login-help"> |
6607 |
19 Nov 14 |
nicklas |
206 |
<%=loginAction.getHelp() %> |
6607 |
19 Nov 14 |
nicklas |
207 |
</div> |
8045 |
03 Jun 22 |
nicklas |
208 |
<div id="login-error" class="messagecontainer error" |
8045 |
03 Jun 22 |
nicklas |
209 |
style="margin-top: 1em; margin-bottom: 1em; display:none;"> |
8045 |
03 Jun 22 |
nicklas |
210 |
</div> |
6607 |
19 Nov 14 |
nicklas |
211 |
</div> |
6607 |
19 Nov 14 |
nicklas |
212 |
</td> |
6607 |
19 Nov 14 |
nicklas |
213 |
</tr> |
6426 |
27 Feb 14 |
nicklas |
214 |
<% |
6607 |
19 Nov 14 |
nicklas |
215 |
} |
6607 |
19 Nov 14 |
nicklas |
216 |
else |
6607 |
19 Nov 14 |
nicklas |
217 |
{ |
6426 |
27 Feb 14 |
nicklas |
218 |
%> |
6607 |
19 Nov 14 |
nicklas |
219 |
<tr class="dynamic"> |
6607 |
19 Nov 14 |
nicklas |
220 |
<th></th> |
8045 |
03 Jun 22 |
nicklas |
221 |
<td> |
8045 |
03 Jun 22 |
nicklas |
222 |
<div id="login-error" class="messagecontainer error" |
8045 |
03 Jun 22 |
nicklas |
223 |
style="margin-top: 1em; margin-bottom: 1em; display:none;"> |
8045 |
03 Jun 22 |
nicklas |
224 |
</div> |
8045 |
03 Jun 22 |
nicklas |
225 |
</td> |
6607 |
19 Nov 14 |
nicklas |
226 |
</tr> |
6607 |
19 Nov 14 |
nicklas |
227 |
<% |
6607 |
19 Nov 14 |
nicklas |
228 |
} |
6607 |
19 Nov 14 |
nicklas |
229 |
%> |
6607 |
19 Nov 14 |
nicklas |
230 |
</table> |
6426 |
27 Feb 14 |
nicklas |
231 |
|
2823 |
31 Oct 06 |
nicklas |
232 |
</div> |
2823 |
31 Oct 06 |
nicklas |
233 |
</form> |
2823 |
31 Oct 06 |
nicklas |
234 |
|
5907 |
13 Dec 11 |
nicklas |
235 |
<base:buttongroup subclass="dialogbuttons"> |
6167 |
12 Oct 12 |
nicklas |
236 |
<base:button id="btnLogin" image="login.png" title="Login" /> |
6167 |
12 Oct 12 |
nicklas |
237 |
<base:button id="close" title="Cancel" /> |
5907 |
13 Dec 11 |
nicklas |
238 |
</base:buttongroup> |
2823 |
31 Oct 06 |
nicklas |
239 |
|
2823 |
31 Oct 06 |
nicklas |
240 |
</base:body> |
2823 |
31 Oct 06 |
nicklas |
241 |
</base:page> |
2823 |
31 Oct 06 |
nicklas |
242 |
<% |
2823 |
31 Oct 06 |
nicklas |
243 |
} |
2823 |
31 Oct 06 |
nicklas |
244 |
finally |
2823 |
31 Oct 06 |
nicklas |
245 |
{ |
2823 |
31 Oct 06 |
nicklas |
246 |
if (dc != null) dc.close(); |
2823 |
31 Oct 06 |
nicklas |
247 |
} |
2823 |
31 Oct 06 |
nicklas |
248 |
%> |
2823 |
31 Oct 06 |
nicklas |
249 |
|