mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 11:35:57 +01:00
use client messages
This commit is contained in:
@@ -38,6 +38,7 @@ import com.google.inject.Singleton;
|
|||||||
|
|
||||||
import org.eclipse.jgit.http.server.GitSmartHttpTools;
|
import org.eclipse.jgit.http.server.GitSmartHttpTools;
|
||||||
|
|
||||||
|
import sonia.scm.ClientMessages;
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.repository.GitUtil;
|
import sonia.scm.repository.GitUtil;
|
||||||
import sonia.scm.web.filter.AutoLoginModule;
|
import sonia.scm.web.filter.AutoLoginModule;
|
||||||
@@ -60,12 +61,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
public class GitBasicAuthenticationFilter extends BasicAuthenticationFilter
|
public class GitBasicAuthenticationFilter extends BasicAuthenticationFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private static final String MESSAGE_FAILED_AUTHENTICATION =
|
|
||||||
"Invalid username or password.";
|
|
||||||
|
|
||||||
//~--- constructors ---------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
@@ -96,10 +91,12 @@ public class GitBasicAuthenticationFilter extends BasicAuthenticationFilter
|
|||||||
HttpServletResponse response)
|
HttpServletResponse response)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
System.out.println(ClientMessages.get(request).failedAuthentication());
|
||||||
if (GitUtil.isGitClient(request))
|
if (GitUtil.isGitClient(request))
|
||||||
{
|
{
|
||||||
GitSmartHttpTools.sendError(request, response,
|
GitSmartHttpTools.sendError(request, response,
|
||||||
HttpServletResponse.SC_FORBIDDEN, MESSAGE_FAILED_AUTHENTICATION);
|
HttpServletResponse.SC_FORBIDDEN,
|
||||||
|
ClientMessages.get(request).failedAuthentication());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import com.google.inject.Singleton;
|
|||||||
|
|
||||||
import org.eclipse.jgit.http.server.GitSmartHttpTools;
|
import org.eclipse.jgit.http.server.GitSmartHttpTools;
|
||||||
|
|
||||||
|
import sonia.scm.ClientMessages;
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.repository.GitUtil;
|
import sonia.scm.repository.GitUtil;
|
||||||
import sonia.scm.repository.RepositoryProvider;
|
import sonia.scm.repository.RepositoryProvider;
|
||||||
@@ -72,10 +73,6 @@ public class GitPermissionFilter extends ProviderPermissionFilter
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String URI_REF_INFO = "/info/refs";
|
public static final String URI_REF_INFO = "/info/refs";
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private static final String MESSAGE_NOT_ENOUGH_PRIVILEGES =
|
|
||||||
"You do not have enough access privileges for this operation.";
|
|
||||||
|
|
||||||
//~--- constructors ---------------------------------------------------------
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +107,8 @@ public class GitPermissionFilter extends ProviderPermissionFilter
|
|||||||
if (GitUtil.isGitClient(request))
|
if (GitUtil.isGitClient(request))
|
||||||
{
|
{
|
||||||
GitSmartHttpTools.sendError(request, response,
|
GitSmartHttpTools.sendError(request, response,
|
||||||
HttpServletResponse.SC_FORBIDDEN, MESSAGE_NOT_ENOUGH_PRIVILEGES);
|
HttpServletResponse.SC_FORBIDDEN,
|
||||||
|
ClientMessages.get(request).notEnoughPrivileges());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ package sonia.scm.web;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import com.google.common.io.Closeables;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@@ -44,7 +43,6 @@ import sonia.scm.web.filter.BasicAuthenticationFilter;
|
|||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|||||||
@@ -39,18 +39,9 @@ import org.tmatesoft.svn.core.SVNErrorCode;
|
|||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public class ScmSvnErrorCode extends SVNErrorCode
|
public final class ScmSvnErrorCode extends SVNErrorCode
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
public static final SVNErrorCode AUTHN_FAILED =
|
|
||||||
new ScmSvnErrorCode(AUTHN_CATEGORY, 4, "Authentication failed");
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
public static final SVNErrorCode AUTHZ_NOT_ENOUGH_PRIVILEGES =
|
|
||||||
new ScmSvnErrorCode(AUTHZ_CATEGORY, 4,
|
|
||||||
"You do not have enough access privileges for this operation.");
|
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private static final long serialVersionUID = -6864996390796610410L;
|
private static final long serialVersionUID = -6864996390796610410L;
|
||||||
|
|
||||||
@@ -68,4 +59,19 @@ public class ScmSvnErrorCode extends SVNErrorCode
|
|||||||
{
|
{
|
||||||
super(category, index, description);
|
super(category, index, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param description
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ScmSvnErrorCode authzNotEnoughPrivileges(String description)
|
||||||
|
{
|
||||||
|
return new ScmSvnErrorCode(AUTHZ_CATEGORY, 4, description);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,9 @@ package sonia.scm.web;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.tmatesoft.svn.core.SVNErrorCode;
|
|
||||||
|
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.repository.ScmSvnErrorCode;
|
|
||||||
import sonia.scm.repository.SvnUtil;
|
import sonia.scm.repository.SvnUtil;
|
||||||
|
import sonia.scm.util.HttpUtil;
|
||||||
import sonia.scm.web.filter.AutoLoginModule;
|
import sonia.scm.web.filter.AutoLoginModule;
|
||||||
import sonia.scm.web.filter.BasicAuthenticationFilter;
|
import sonia.scm.web.filter.BasicAuthenticationFilter;
|
||||||
|
|
||||||
@@ -52,7 +50,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import sonia.scm.util.HttpUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.tmatesoft.svn.core.SVNErrorCode;
|
import sonia.scm.ClientMessages;
|
||||||
|
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.repository.RepositoryProvider;
|
import sonia.scm.repository.RepositoryProvider;
|
||||||
import sonia.scm.repository.ScmSvnErrorCode;
|
import sonia.scm.repository.ScmSvnErrorCode;
|
||||||
@@ -102,8 +101,16 @@ public class SvnPermissionFilter extends ProviderPermissionFilter
|
|||||||
{
|
{
|
||||||
if (SvnUtil.isSvnClient(request))
|
if (SvnUtil.isSvnClient(request))
|
||||||
{
|
{
|
||||||
SvnUtil.sendError(request, response, HttpServletResponse.SC_FORBIDDEN,
|
//J-
|
||||||
ScmSvnErrorCode.AUTHZ_NOT_ENOUGH_PRIVILEGES);
|
SvnUtil.sendError(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
HttpServletResponse.SC_FORBIDDEN,
|
||||||
|
ScmSvnErrorCode.authzNotEnoughPrivileges(
|
||||||
|
ClientMessages.get(request).notEnoughPrivileges()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
//J+
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user