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


Java UserInfoClient.execUserInfo方法代码示例

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


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

示例1: getUserInfo

import org.xdi.oxauth.client.UserInfoClient; //导入方法依赖的package包/类
private UserInfoResponse getUserInfo(final String accessToken) {
	logger.debug("Session validation successful. Getting user information");

	final UserInfoClient userInfoClient = new UserInfoClient(this.openIdConfiguration.getUserInfoEndpoint());
	final UserInfoResponse userInfoResponse = userInfoClient.execUserInfo(accessToken);

	logger.trace("userInfoResponse.getStatus(): '{}'", userInfoResponse.getStatus());
	logger.trace("userInfoResponse.getErrorType(): '{}'", userInfoResponse.getErrorType());
	logger.debug("userInfoResponse.getClaims(): '{}'", userInfoResponse.getClaims());

	return userInfoResponse;
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:13,代码来源:OpenIdClient.java

示例2: doGet

import org.xdi.oxauth.client.UserInfoClient; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    try {
        resp.setContentType("text/html;charset=utf-8");

        PrintWriter pw = resp.getWriter();
        pw.println("<h1>RP Demo</h1>");
        pw.println("<br/><br/>");

        String accessToken = (String) req.getSession().getAttribute("access_token");
        String userInfoEndpoint = (String) req.getSession().getAttribute("userinfo_endpoint");

        LOG.trace("access_token: " + accessToken + ", userinfo_endpoint: " + userInfoEndpoint);

        UserInfoClient userInfoClient = new UserInfoClient(userInfoEndpoint);
        userInfoClient.setExecutor(Utils.createTrustAllExecutor());
        UserInfoResponse response = userInfoClient.execUserInfo(accessToken);
        LOG.trace("UserInfo response: " + response);

        if (response.getStatus() != 200) {
            pw.print("Failed to fetch user info claims");
            return;
        }

        pw.println("<h2>User Info Claims:</h2>");
        pw.println("<br/>");

        for (Map.Entry<String, List<String>> entry : response.getClaims().entrySet()) {
            pw.print("Name: " + entry.getKey() + " Value: " + entry.getValue());
            pw.println("<br/>");
        }
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:37,代码来源:RpDemoServlet.java

示例3: requestAccessToken

import org.xdi.oxauth.client.UserInfoClient; //导入方法依赖的package包/类
private String requestAccessToken(String oxAuthHost, String authorizationCode, String sessionState, String idToken, String scopes,
		String clientID, String clientPassword, String tokenURL) {
	TokenClient tokenClient1 = new TokenClient(tokenURL);

	log.info("Sending request to token endpoint");
	String redirectURL = applicationConfiguration.getLoginRedirectUrl();
	log.info("redirectURI : " + applicationConfiguration.getLoginRedirectUrl());
	TokenResponse tokenResponse = tokenClient1.execAuthorizationCode(authorizationCode, redirectURL, clientID, clientPassword);

	log.debug(" tokenResponse : " + tokenResponse);
	if (tokenResponse == null) {
		log.error("Get empty token response. User rcan't log into application");
		return OxTrustConstants.RESULT_NO_PERMISSIONS;
	}

	log.debug(" tokenResponse.getErrorType() : " + tokenResponse.getErrorType());

	String accessToken = tokenResponse.getAccessToken();
	log.debug(" accessToken : " + accessToken);

	// 2. Validate the access token
	// ValidateTokenClient validateTokenClient = new
	// ValidateTokenClient(applicationConfiguration.getOxAuthValidateTokenUrl());
	// ValidateTokenResponse response3 = validateTokenClient
	// .execValidateToken(accessToken);
	log.debug(" validating AccessToken ");

	String validateUrl = applicationConfiguration.getOxAuthTokenValidationUrl();
	ValidateTokenClient validateTokenClient = new ValidateTokenClient(validateUrl);
	ValidateTokenResponse response3 = validateTokenClient.execValidateToken(accessToken);
	log.debug(" response3.getStatus() : " + response3.getStatus());

	log.debug("validate check session status:" + response3.getStatus());
	if (response3.getErrorDescription() != null) {
		log.debug("validate token status message:" + response3.getErrorDescription());
	}

	if (response3.getStatus() == 200) {
		log.info("Session validation successful. User is logged in");
		String userInfoEndPoint = applicationConfiguration.getOxAuthUserInfo();
		UserInfoClient userInfoClient = new UserInfoClient(userInfoEndPoint);
		UserInfoResponse userInfoResponse = userInfoClient.execUserInfo(accessToken);

		this.oauthData.setHost(oxAuthHost);
		// Determine uid
		List<String> uidValues = userInfoResponse.getClaims().get(JwtClaimName.USER_NAME);
		if ((uidValues == null) || (uidValues.size() == 0)) {
			log.error("User info response doesn't contains uid claim");
			return OxTrustConstants.RESULT_NO_PERMISSIONS;
		}
		
		this.oauthData.setUserUid(uidValues.get(0));
		this.oauthData.setAccessToken(accessToken);
		this.oauthData.setAccessTokenExpirationInSeconds(response3.getExpiresIn());
		this.oauthData.setScopes(scopes);
		this.oauthData.setIdToken(idToken);
		this.oauthData.setSessionState(sessionState);

		log.info("user uid:" + oauthData.getUserUid());
		
		// Create session scope authentication service
		Component.getInstance(AuthenticationSessionService.class);

		return OxTrustConstants.RESULT_SUCCESS;
	}

	log.info("Token validation failed. User is NOT logged in");
	return OxTrustConstants.RESULT_NO_PERMISSIONS;
	
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:71,代码来源:Authenticator.java


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