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


Java FetchResponse.getAttributeValues方法代码示例

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


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

示例1: receiveAttributeExchange

import org.openid4java.message.ax.FetchResponse; //导入方法依赖的package包/类
/**
 * @param httpReq
 * @param authSuccess
 * @throws MessageException 
 */
private void receiveAttributeExchange(HttpServletRequest httpReq,
		AuthSuccess authSuccess) throws MessageException {
	if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
		FetchResponse fetchResp = (FetchResponse) authSuccess
				.getExtension(AxMessage.OPENID_NS_AX);

		// List emails = fetchResp.getAttributeValues("email");
		// String email = (String) emails.get(0);

		List aliases = fetchResp.getAttributeAliases();
		Map attributes = new LinkedHashMap();
		for (Iterator iter = aliases.iterator(); iter.hasNext();) {
			String alias = (String) iter.next();
			List values = fetchResp.getAttributeValues(alias);
			if (values.size() > 0) {
				String[] arr = new String[values.size()];
				values.toArray(arr);
				attributes.put(alias, StringUtils.join(arr));
			}
		}
		httpReq.setAttribute("attributes", attributes);
	}
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:29,代码来源:ConsumerServlet.java

示例2: receiveAttributeExchange

import org.openid4java.message.ax.FetchResponse; //导入方法依赖的package包/类
/**
 * @param model
 * @param authSuccess
 * @throws MessageException
 */
private void receiveAttributeExchange(Map<Object, Object> model, AuthSuccess authSuccess) throws MessageException {
	if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
		FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
		List<String> aliases = fetchResp.getAttributeAliases();
		Map<String, String> attributes = new LinkedHashMap<>();
           for (String alias : aliases) {
               List<String> values = fetchResp.getAttributeValues(alias);
               if (values.size() > 0) {
                   String[] arr = new String[values.size()];
                   values.toArray(arr);
                   attributes.put(alias, arr[0]);
               }
           }
		model.put("attributes", attributes);
	}
}
 
开发者ID:AveryRegier,项目名称:club-tracker,代码行数:22,代码来源:ConsumerService.java

示例3: verifyResponse

import org.openid4java.message.ax.FetchResponse; //导入方法依赖的package包/类
public Identifier verifyResponse(HttpServletRequest httpReq) {
	try {
		// extract the parameters from the authentication response
		// (which comes in as a HTTP request from the OpenID provider)
		ParameterList response = new ParameterList(httpReq.getParameterMap());

		// retrieve the previously stored discovery information
		DiscoveryInformation discovered = (DiscoveryInformation) httpReq.getSession().getAttribute(OpenIdConstants.OPENID_DISC);

		// extract the receiving URL from the HTTP request
		StringBuffer receivingURL = httpReq.getRequestURL();
		String queryString = httpReq.getQueryString();
		if (queryString != null && queryString.length() > 0)
			receivingURL.append("?").append(httpReq.getQueryString());

		// verify the response; ConsumerManager needs to be the same
		// (static) instance used to place the authentication request
		VerificationResult verification = manager.verify(receivingURL.toString(), response, discovered);

		// examine the verification result and extract the verified
		// identifier
		Identifier verified = verification.getVerifiedId();
		if (verified != null) {
			AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();

			if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
				FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);

				List<?> emails = fetchResp.getAttributeValues("email");
				String email = (String) emails.get(0);
				
				httpReq.getSession().setAttribute(OpenIdConstants.OPENID_SESSION_VAR, new OpenIDUser(email));
			}

			return verified; // success
		}
	} catch (OpenIDException e) {
		// present error to the user
	}

	return null;
}
 
开发者ID:hburgmeier,项目名称:jerseyoauth2,代码行数:43,代码来源:OpenIdConsumer.java


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