mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
improve error handling for failed authentication and not enough privileges
This commit is contained in:
@@ -58,6 +58,10 @@ import java.io.File;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -68,6 +72,12 @@ public final class HgUtil
|
||||
/** Field description */
|
||||
public static final String REVISION_TIP = "tip";
|
||||
|
||||
/** Field description */
|
||||
private static final String HEADER_USERAGENT = "User-Agent";
|
||||
|
||||
/** Field description */
|
||||
private static final String USERAGENT_HG = "mercurial/";
|
||||
|
||||
/**
|
||||
* the logger for HgUtil
|
||||
*/
|
||||
@@ -180,4 +190,18 @@ public final class HgUtil
|
||||
? REVISION_TIP
|
||||
: revision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the request comes from a mercurial client.
|
||||
*
|
||||
*
|
||||
* @param request servlet request
|
||||
*
|
||||
* @return true if the client is mercurial
|
||||
*/
|
||||
public static boolean isHgClient(HttpServletRequest request)
|
||||
{
|
||||
return Strings.nullToEmpty(request.getHeader(HEADER_USERAGENT)).toLowerCase(
|
||||
Locale.ENGLISH).startsWith(USERAGENT_HG);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user