mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #1 from mwoodiupui/patch-1-mark
Patch 1 amended with changes from Mark Wood
This commit is contained in:
@@ -257,12 +257,17 @@ public class DSpaceCocoonServletFilter implements Filter
|
||||
realResponse.sendRedirect(locationWithTrailingSlash);
|
||||
}
|
||||
// if force ssl is on and the user has authenticated and the request is not secure redirect to https
|
||||
else if ((ConfigurationManager.getBooleanProperty("xmlui.force.ssl")) && (realRequest.getSession().getAttribute("dspace.user.effective")!=null) && (!realRequest.isSecure())) {
|
||||
StringBuffer location = new StringBuffer("https://");
|
||||
location.append(ConfigurationManager.getProperty("dspace.hostname")).append(realRequest.getContextPath()).append(realRequest.getServletPath()).append(
|
||||
realRequest.getQueryString() == null ? ""
|
||||
: ("?" + realRequest.getQueryString()));
|
||||
realResponse.sendRedirect(location.toString());
|
||||
else if ((ConfigurationManager.getBooleanProperty("xmlui.force.ssl"))
|
||||
&& (AuthenticationUtil.isLoggedIn(realRequest))
|
||||
&& (!realRequest.isSecure()))
|
||||
{
|
||||
StringBuffer location = new StringBuffer("https://");
|
||||
location.append(ConfigurationManager.getProperty("dspace.hostname"))
|
||||
.append(realRequest.getContextPath())
|
||||
.append(realRequest.getServletPath())
|
||||
.append(realRequest.getQueryString() == null ? ""
|
||||
: ("?" + realRequest.getQueryString()));
|
||||
realResponse.sendRedirect(location.toString());
|
||||
}
|
||||
else
|
||||
{ // invoke the next filter
|
||||
|
@@ -142,7 +142,7 @@ public class MetadataExportReader extends AbstractReader implements Recyclable
|
||||
*
|
||||
*/
|
||||
|
||||
if(this.request.getSession().getAttribute("dspace.current.user.id")!=null) {
|
||||
if(AuthenticationUtil.isLoggedIn(request)) {
|
||||
String redictURL = request.getContextPath() + "/restricted-resource";
|
||||
HttpServletResponse httpResponse = (HttpServletResponse)
|
||||
objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
|
||||
|
@@ -613,5 +613,14 @@ public class AuthenticationUtil
|
||||
// Otherwise return the real request.
|
||||
return realHttpRequest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Has this user authenticated?
|
||||
* @param request
|
||||
* @return true if request is in a session having a user ID.
|
||||
*/
|
||||
public static boolean isLoggedIn(HttpServletRequest request)
|
||||
{
|
||||
return (null != request.getSession().getAttribute(EFFECTIVE_USER_ID));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user