本文整理汇总了Java中org.opensaml.saml2.core.Attribute.getNameFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.getNameFormat方法的具体用法?Java Attribute.getNameFormat怎么用?Java Attribute.getNameFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.core.Attribute
的用法示例。
在下文中一共展示了Attribute.getNameFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateUniqueAttributeIdentifiers
import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
* Checks that all the attributes have a unique Name/NameFormat pair.
*
* @param query the attribute query to validate
*
* @throws ValidationException thrown if more than on Name/NameFormat pair is found in the list of attributes in
* this query
*/
protected void validateUniqueAttributeIdentifiers(AttributeQuery query) throws ValidationException {
List<Attribute> attributes = query.getAttributes();
HashSet<Pair<String, String>> encounteredNames = new HashSet<Pair<String, String>>();
String attributeName;
String attributeNameFormat;
for (Attribute attribute : attributes) {
attributeName = attribute.getName();
attributeNameFormat = attribute.getNameFormat();
if (DatatypeHelper.isEmpty(attributeNameFormat)) {
// SAML 2 core, sec. 2.7.3.1, if no format is specified,
// unspecified is in effect. This avoids bug in processing null value.
attributeNameFormat = Attribute.UNSPECIFIED;
}
Pair<String, String> pair = new Pair<String, String>(attributeName, attributeNameFormat);
if (encounteredNames.contains(pair)) {
throw new ValidationException(
"Attribute query contains more than one attribute with the same Name and NameFormat");
} else {
encounteredNames.add(pair);
}
}
}
示例2: marshallAttributes
import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
Attribute attribute = (Attribute) samlElement;
if (attribute.getName() != null) {
domElement.setAttributeNS(null, Attribute.NAME_ATTTRIB_NAME, attribute.getName());
}
if (attribute.getNameFormat() != null) {
domElement.setAttributeNS(null, Attribute.NAME_FORMAT_ATTRIB_NAME, attribute.getNameFormat());
}
if (attribute.getFriendlyName() != null) {
domElement.setAttributeNS(null, Attribute.FRIENDLY_NAME_ATTRIB_NAME, attribute.getFriendlyName());
}
Attr attr;
for (Entry<QName, String> entry : attribute.getUnknownAttributes().entrySet()) {
attr = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
attr.setValue(entry.getValue());
domElement.setAttributeNodeNS(attr);
if (Configuration.isIDAttribute(entry.getKey())
|| attribute.getUnknownAttributes().isIDAttribute(entry.getKey())) {
attr.getOwnerElement().setIdAttributeNode(attr, true);
}
}
}
示例3: getAttributeNameFormat
import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
* Get the name format for an attribute.
*
* @param attribute The attribute to look for.
* @param defaultFormat The format to return if the attribute is not present in idp metadata.
*/
public String getAttributeNameFormat(String attribute, String defaultFormat) {
for (Attribute attr : idpSSODescriptor.getAttributes()) {
if (attribute.equals(attr.getName())) {
return attr.getNameFormat();
}
}
return defaultFormat;
}
示例4: testSingleElementOptionalAttributesUnmarshall
import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesUnmarshall() {
Attribute attribute = (Attribute) unmarshallElement(singleElementOptionalAttributesFile);
String name = attribute.getName();
assertEquals("Name was " + name + ", expected " + expectedName, expectedName, name);
String nameFormat = attribute.getNameFormat();
assertEquals("NameFormat was " + nameFormat + ", expected " + expectedNameFormat, expectedNameFormat,
nameFormat);
String friendlyName = attribute.getFriendlyName();
assertEquals("FriendlyName was " + friendlyName + ", expected " + expectedFriendlyName, expectedFriendlyName,
friendlyName);
}