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


Java FetchResponse.addAttribute方法代码示例

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


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

示例1: setAttributeExchangeValues

import org.openid4java.message.ax.FetchResponse; //导入方法依赖的package包/类
/**
 * Populate the response with claim values. If we can't find the required values with us, we
 * simply avoid sending them. An Identity Provider MAY return any subset of the following fields
 * in response to the query.
 *
 * @param claimValues Claim values.
 * @throws MessageException
 */
protected void setAttributeExchangeValues(FetchResponse response,
                                          Map<String, OpenIDClaimDTO> claimValues) throws MessageException {

    Iterator<Entry<String, OpenIDClaimDTO>> iterator = null;
    Entry<String, OpenIDClaimDTO> entry = null;
    OpenIDClaimDTO claim = null;

    iterator = claimValues.entrySet().iterator();

    while (iterator.hasNext()) {
        entry = iterator.next();
        claim = entry.getValue();
        response.addAttribute(claim.getClaimUri(), claim.getClaimValue());
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:24,代码来源:OpenIDAttributeExchange.java

示例2: addAttributes

import org.openid4java.message.ax.FetchResponse; //导入方法依赖的package包/类
/**
 * Add attributes to the response message.
 * 
 * @param response
 *            the response message to add to
 * @throws MessageException
 *             if add failed
 */
private void addAttributes(final Message response, Persona persona)
		throws MessageException {
	if (authRequest.hasExtension(AxMessage.OPENID_NS_AX)) {
		MessageExtension ext = authRequest
				.getExtension(AxMessage.OPENID_NS_AX);
		if (ext instanceof FetchRequest) {
			FetchRequest fetchReq = (FetchRequest) ext;

			FetchResponse fetchResp = FetchResponse.createFetchResponse();

			@SuppressWarnings("unchecked")
			Map<String, String> attributes = (Map<String, String>) fetchReq
					.getAttributes();

			Map<String, String> typeValueMap = persona.toTypeValueMap();
			Map<String, String> aliasValueMap = persona.toAliasValueMap();

			for (Map.Entry<String, String> entry : attributes.entrySet()) {
				String alias = entry.getKey();
				String type = entry.getValue();

				String value = typeValueMap.get(type);
				if (value == null) {
					value = aliasValueMap.get(alias);
				}
				if (value != null) {
					fetchResp.addAttribute(alias, type, value);
				}

				Attribute attribute = persona.getAttributeByType(type);
				if (attribute != null) {
					for (String v : attribute.getValues()) {
						fetchResp.addAttribute(alias, type, v);
					}
				}
			}

			response.addExtension(fetchResp);
		} else { // if (ext instanceof StoreRequest)
			throw new UnsupportedOperationException(ext.getClass()
					+ " is unsupported.");
		}
	}
}
 
开发者ID:sutra,项目名称:openid-server,代码行数:53,代码来源:ApprovingRequestProcessor.java


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