mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 05:53:08 +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);
|
realResponse.sendRedirect(locationWithTrailingSlash);
|
||||||
}
|
}
|
||||||
// if force ssl is on and the user has authenticated and the request is not secure redirect to https
|
// 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())) {
|
else if ((ConfigurationManager.getBooleanProperty("xmlui.force.ssl"))
|
||||||
StringBuffer location = new StringBuffer("https://");
|
&& (AuthenticationUtil.isLoggedIn(realRequest))
|
||||||
location.append(ConfigurationManager.getProperty("dspace.hostname")).append(realRequest.getContextPath()).append(realRequest.getServletPath()).append(
|
&& (!realRequest.isSecure()))
|
||||||
realRequest.getQueryString() == null ? ""
|
{
|
||||||
: ("?" + realRequest.getQueryString()));
|
StringBuffer location = new StringBuffer("https://");
|
||||||
realResponse.sendRedirect(location.toString());
|
location.append(ConfigurationManager.getProperty("dspace.hostname"))
|
||||||
|
.append(realRequest.getContextPath())
|
||||||
|
.append(realRequest.getServletPath())
|
||||||
|
.append(realRequest.getQueryString() == null ? ""
|
||||||
|
: ("?" + realRequest.getQueryString()));
|
||||||
|
realResponse.sendRedirect(location.toString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // invoke the next filter
|
{ // 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";
|
String redictURL = request.getContextPath() + "/restricted-resource";
|
||||||
HttpServletResponse httpResponse = (HttpServletResponse)
|
HttpServletResponse httpResponse = (HttpServletResponse)
|
||||||
objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
|
objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
|
||||||
|
@@ -613,5 +613,14 @@ public class AuthenticationUtil
|
|||||||
// Otherwise return the real request.
|
// Otherwise return the real request.
|
||||||
return realHttpRequest;
|
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