Class AsIsFileService
java.lang.Object
org.eclipse.jgit.http.server.resolver.AsIsFileService
Controls access to bare files in a repository.
Older HTTP clients which do not speak the smart HTTP variant of the Git
protocol fetch from a repository by directly getting its objects and pack
files. This class, along with the http.getanyfile
per-repository
configuration setting, can be used by
GitServlet
to control whether or not
these older clients are permitted to read these direct files.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AsIsFileService
Always throwsServiceNotEnabledException
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
access
(jakarta.servlet.http.HttpServletRequest req, org.eclipse.jgit.lib.Repository db) Determine if access to any bare file of the repository is allowed.protected static boolean
isEnabled
(org.eclipse.jgit.lib.Repository db) Determine ifhttp.getanyfile
is enabled in the configuration.
-
Field Details
-
DISABLED
Always throwsServiceNotEnabledException
.
-
-
Constructor Details
-
AsIsFileService
public AsIsFileService()
-
-
Method Details
-
isEnabled
protected static boolean isEnabled(org.eclipse.jgit.lib.Repository db) Determine ifhttp.getanyfile
is enabled in the configuration.- Parameters:
db
- the repository to check.- Returns:
false
ifhttp.getanyfile
was explicitly set tofalse
in the repository's configuration file; otherwisetrue
.
-
access
public void access(jakarta.servlet.http.HttpServletRequest req, org.eclipse.jgit.lib.Repository db) throws org.eclipse.jgit.transport.resolver.ServiceNotEnabledException, org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException Determine if access to any bare file of the repository is allowed.This method silently succeeds if the request is allowed, or fails by throwing a checked exception if access should be denied.
The default implementation of this method checks
http.getanyfile
, throwingServiceNotEnabledException
if it was explicitly set tofalse
, and otherwise succeeding silently.- Parameters:
req
- current HTTP request, in case information from the request may help determine the access request.db
- the repository the request would obtain a bare file from.- Throws:
org.eclipse.jgit.transport.resolver.ServiceNotEnabledException
- bare file access is not allowed on the target repository, by any user, for any reason.org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException
- bare file access is not allowed for this HTTP request and repository, such as due to a permission error.
-