use of com.google.gerrit.extensions.auth.oauth.OAuthVerifier in project gerrit by GerritCodeReview.
the class OAuthSession method login.
boolean login(HttpServletRequest request, HttpServletResponse response, OAuthServiceProvider oauth) throws IOException {
log.debug("Login " + this);
if (isOAuthFinal(request)) {
if (!checkState(request)) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return false;
}
log.debug("Login-Retrieve-User " + this);
OAuthToken token = oauth.getAccessToken(new OAuthVerifier(request.getParameter("code")));
user = oauth.getUserInfo(token);
if (isLoggedIn()) {
log.debug("Login-SUCCESS " + this);
authenticateAndRedirect(request, response, token);
return true;
}
response.sendError(SC_UNAUTHORIZED);
return false;
}
log.debug("Login-PHASE1 " + this);
redirectToken = request.getRequestURI();
// We are here in content of filter.
// Due to this Jetty limitation:
// https://bz.apache.org/bugzilla/show_bug.cgi?id=28323
// we cannot use LoginUrlToken.getToken() method,
// because it relies on getPathInfo() and it is always null here.
redirectToken = redirectToken.substring(request.getContextPath().length());
response.sendRedirect(oauth.getAuthorizationUrl() + "&state=" + state);
return false;
}
Aggregations