improve error handling for failed authentication and not enough privileges

This commit is contained in:
Sebastian Sdorra
2014-03-15 16:12:14 +01:00
parent 54faa5cb56
commit b131d4b804
4 changed files with 126 additions and 4 deletions

View File

@@ -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);
}
}