mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
Turn xmlui/jspui.user.assumelogin property to the new webui.user.assumelogin, add custom jsp error to show no loginas action reason
This commit is contained in:
@@ -1570,3 +1570,6 @@ jsp.dspace-admin.eperson-main.LoginAs.submit = Login As
|
|||||||
jsp.dspace-admin.eperson-main.LoginAs.onlyAdmins = Only site administrators may assume login as another user.
|
jsp.dspace-admin.eperson-main.LoginAs.onlyAdmins = Only site administrators may assume login as another user.
|
||||||
jsp.dspace-admin.eperson-main.LoginAs.onlyAuthenticatedAdmins = Only authenticated users who are administrators may assume the login as another user.
|
jsp.dspace-admin.eperson-main.LoginAs.onlyAuthenticatedAdmins = Only authenticated users who are administrators may assume the login as another user.
|
||||||
jsp.dspace-admin.eperson-main.LoginAs.notAnotherAdmin = You may not assume the login as another administrator.
|
jsp.dspace-admin.eperson-main.LoginAs.notAnotherAdmin = You may not assume the login as another administrator.
|
||||||
|
jsp.dspace-admin.eperson-main.loginAs.authorize.title = Authorization Error
|
||||||
|
jsp.dspace-admin.eperson-main.loginAs.authorize.errormsg = Reason: {0}
|
||||||
|
jsp.dspace-admin.eperson-main.loginAs.backtohome = Back to home
|
@@ -44,6 +44,10 @@ import org.dspace.eperson.Group;
|
|||||||
public class EPersonAdminServlet extends DSpaceServlet
|
public class EPersonAdminServlet extends DSpaceServlet
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static final String LOG_MESSAGE_LOGIN_AS_OFF = "jsp.dspace-admin.eperson-main.LoginAs.submit";
|
||||||
|
private static final String MESSAGE_LOGIN_AS_NOT_ANOTHER_ADMIN = "jsp.dspace-admin.eperson-main.LoginAs.notAnotherAdmin";
|
||||||
|
private static final String MESSAGE_LOGIN_AS_ONLY_AUTHENTICATED_ADMINS = "jsp.dspace-admin.eperson-main.LoginAs.onlyAuthenticatedAdmins";
|
||||||
|
private static final String MESSAGE_LOGIN_AS_ONLY_ADMINS = "jsp.dspace-admin.eperson-main.LoginAs.onlyAdmins";
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Logger log = Logger.getLogger(EPersonAdminServlet.class);
|
private static Logger log = Logger.getLogger(EPersonAdminServlet.class);
|
||||||
|
|
||||||
@@ -292,9 +296,9 @@ public class EPersonAdminServlet extends DSpaceServlet
|
|||||||
}
|
}
|
||||||
else if (button.equals("submit_login_as"))
|
else if (button.equals("submit_login_as"))
|
||||||
{
|
{
|
||||||
if (!ConfigurationManager.getBooleanProperty("jspui.user.assumelogin", false))
|
if (!ConfigurationManager.getBooleanProperty("webui.user.assumelogin", false))
|
||||||
{
|
{
|
||||||
throw new AuthorizeException(I18nUtil.getMessage("jsp.dspace-admin.eperson-main.LoginAs.submit"));
|
throw new AuthorizeException(I18nUtil.getMessage(LOG_MESSAGE_LOGIN_AS_OFF));
|
||||||
}
|
}
|
||||||
EPerson e = EPerson.find(context, UIUtil.getIntParameter(request,
|
EPerson e = EPerson.find(context, UIUtil.getIntParameter(request,
|
||||||
"eperson_id"));
|
"eperson_id"));
|
||||||
@@ -307,7 +311,11 @@ public class EPersonAdminServlet extends DSpaceServlet
|
|||||||
// Only super administrators can login as someone else.
|
// Only super administrators can login as someone else.
|
||||||
else if (!AuthorizeManager.isAdmin(context))
|
else if (!AuthorizeManager.isAdmin(context))
|
||||||
{
|
{
|
||||||
JSPManager.showAuthorizeError(request, response, new AuthorizeException(I18nUtil.getMessage("jsp.dspace-admin.eperson-main.LoginAs.onlyAdmins")));
|
request.setAttribute("authorize_error_message", MESSAGE_LOGIN_AS_ONLY_ADMINS);
|
||||||
|
log.warn(new AuthorizeException(I18nUtil.getMessage(MESSAGE_LOGIN_AS_ONLY_ADMINS)));
|
||||||
|
JSPManager.showJSP(request, response,
|
||||||
|
"/dspace-admin/eperson-loginas-error.jsp");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -325,14 +333,22 @@ public class EPersonAdminServlet extends DSpaceServlet
|
|||||||
Integer authenticatedID = (Integer) session.getAttribute("dspace.current.user.id");
|
Integer authenticatedID = (Integer) session.getAttribute("dspace.current.user.id");
|
||||||
if (context.getCurrentUser().getID() != authenticatedID)
|
if (context.getCurrentUser().getID() != authenticatedID)
|
||||||
{
|
{
|
||||||
throw new AuthorizeException(I18nUtil.getMessage("jsp.dspace-admin.eperson-main.LoginAs.onlyAuthenticatedAdmins"));
|
request.setAttribute("authorize_error_message", MESSAGE_LOGIN_AS_ONLY_AUTHENTICATED_ADMINS);
|
||||||
|
log.warn(new AuthorizeException(I18nUtil.getMessage(MESSAGE_LOGIN_AS_ONLY_AUTHENTICATED_ADMINS)));
|
||||||
|
JSPManager.showJSP(request, response,
|
||||||
|
"/dspace-admin/eperson-loginas-error.jsp");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// You may not assume the login of another super administrator
|
// You may not assume the login of another super administrator
|
||||||
Group administrators = Group.find(context,1);
|
Group administrators = Group.find(context,1);
|
||||||
if (administrators.isMember(e))
|
if (administrators.isMember(e))
|
||||||
{
|
{
|
||||||
throw new AuthorizeException(I18nUtil.getMessage("jsp.dspace-admin.eperson-main.LoginAs.notAnotherAdmin"));
|
request.setAttribute("authorize_error_message", MESSAGE_LOGIN_AS_NOT_ANOTHER_ADMIN);
|
||||||
|
log.warn(new AuthorizeException(I18nUtil.getMessage(MESSAGE_LOGIN_AS_NOT_ANOTHER_ADMIN)));
|
||||||
|
JSPManager.showJSP(request, response,
|
||||||
|
"/dspace-admin/eperson-loginas-error.jsp");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logged in OK.
|
// Logged in OK.
|
||||||
|
@@ -0,0 +1,45 @@
|
|||||||
|
<%--
|
||||||
|
|
||||||
|
The contents of this file are subject to the license and copyright
|
||||||
|
detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
tree and available online at
|
||||||
|
|
||||||
|
http://www.dspace.org/license/
|
||||||
|
|
||||||
|
--%>
|
||||||
|
<%--
|
||||||
|
- Page representing an eperson reset password error
|
||||||
|
|
||||||
|
--%>
|
||||||
|
|
||||||
|
<%@ page contentType="text/html;charset=UTF-8" %>
|
||||||
|
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"
|
||||||
|
prefix="fmt" %>
|
||||||
|
|
||||||
|
<%@ page isErrorPage="true" %>
|
||||||
|
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
|
||||||
|
<%@page import="javax.servlet.jsp.jstl.fmt.LocaleSupport"%>
|
||||||
|
<%
|
||||||
|
Object i18nKey = request.getAttribute("authorize_error_message");
|
||||||
|
String message = "";
|
||||||
|
if(i18nKey!=null) {
|
||||||
|
message = LocaleSupport.getLocalizedMessage(pageContext, i18nKey.toString());
|
||||||
|
}
|
||||||
|
request.removeAttribute("authorize_error_message");
|
||||||
|
%>
|
||||||
|
<dspace:layout titlekey="jsp.dspace-admin.eperson-main.loginAs.authorize.title">
|
||||||
|
|
||||||
|
<%-- <h1>Authorization Required</h1> --%>
|
||||||
|
<h1><fmt:message key="jsp.dspace-admin.eperson-main.loginAs.authorize.title"/></h1>
|
||||||
|
|
||||||
|
|
||||||
|
<p><fmt:message key="jsp.dspace-admin.eperson-main.loginAs.authorize.errormsg"><fmt:param><%= message %></fmt:param></fmt:message></p>
|
||||||
|
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="<%= request.getContextPath() %>"><fmt:message key="jsp.dspace-admin.eperson-main.loginAs.backtohome" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</dspace:layout>
|
||||||
|
|
@@ -36,7 +36,7 @@
|
|||||||
<%
|
<%
|
||||||
boolean noEPersonSelected = (request.getAttribute("no_eperson_selected") != null);
|
boolean noEPersonSelected = (request.getAttribute("no_eperson_selected") != null);
|
||||||
boolean resetPassword = (request.getAttribute("reset_password") != null);
|
boolean resetPassword = (request.getAttribute("reset_password") != null);
|
||||||
boolean loginAs = ConfigurationManager.getBooleanProperty("jspui.user.assumelogin", false);
|
boolean loginAs = ConfigurationManager.getBooleanProperty("webui.user.assumelogin", false);
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<dspace:layout titlekey="jsp.dspace-admin.eperson-main.title"
|
<dspace:layout titlekey="jsp.dspace-admin.eperson-main.title"
|
||||||
|
@@ -310,7 +310,7 @@ public class EditEPersonForm extends AbstractDSpaceTransformer
|
|||||||
|
|
||||||
Button submitLoginAs = special.addButton("submit_login_as");
|
Button submitLoginAs = special.addButton("submit_login_as");
|
||||||
submitLoginAs.setValue(T_submit_login_as);
|
submitLoginAs.setValue(T_submit_login_as);
|
||||||
if (!ConfigurationManager.getBooleanProperty("xmlui.user.assumelogin", false))
|
if (!ConfigurationManager.getBooleanProperty("webui.user.assumelogin", false))
|
||||||
{
|
{
|
||||||
submitLoginAs.setDisabled();
|
submitLoginAs.setDisabled();
|
||||||
}
|
}
|
||||||
|
@@ -306,7 +306,7 @@ public class AuthenticationUtil
|
|||||||
throws SQLException, AuthorizeException
|
throws SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
// Only allow loginAs if the administrator has allowed it.
|
// Only allow loginAs if the administrator has allowed it.
|
||||||
if (!ConfigurationManager.getBooleanProperty("xmlui.user.assumelogin", false))
|
if (!ConfigurationManager.getBooleanProperty("webui.user.assumelogin", false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -735,6 +735,12 @@ org.dspace.app.itemexport.max.size = 200
|
|||||||
# except where explicitly stated otherwise. #
|
# except where explicitly stated otherwise. #
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
|
|
||||||
|
# Determine if super administrators (those whom are in the Administrators group)
|
||||||
|
# can login as another user from the "edit eperson" page. This is useful for
|
||||||
|
# debugging problems in a running dspace instance, especially in the workflow
|
||||||
|
# process. The default value is false, i.e. no one may assume the login of another user.
|
||||||
|
#webui.user.assumelogin = true
|
||||||
|
|
||||||
# whether to display the contents of the licence bundle (often just the deposit
|
# whether to display the contents of the licence bundle (often just the deposit
|
||||||
# licence in standard DSpace installation
|
# licence in standard DSpace installation
|
||||||
webui.licence_bundle.show = false
|
webui.licence_bundle.show = false
|
||||||
@@ -1697,11 +1703,6 @@ webui.suggest.enable = false
|
|||||||
# Take this key (just the UA-XXXXXX-X part) and place it here in this parameter.
|
# Take this key (just the UA-XXXXXX-X part) and place it here in this parameter.
|
||||||
# jspui.google.analytics.key=UA-XXXXXX-X
|
# jspui.google.analytics.key=UA-XXXXXX-X
|
||||||
|
|
||||||
# Determine if super administrators (those whom are in the Administrators group)
|
|
||||||
# can login as another user from the "edit eperson" page. This is useful for
|
|
||||||
# debugging problems in a running dspace instance, especially in the workflow
|
|
||||||
# process. The default value is false, i.e. no one may assume the login of another user.
|
|
||||||
#jspui.user.assumelogin = true
|
|
||||||
|
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
#--------------XMLUI SPECIFIC CONFIGURATIONS--------------------#
|
#--------------XMLUI SPECIFIC CONFIGURATIONS--------------------#
|
||||||
@@ -1730,13 +1731,6 @@ webui.suggest.enable = false
|
|||||||
#xmlui.user.registration=true
|
#xmlui.user.registration=true
|
||||||
#xmlui.user.editmetadata=true
|
#xmlui.user.editmetadata=true
|
||||||
|
|
||||||
|
|
||||||
# Determine if super administrators (those whom are in the Administrators group)
|
|
||||||
# can login as another user from the "edit eperson" page. This is useful for
|
|
||||||
# debugging problems in a running dspace instance, especially in the workflow
|
|
||||||
# process. The default value is false, i.e. no one may assume the login of another user.
|
|
||||||
#xmlui.user.assumelogin = true
|
|
||||||
|
|
||||||
# Check if the user has a consistent ip address from the start of the login process
|
# Check if the user has a consistent ip address from the start of the login process
|
||||||
# to the end of the login process. Disabling this check is not recommended unless
|
# to the end of the login process. Disabling this check is not recommended unless
|
||||||
# absolutely necessary as the ip check can be helpful for preventing session
|
# absolutely necessary as the ip check can be helpful for preventing session
|
||||||
|
Reference in New Issue
Block a user