List of usage examples for com.google.api.client.googleapis.auth.oauth2 GoogleAuthorizationCodeRequestUrl setState
@Override
public GoogleAuthorizationCodeRequestUrl setState(String state)
From source file:org.vx68k.hudson.plugin.google.login.GoogleLoginService.java
License:Open Source License
/** * Handles a federated login request.// ww w . j a v a 2 s .c o m * * @param request HTTP servlet request * @param from URL path where the login request made * @return HTTP response for the request */ public HttpResponse doLogin(HttpServletRequest request, @QueryParameter String from) { GoogleLoginServiceProperty.Descriptor descriptor = getHudson() .getDescriptorByType(GoogleLoginServiceProperty.Descriptor.class); HttpSession session = request.getSession(); session.removeAttribute(LOGIN_FROM_NAME); if (from != null) { String contextPath = request.getContextPath(); // Handling a path that is not prefixed by the context path. if (!from.startsWith(contextPath)) { from = contextPath + from; } if (!from.equals(contextPath + "/login")) { session.setAttribute(LOGIN_FROM_NAME, from); } } GoogleAuthorizationCodeFlow flow = descriptor.getAuthorizationCodeFlow(); GoogleAuthorizationCodeRequestUrl url = flow.newAuthorizationUrl(); url.setRedirectUri(getRedirectUri()); url.setState(session.getId()); return HttpResponses.redirectTo(url.build()); }