Avoid using Jenkins CI Maven Repo for snapshot artifacts

Snapshot artifacts are typically provided by the
GerritForge CI and thus do not have to be searched
in Jenkins maven repo.

Change-Id: I3472e4fb4a0c414ff00cf261e7be36815450e9ac
Avoid use of @SessionScoped for GitHub login

Guice's session scoped beans rely on the fact
that the the GuiceServlet has been captured the
request and managed in the current thread.
This assumption is not true when a request gets
filtered outside GuiceServlet, as it happens for
the GitHub OAuth Filter.

With this change the GitHub login is directly
obtained from the HTTP Servlet Request without
relying on GuiceServlet on the active request
thread.

Change-Id: Id9d687e9cb0cbab413e71ab5c369e64a10ec74f6
Share GitHub login on Gerrit filter and plugin.

Allows to sign-in to GitHub only once during
Gerrit login and then share the GitHub OAuth token
within the plugin screens.
Previously the two logins were completely isolated
and the user had to connect twice.

With this change is not possible anymore to have
multiple logins with different scopes: not a regression
but a simplification IMHO, as having multiple sessions
with multiple permissions have lead to confusion
on why GitHub permissions are requested twice.

Change-Id: I8aeb131704ee015d67b56670295c231dd6db1478
Multi-OAuth scopes configuration.

Enable the ability to have more than one scope
configured under gerrit.config and switch between
login scopes using a scope parameter in the Gerrit login.

Example use is:

GitHub's config in gerrit.config:
[github]
        scopes = USER_EMAIL,PUBLIC_REPO
        scopesPrivate = USER_EMAIL,REPO

GitHub OAuth USER_EMAIL+PUBLIC_REPO
by default at Gerrit login.

GitHub OAuth USER_EMAIL+REPO is used when loggin
in to Gerrit with /login?scope=scopesPrivate

NOTE: When logged using a specific scope, the OAuth
token is then reused throughout the Gerrit session
without having to specify the scope parameter anymore.

Change-Id: I0a6573bca6c677dd15b7878e7062bcac6b20529d
Resilience against GerritOAuth and JSESSIONID cookies lost

GitHub plugin uses two main cookies to cache OAuth
information:
- GerritOAuth to enrich HTTP requests with auth headers used by
  Gerrit HTTP authentication
- JSESSIONID to get session objects with GitHub client objects

When GerritOAuth or JSESSIONID expire, a transparent GitHub OAuth
renegotiation is needed to recreate them through a new authentication
challenge. OAuth scope is now stored in the GerritOAuth cookie in order
to re-create the same scope-level previously own.

NOTE: GerritOAuth is typically short lived to avoid
      security leak of the OAuth information. JSESSIONID could be lost
      because of workload balancing or failover.

Change-Id: I874c4ae75f2b238dccb0ec8c164628c28f1b5f01
Import of private organisations, repos and pull requests

Overall refactoring to inject GitHubLogin deep into the repo
and pull request importers and include the GitHub user's credentials
for cloning and fetching GitHub repositories.

Change-Id: I7808b09762f5af51a11d407eb68b2e7c7f5dce1b
Redundant injected GitHubLogin removed

GitHubLogin injected via Guice was unused at
GitImporter level: is injected down the chain and
only when needed.

Change-Id: I681d2b4753e525305e006891ceecd965bc2a562a
ScopedProvider is now more similar to standard Guice's Provider

By hiding the HttpServletRequest inside the HttpSessionProvider,
the ScopedProvider<T> can be now 100% compatible with the standard
Guice's Provider<T> interface.

Moving as well from constructor injection to field injection so
that the concrete implementation do not have to replicate the
constructor injection definition. Code is more compact and extensible.

The ability to get an instance by passing an actual HttpServletRequest
is kept in order to allow the standard servlet filter (outside the Guice
domain) to retrieve the object in the current session, without
having to request a Provider<HttpServletRequest> which would fail.

Change-Id: I20f32fc42ca05e9a4a140b64a1d5693d83ecf125
Allow to define different hierarchy for public vs. private repos

It is possible now to differentiate different project hierarchies
for GitHub public and private repositories.
Define the two different base projects in your [github] section using
the publicBaseProject and privateBaseProject.

If not specified in gerrit.config [github] section, the default base
project hierarchy is All-Projects.

Change-Id: Iaea7ee232dbfb2388ab8b23a84b5f397fd2aa150
Display ALL organisations, including private ones

When authorised by GitHub OAuth scope, allows to select any
type of organisation, including private ones.

Change-Id: Id2970f0f0ac09563cc801056a23ae3099e098762
Display repository private/public label

Label private vs. public repositories in list selection
of those to be imported into Gerrit.

Change-Id: I79baaab30840433bd60253eae025c703b21f7ef1
Set GitHub OAuth scope as persistent cookie

Once the GitHub OAuth scope has been chosen for login,
makes it persistent as Browser Cookie with 50 years
max age.

This allows to "remember" the desired login scope
across multiple logins to Gerrit. Scope can be changed
again specifying another "scope=X" query parameter during
login.

Change-Id: I466781c1d14a92809ac8808bee31148fe0ab47b5
GitHub OAuth authentication with Gerrit Git/HTTP protocol

It is possible now to use the standard GitHub OAuth
token on Git / HTTP with Gerrit Code Review.

The details on how GitHub OAuth Token for Git/HTTP
are described at:
https://help.github.com/articles/git-over-https-using-oauth-token

This allows to completely "shadow" your existing
GitHub repository behind a Gerrit Code Review front-end.
Using OAuth token you can automate the batch builds
over HTTP(/S) without having to manage Gerrit HTTP passwords.

NOTE: this requires the [auth.gitBasicAuth] setting
on your gerrit.config as currently there is no way to
seamlessly integrate SSO with Gerrit on Git/HTTP.
The GitHub plugin "automate" a random HTTP password
generate and use it internally for a transparent
BasicAuth, after having validated the GitHub OAuth Token.

Change-Id: I23552e1b559f50056fdc48248f44696726aa1fef
Fetch GitHub full name and e-mail from the plugin profile screen

Allows a user to select his details from the GitHub profile
displayed at /plugins/github-plugin/static/account.html

It is particularly useful when switching from a public identity
(e.g. when using GitHub plugin for OpenSource projects) to a private
use within a company. You can go to the account.html page 
and select an alternative e-mail address and Gerrit will be 
automatically updated.

Change-Id: Ib4ac50194c65336e64d2ef12e8463eccd42ad8e5
Align GitHub OAuth token expire with GerritAccount

Calculate the GerritOAuth Cookie.maxAge in the same
way that Gerrit Cached WebSessions expire.
This allows to avoid the unpleasant situations where
Gerrit session is active but all RESTFul API calls
are failing because of the missing OAuth cookie.

This was perceived as a "Internal Error" pop-up
on the Gerrit UX when the OAuth token expired.

Change-Id: I0d1f5d3be1f9257ee3b8ee5f0ac1dd809f1727fd
Remove unused imports

Change-Id: Ia1be9f982c7e71074cde2fa35582053291908712
Correct spelling of AccountImporter class

Change-Id: I6f9567da5d9211305685ed8bfa776753b0f703f6
Remove unnecessary suppression of unchecked warning

Change-Id: I47d33e98bbc1d9dcff7442b1480c2e73c308b94f
Replace deprecated HTTP.UTF_8 with Charsets.UTF_8

Change-Id: I2da2c67462043c046edf6a8ba1f99f9b46401fd7
Replace deprecated consumeContent with EntityUtils.consume

Change-Id: I7d9f83b1fae0853b98ba88b64016d0ecc507dc95