mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
allow changing of context path with a http header
This commit is contained in:
@@ -45,8 +45,8 @@ import org.tmatesoft.svn.core.internal.server.dav.DAVConfig;
|
|||||||
import org.tmatesoft.svn.core.internal.server.dav.DAVServlet;
|
import org.tmatesoft.svn.core.internal.server.dav.DAVServlet;
|
||||||
|
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
import sonia.scm.repository.RepositoryRequestListenerUtil;
|
|
||||||
import sonia.scm.repository.RepositoryProvider;
|
import sonia.scm.repository.RepositoryProvider;
|
||||||
|
import sonia.scm.repository.RepositoryRequestListenerUtil;
|
||||||
import sonia.scm.repository.SvnRepositoryHandler;
|
import sonia.scm.repository.SvnRepositoryHandler;
|
||||||
import sonia.scm.util.AssertUtil;
|
import sonia.scm.util.AssertUtil;
|
||||||
import sonia.scm.util.HttpUtil;
|
import sonia.scm.util.HttpUtil;
|
||||||
@@ -68,6 +68,9 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
public class SvnDAVServlet extends DAVServlet
|
public class SvnDAVServlet extends DAVServlet
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private static final String HEADER_CONTEXTPATH = "X-Forwarded-Ctx";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private static final long serialVersionUID = -1462257085465785945L;
|
private static final long serialVersionUID = -1462257085465785945L;
|
||||||
|
|
||||||
@@ -86,8 +89,7 @@ public class SvnDAVServlet extends DAVServlet
|
|||||||
* @param repositoryRequestListenerUtil
|
* @param repositoryRequestListenerUtil
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public SvnDAVServlet(
|
public SvnDAVServlet(SvnRepositoryHandler handler,
|
||||||
SvnRepositoryHandler handler,
|
|
||||||
RepositoryProvider repositoryProvider,
|
RepositoryProvider repositoryProvider,
|
||||||
RepositoryRequestListenerUtil repositoryRequestListenerUtil)
|
RepositoryRequestListenerUtil repositoryRequestListenerUtil)
|
||||||
{
|
{
|
||||||
@@ -177,6 +179,25 @@ public class SvnDAVServlet extends DAVServlet
|
|||||||
|
|
||||||
//~--- get methods --------------------------------------------------------
|
//~--- get methods --------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getContextPath()
|
||||||
|
{
|
||||||
|
String header = getHeader(HEADER_CONTEXTPATH);
|
||||||
|
|
||||||
|
if ((header == null) ||!isValidContextPath(header))
|
||||||
|
{
|
||||||
|
header = super.getContextPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -230,6 +251,32 @@ public class SvnDAVServlet extends DAVServlet
|
|||||||
return servletPath;
|
return servletPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param ctx
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isValidContextPath(String ctx)
|
||||||
|
{
|
||||||
|
int length = ctx.length();
|
||||||
|
|
||||||
|
boolean result = (length == 0)
|
||||||
|
|| ((length > 1)
|
||||||
|
&& ctx.startsWith(HttpUtil.SEPARATOR_PATH));
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
logger.warn(
|
||||||
|
"header {} contains a non valid context path, fallback to default",
|
||||||
|
HEADER_CONTEXTPATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields -------------------------------------------------------------
|
//~--- fields -------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
Reference in New Issue
Block a user