当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponses.redirectTo方法代码示例

本文整理汇总了Java中org.kohsuke.stapler.HttpResponses.redirectTo方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponses.redirectTo方法的具体用法?Java HttpResponses.redirectTo怎么用?Java HttpResponses.redirectTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kohsuke.stapler.HttpResponses的用法示例。


在下文中一共展示了HttpResponses.redirectTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFinishLogin

import org.kohsuke.stapler.HttpResponses; //导入方法依赖的package包/类
public HttpResponse doFinishLogin(StaplerRequest request, StaplerResponse rsp) throws IOException {

        String code = request.getParameter("code");

        if (code == null || code.trim().length() == 0) {
            Log.info("doFinishLogin: missing code.");
            return HttpResponses.redirectToContextRoot();
        }

        String content = postForAccessToken(code);

        String accessToken = extractToken(content);
        updateOfflineAccessTokenForUser(accessToken);
        request.getSession().setAttribute("access_token", accessToken);

        String newProjectSetupUrl = getJenkinsRootUrl() + "/" + GithubReposController.URL;
        return HttpResponses.redirectTo(newProjectSetupUrl);
    }
 
开发者ID:groupon,项目名称:DotCi,代码行数:19,代码来源:GithubOauthLoginAction.java

示例2: doFinishLogin

import org.kohsuke.stapler.HttpResponses; //导入方法依赖的package包/类
public HttpResponse doFinishLogin(StaplerRequest request) throws IOException {
    String code = request.getParameter("code");
    
    if (StringUtils.isBlank(code)) {
        LOGGER.log(Level.SEVERE, "doFinishLogin() code = null");
        return HttpResponses.redirectToContextRoot();
    }

    DeepinToken token = new DeepinOAuthApiService(clientID, clientSecret).getTokenByAuthorizationCode(code);

    if (!token.accessToken.isEmpty()) {
        DeepinAuthenticationToken auth = new DeepinAuthenticationToken(token, clientID, clientSecret);
        SecurityContextHolder.getContext().setAuthentication(auth);
        User u = User.current();
        u.setFullName(auth.getName());
    } else {
        LOGGER.log(Level.SEVERE, "doFinishLogin() accessToken = null");
    }

    // redirect to referer
    String referer = (String) request.getSession().getAttribute(REFERER_ATTRIBUTE);
    if (referer != null) {
        return HttpResponses.redirectTo(referer);
    } else {
        return HttpResponses.redirectToContextRoot();
    }
}
 
开发者ID:Iceyer,项目名称:deepin-oauth-plugin,代码行数:28,代码来源:DeepinSecurityRealm.java

示例3: doFinishLogin

import org.kohsuke.stapler.HttpResponses; //导入方法依赖的package包/类
/**
 * This is where the user comes back to at the end of the OpenID redirect
 * ping-pong.
 * 
 * @throws HttpFailure
 * @throws VerificationException
 */
public HttpResponse doFinishLogin(StaplerRequest request) {

	String redirect = redirectUrl(request);

	try {

		AccessTokenResponse tokenResponse = ServerRequest.invokeAccessCodeToToken(getKeycloakDeployment(),
				request.getParameter("code"), redirect, null);

		String tokenString = tokenResponse.getToken();
		String idTokenString = tokenResponse.getIdToken();
		String refreashToken = tokenResponse.getRefreshToken();

		AccessToken token = AdapterRSATokenVerifier.verifyToken(tokenString, getKeycloakDeployment());
		if (idTokenString != null) {
			JWSInput input = new JWSInput(idTokenString);

			IDToken idToken = input.readJsonContent(IDToken.class);
			SecurityContextHolder.getContext()
					.setAuthentication(new KeycloakAuthentication(idToken, token, refreashToken));

			User currentUser = User.current();
			if (currentUser != null) {
				currentUser.setFullName(idToken.getPreferredUsername());

				if (!currentUser.getProperty(Mailer.UserProperty.class).hasExplicitlyConfiguredAddress()) {
					currentUser.addProperty(new Mailer.UserProperty(idToken.getEmail()));
				}
			}
		}

	} catch (Exception e) {
		LOGGER.log(Level.SEVERE, "Authentication Exception ", e);
	}

	String referer = (String) request.getSession().getAttribute(REFERER_ATTRIBUTE);
	if (referer != null) {
		return HttpResponses.redirectTo(referer);
	}
	return HttpResponses.redirectToContextRoot();
}
 
开发者ID:devlauer,项目名称:jenkins-keycloak-plugin,代码行数:49,代码来源:KeycloakSecurityRealm.java


注:本文中的org.kohsuke.stapler.HttpResponses.redirectTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。