本文整理汇总了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());
}
}
示例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.");
}
}
}