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


Java Attribute.getName方法代码示例

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


在下文中一共展示了Attribute.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:AttributeQuerySchemaValidator.java

示例2: processAuthnAttributes

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
 * Add each assertion attributes and its values in the authentication data object.
 * 
 * @param assertion
 *            the assertion
 * @param authn
 *            the authentication data object
 * @throws DecryptionException
 * @throws SamlSecurityException
 */
protected void processAuthnAttributes(final Assertion assertion, final IInternalAuthentication authn)
		throws SamlSecurityException, DecryptionException {
	final List<Attribute> attributes = this.retrieveAttributes(assertion);
	if (!CollectionUtils.isEmpty(attributes)) {
		for (final Attribute attr : attributes) {
			if (attr != null) {
				final List<String> values = new ArrayList<String>();
				for (final XMLObject value : attr.getAttributeValues()) {
					if (value != null) {
						final String textContent = value.getDOM().getTextContent();
						if (StringUtils.hasText(textContent)) {
							values.add(textContent);
						}
					}
				}

				final String attrName = attr.getName();
				if (!CollectionUtils.isEmpty(values)) {
					authn.addAttribute(attrName, values);
				}
			}
		}
	}
}
 
开发者ID:mxbossard,项目名称:java-saml2-sp,代码行数:35,代码来源:AuthnResponseQueryProcessor.java

示例3: 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);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:AttributeMarshaller.java

示例4: getRolesFromAssertion

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
 * Get the username from the SAML2 Assertion
 *
 * @param assertion SAML2 assertion
 * @return username
 */
private String[] getRolesFromAssertion(Assertion assertion) {
    String[] roles = null;
    String roleClaim = getRoleClaim();
    List<AttributeStatement> attributeStatementList = assertion.getAttributeStatements();

    if (attributeStatementList != null) {
        for (AttributeStatement statement : attributeStatementList) {
            List<Attribute> attributesList = statement.getAttributes();
            for (Attribute attribute : attributesList) {
                String attributeName = attribute.getName();
                if (attributeName != null && roleClaim.equals(attributeName)) {
                    // Assumes role claim appear only once
                    Element value = attribute.getAttributeValues().get(0).getDOM();
                    String attributeValue = value.getTextContent();

                    if (log.isDebugEnabled()) {
                        log.debug("AttributeName : " + attributeName + ", AttributeValue : " + attributeValue);
                    }

                    roles = attributeValue.split(getAttributeSeperator());
                    if (log.isDebugEnabled()) {
                        log.debug("Role list : " + Arrays.toString(roles));
                    }
                }
            }
        }
    }
    return roles;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:36,代码来源:SAML2SSOAuthenticator.java

示例5: testSingleElementUnmarshall

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
    Attribute attribute = (Attribute) unmarshallElement(singleElementFile);

    String name = attribute.getName();
    assertEquals("Name was " + name + ", expected " + expectedName, expectedName, name);

}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:9,代码来源:AttributeTest.java

示例6: 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);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:16,代码来源:AttributeTest.java


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