source: trunk/www/exception/not_logged_in.jsp @ 7408

Last change on this file since 7408 was 7408, checked in by Nicklas Nordborg, 5 years ago

References #2097: Implement support for device verification

The major part of device verification should now be implemented. If the web application has a stored token it is submitted with the login information (LoginRequest.setDeviceToken()). The SessionControl.login() method will check if the device is known or not.

If not, a DeviceNotVerifiedException is thrown and the user is taken to the verify_device.jsp page. The code should be sent by email but is currently only display on that page (to be fixed!). If the verification code is correct, information about the device is stored in the database so that the user can be allowed access immediately the next time.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.3 KB
Line 
1<%-- $Id: not_logged_in.jsp 7408 2017-10-06 09:37:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
5  Copyright (C) 2007 Nicklas Nordborg
6
7  This file is part of BASE - BioArray Software Environment.
8  Available at http://base.thep.lu.se/
9
10  BASE is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 3
13  of the License, or (at your option) any later version.
14
15  BASE is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with BASE. If not, see <http://www.gnu.org/licenses/>.
22  ------------------------------------------------------------------
23
24  This page is used to catch NotLoggedInExceptions which are
25  directed here via the exception.jsp page. NotLoggedInExceptions
26  happen when a user tries to access a protected page without beeing
27  logged in. Typically the exception is thrown from the method that
28  retrieves the BaseControl object:
29
30  BASE.getExistingBaseControl(pageContext);
31
32  This page will display a new login form allowing the user
33  to login again and continue with what he/she was doing.
34
35  @author Nicklas
36  @version 2.0
37--%>
38<%@ page pageEncoding="UTF-8" session="false"
39  import="net.sf.basedb.core.Application"
40  import="net.sf.basedb.core.SessionControl"
41  import="net.sf.basedb.core.DbControl"
42  import="net.sf.basedb.clients.web.Base"
43  import="net.sf.basedb.util.Values"
44  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
45  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
46  import="net.sf.basedb.clients.web.extensions.JspContext"
47  import="net.sf.basedb.clients.web.extensions.login.LoginFormAction"
48  import="net.sf.basedb.clients.web.extensions.login.LoginFormBean"
49  import="net.sf.basedb.clients.web.extensions.login.FieldInfo"
50  isErrorPage="true"
51%>
52<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
53<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
54<%! 
55// If value is null, return "", else <prefix>+<value>+<suffix>
56String valueIfNotNull(String prefix, String value, String suffix)
57{
58  return value == null ? "" : prefix+value+suffix;
59}
60%>
61<%
62final SessionControl sc = Base.getSessionControl(pageContext, true);
63final String ID = sc.getId();
64final String root = request.getContextPath()+"/";
65final String redirect = Values.getString((String)request.getAttribute("redirect"));
66final DbControl dc = sc.newDbControl();
67
68try
69{
70  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
71  ExtensionsInvoker<LoginFormAction> invoker = (ExtensionsInvoker<LoginFormAction>)ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.login-form");
72  LoginFormAction loginAction = null;
73  for (LoginFormAction action : invoker)
74  {
75    if (action != null)
76    {
77      loginAction = action;
78      break;
79    }
80  }
81  if (loginAction == null)
82  {
83    LoginFormBean bean  = new LoginFormBean();
84    bean.setRememberLastLogin(true);
85    bean.setLoginField(FieldInfo.DEFAULT_LOGIN);
86    bean.setPasswordField(FieldInfo.DEFAULT_PASSWORD);
87    loginAction = bean;
88  }
89  FieldInfo loginField = loginAction.getLoginField();
90  FieldInfo passwordField = loginAction.getPasswordField();
91  %>
92  <base:page type="default" menu="exception" title="Not logged in">
93  <base:head scripts="exception.js,/login.js" styles="login.css">
94    <ext:scripts context="<%=jspContext%>" />
95    <ext:stylesheets context="<%=jspContext%>" />
96  </base:head>
97  <base:body data-resize-if-popup="1">
98 
99      <form action="<%=root%>login.jsp?again=1" method="post" name="login" target="Login">
100      <input type="hidden" name="ID" value="<%=ID%>">
101      <input type="hidden" name="redirect" value="<%=redirect%>">
102      <input type="hidden" name="useAutoStartPage" value="0">
103      <input type="hidden" name="deviceToken" value="">
104 
105      <table style="margin: auto; width: 700px; margin-top:5em; ">
106      <tr>
107      <td>
108        <%
109        if (loginAction.getHelp() != null)
110        {
111          %>
112          <div class="messagecontainer help" style="font-style: italic;" id="login-help">
113          <%=loginAction.getHelp() %>
114          </div>
115          <%
116        }
117        %>
118        <table style="width: 100%; margin-top: 1em; border-collapse: separate;">
119        <tr>
120          <td class="base-logo"><img src="<%=root%>images/baselogo.png" alt="BASE logo"></td>
121          <td style="width: 515px;">
122            <div id="loginform">
123            <table style="width: 100%;">
124              <tr <%=valueIfNotNull("class=\"", loginField.getClazz(), "\"")%> id="login-row">
125                <th class="bg-filled-100"><%=loginField.getPrompt() %></th>
126                <td colspan="2"><input class="text" name="login" id="login"
127                  type="<%=loginField.hasHiddenCharacters() ? "password" : "text"%>"
128                  value="" 
129                  <%=valueIfNotNull("style=\"", loginField.getStyle(), "\"") %>
130                  <%=valueIfNotNull("title=\"", loginField.getTooltip(), "\"") %>
131                  <%=valueIfNotNull("placeholder=\"", loginField.getPlaceHolder(), "\"") %>
132                  <%=loginAction.rememberLastLogin() ? "" : "autocomplete=\"off\" data-use-last-login=\"0\""%>
133                  maxlength="100" 
134                  tabindex="0">
135                </td>
136              </tr>
137              <tr <%=valueIfNotNull("class=\"", passwordField.getClazz(), "\"")%> id="password-row">
138                <th class="bg-filled-100"><%=passwordField.getPrompt() %></th>
139                <td><input class="text" name="password" id="password"
140                  type="<%=passwordField.hasHiddenCharacters() ? "password" : "text"%>"
141                  <%=valueIfNotNull("style=\"", passwordField.getStyle(), "\"") %>
142                  <%=valueIfNotNull("title=\"", passwordField.getTooltip(), "\"") %>
143                  <%=valueIfNotNull("placeholder=\"", passwordField.getPlaceHolder(), "\"") %>
144                  maxlength="80"
145                  tabindex="0">
146                </td>
147                <td>
148                  <base:buttongroup>
149                    <base:button id="btnLogin" image="login.png" title="Login" />
150                    <base:button id="close" title="Cancel" />
151                  </base:buttongroup>
152                </td>
153              </tr>
154              <tr>
155                <th class="bg-filled-100"></th>
156                <td colspan="2">
157                <%
158                String forgotPassword = sc.getClientDefaultSetting("server.forgotten.password");
159                String getAccount = sc.getClientDefaultSetting("server.get.account");
160                if (forgotPassword != null)
161                {
162                  %>
163                  <base:icon id="forgotPassword" image="bullet.png" 
164                    tooltip="Click here if you have forgotten your password">Forgot your password?</base:icon>
165                  <%
166                }
167                if (getAccount != null)
168                {
169                  %>
170                  <base:icon id="getAccount" image="bullet.png" 
171                    tooltip="Click here if you want to get an account on this server">Get an account!</base:icon>
172                  <%
173                }
174                %>
175                </td>
176              </tr>
177              </table>
178            </div>
179          </td>
180        </tr>
181        </table>
182 
183        <div class="messagecontainer error" id="timeout" style="display: none; margin-top: 1em;">
184          <b>Not logged in</b><br>
185          You have been automatically logged out due to inactivity or because the
186          server has been restarted.
187          You may log in again and continue your work but unsaved changes
188          may have been lost.
189        </div>
190 
191      </td>
192      </tr>
193      </table>
194 
195    </form>
196  </base:body>
197  </base:page>
198  <%
199}
200finally
201{
202  if (dc != null) dc.close();
203}
204%>
Note: See TracBrowser for help on using the repository browser.