Example usage for org.eclipse.jgit.http.server GitSmartHttpTools isGitClient

List of usage examples for org.eclipse.jgit.http.server GitSmartHttpTools isGitClient

Introduction

In this page you can find the example usage for org.eclipse.jgit.http.server GitSmartHttpTools isGitClient.

Prototype

public static boolean isGitClient(HttpServletRequest req) 

Source Link

Document

Check a request for Git-over-HTTP indicators.

Usage

From source file:com.google.gerrit.httpd.CacheBasedWebSession.java

License:Apache License

protected CacheBasedWebSession(final HttpServletRequest request, final HttpServletResponse response,
        final WebSessionManager manager, final AuthConfig authConfig,
        final Provider<AnonymousUser> anonymousProvider, final IdentifiedUser.RequestFactory identified) {
    this.request = request;
    this.response = response;
    this.manager = manager;
    this.authConfig = authConfig;
    this.anonymousProvider = anonymousProvider;
    this.identified = identified;

    if (request.getRequestURI() == null || !GitSmartHttpTools.isGitClient(request)) {
        String cookie = readCookie();
        if (cookie != null) {
            key = new Key(cookie);
            val = manager.get(key);
            if (val != null && val.needsCookieRefresh()) {
                // Cookie is more than half old. Send the cookie again to the
                // client with an updated expiration date.
                val = manager.createVal(key, val);
            }//ww w.  j  a  v  a  2 s.co  m

            String token = request.getHeader("X-Gerrit-Auth");
            if (val != null && token != null && token.equals(val.getAuth())) {
                okPaths.add(AccessPath.REST_API);
            }
        }
    }
}