本文整理汇总了Java中com.sun.xml.ws.api.security.trust.STSAttributeProvider类的典型用法代码示例。如果您正苦于以下问题:Java STSAttributeProvider类的具体用法?Java STSAttributeProvider怎么用?Java STSAttributeProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
STSAttributeProvider类属于com.sun.xml.ws.api.security.trust包,在下文中一共展示了STSAttributeProvider类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClaimedAttributes
import com.sun.xml.ws.api.security.trust.STSAttributeProvider; //导入依赖的package包/类
public Map<QName, List<String>> getClaimedAttributes(Subject subject, String appliesTo, String tokenType, Claims claims) {
Map<QName, List<String>> res = new HashMap<QName, List<String>>();
Assertion assertion = getSubject(claims);
if (assertion != null) {
AttributeStatement attrs = getAttributes(assertion);
for (Attribute attr : attrs.getAttributes()) {
if (!hasClaim(attr.getName(), claims)) continue;
List<String> values = new ArrayList<String>();
for (Object val : attr.getAttributes()) {
values.add(val.toString());
}
res.put(new QName(attr.getName()), values);
}
}
res.put(new QName(assertion.getSubject().getNameId().getNameQualifier(),
STSAttributeProvider.NAME_IDENTIFIER), Collections.singletonList(assertion.getSubject().getNameId().getValue()));
return res;
}
示例2: getClaimedAttributes
import com.sun.xml.ws.api.security.trust.STSAttributeProvider; //导入依赖的package包/类
@Override
public Map<QName, List<String>> getClaimedAttributes(Subject subject,
String appliesTo, String tokenType, Claims claims) {
String name = null;
Set<Principal> principals = subject.getPrincipals();
if (principals != null) {
final Iterator<Principal> iterator = principals.iterator();
while (iterator.hasNext()) {
String cnName = principals.iterator().next().getName();
int pos = cnName.indexOf("=");
name = cnName.substring(pos + 1);
break;
}
}
Map<QName, List<String>> attributes = new HashMap<QName, List<String>>();
addAttribute(attributes, STSAttributeProvider.NAME_IDENTIFIER, name);
addAttribute(attributes, "dummy_id1", "test_dummy_attribute1");
addAttribute(attributes, "userid", name);
addAttribute(attributes, "dummy_id2", "test_dummy_attribute2");
String tenantId = PropertyLoader.getInstance()
.load(COMMON_PROPERTIES_PATH).getProperty(TENANT_ID);
addAttribute(attributes, TENANT_ID, tenantId);
// claims not considered here
return attributes;
}