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


Java Attribute.setName方法代码示例

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


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

示例1: processAttribute

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {

    Attribute attrib = (Attribute) samlObject;

    if (attribute.getLocalName().equals(Attribute.NAME_ATTTRIB_NAME)) {
        attrib.setName(attribute.getValue());
    } else if (attribute.getLocalName().equals(Attribute.NAME_FORMAT_ATTRIB_NAME)) {
        attrib.setNameFormat(attribute.getValue());
    } else if (attribute.getLocalName().equals(Attribute.FRIENDLY_NAME_ATTRIB_NAME)) {
        attrib.setFriendlyName(attribute.getValue());
    } else {
        QName attribQName = XMLHelper.getNodeQName(attribute);
        if (attribute.isId()) {
            attrib.getUnknownAttributes().registerID(attribQName);
        }
        attrib.getUnknownAttributes().put(attribQName, attribute.getValue());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AttributeUnmarshaller.java

示例2: buildAttributeStatement

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
 * Build attribute statement section for a SAML Assertion
 *
 * @param pAttributeMap Map of attribute keys to values (currently strings only)
 * @return SAML Attribute Statement object for inclusion in a SAML Assertion
 */
private AttributeStatement buildAttributeStatement(Map<String, String> pAttributeMap) {
  AttributeStatement lAttributeStatement = null;
  if (pAttributeMap != null) {
    lAttributeStatement = new AttributeStatementBuilder().buildObject();

    for (Map.Entry<String, String> lAttributeEntry : pAttributeMap.entrySet()) {
      Attribute lAttribute = new AttributeBuilder().buildObject();
      lAttribute.setName(lAttributeEntry.getKey());

      // Currently just set all value as string type
      XSString lStringAttributeValue = (XSString) buildXMLObject(XSString.TYPE_NAME);
      lStringAttributeValue.setValue(lAttributeEntry.getValue());

      lAttribute.getAttributeValues().add(lStringAttributeValue);
      lAttributeStatement.getAttributes().add(lAttribute);
    }
  }
  return lAttributeStatement;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:26,代码来源:SAMLResponseCommand.java

示例3: buildAttributeStatement

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
 * Build Attribute Statement
 *
 * @param claims
 * @return AttributeStatement
 */
private AttributeStatement buildAttributeStatement(Map<String, String> claims) {
    AttributeStatement attStmt = null;
    if (claims != null) {
        attStmt = new AttributeStatementBuilder().buildObject();
        Iterator<String> ite = claims.keySet().iterator();

        for (int i = 0; i < claims.size(); i++) {
            Attribute attrib = new AttributeBuilder().buildObject();
            String claimUri = ite.next();
            attrib.setName(claimUri);
            // look
            // https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUsrManJavaAnyTypes
            XSStringBuilder stringBuilder =
                    (XSStringBuilder) Configuration.getBuilderFactory()
                            .getBuilder(XSString.TYPE_NAME);
            XSString stringValue =
                    stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME,
                            XSString.TYPE_NAME);
            stringValue.setValue(claims.get(claimUri));
            attrib.getAttributeValues().add(stringValue);
            attStmt.getAttributes().add(attrib);
        }
    }
    return attStmt;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:32,代码来源:SAMLResponseBuilder.java

示例4: createAttributeStatement

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
private AttributeStatement createAttributeStatement(HashMap<String, List<String>> attributes) {
	// create authenticationstatement object
	AttributeStatementBuilder attributeStatementBuilder = new AttributeStatementBuilder();
	AttributeStatement attributeStatement = attributeStatementBuilder.buildObject();
	
	AttributeBuilder attributeBuilder = new AttributeBuilder();
	if (attributes != null) {
		for (Map.Entry<String, List<String>> entry : attributes.entrySet()) {
			Attribute attribute = attributeBuilder.buildObject();
			attribute.setName(entry.getKey());
			
			for (String value : entry.getValue()) {
				XSStringBuilder stringBuilder = new XSStringBuilder();
				XSString attributeValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
				attributeValue.setValue(value);
				attribute.getAttributeValues().add(attributeValue);
			}
			
			attributeStatement.getAttributes().add(attribute);
		}
	}
	
	return attributeStatement;
}
 
开发者ID:rackerlabs,项目名称:saml-generator,代码行数:25,代码来源:SamlAssertionProducer.java

示例5: buildAttributeStatement

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
private AttributeStatement buildAttributeStatement() throws IllegalAccessException {
	AttributeStatement attributeStatement = buildXMLObjectDefaultName(AttributeStatement.class);

	Attribute attributeUserName = buildXMLObjectDefaultName(Attribute.class);

	XSStringBuilder stringBuilder = (XSStringBuilder)Configuration.getBuilderFactory().getBuilder(XSString.TYPE_NAME);
	XSString userNameValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
	userNameValue.setValue(MockIDPAuthnReq.userId);

	attributeUserName.getAttributeValues().add(userNameValue);
	attributeUserName.setName("uid");
	attributeStatement.getAttributes().add(attributeUserName);

	Attribute attributeLevel = buildXMLObjectDefaultName(Attribute.class);
	XSString levelValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
	levelValue.setValue(MockIDPAuthnReq.secLevel);

	attributeLevel.getAttributeValues().add(levelValue);
	attributeLevel.setName("SecurityLevel");
	attributeStatement.getAttributes().add(attributeLevel);

	return attributeStatement;

}
 
开发者ID:rasmusson,项目名称:MockIDP,代码行数:25,代码来源:MockIDPArtifactResolve.java

示例6: createAttributeStatement

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
private static AttributeStatement createAttributeStatement() {

		AttributeStatement attributeStatement = create(AttributeStatement.DEFAULT_ELEMENT_NAME);

		for (AttributeData attributeData : samlResponseData.getAttributes()) {
			Attribute attribute = create(Attribute.DEFAULT_ELEMENT_NAME);
			attribute.setFriendlyName(attributeData.getFriendlyName());
			attribute.setName(attributeData.getName());
			attribute.setNameFormat(attributeData.getNameFormat());

			XMLObjectBuilder<XSAny> builder = getXMLObjectBuilder(XSAny.TYPE_NAME);

			for (String values : attributeData.getValue().split(";", -1)) {
				XSAny value = builder
						.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME);

				value.setTextContent(values);

				attribute.getAttributeValues().add(value);
			}

			attributeStatement.getAttributes().add(attribute);
		}
		return attributeStatement;
	}
 
开发者ID:vetsin,项目名称:SamlSnort,代码行数:26,代码来源:SamlTool.java

示例7: testTransliteratedAttribute

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
 * Test creating and marshalling/unmarshalling an attribute with a name represented in two ways.
 * 
 * @throws Exception
 *           for errors
 */
@Test
public void testTransliteratedAttribute() throws Exception {
  Attribute attribute = OpenSAMLTestBase.createSamlObject(Attribute.class, Attribute.DEFAULT_ELEMENT_NAME);
  attribute.setName(AttributeConstants.EIDAS_CURRENT_FAMILY_NAME_ATTRIBUTE_NAME);
  attribute.setNameFormat(Attribute.URI_REFERENCE);

  XMLObjectBuilder<CurrentFamilyNameType> builder = OpenSAMLTestBase.getBuilder(CurrentFamilyNameType.TYPE_NAME);

  CurrentFamilyNameType name1 = builder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, CurrentFamilyNameType.TYPE_NAME);
  name1.setValue("Onasis");

  CurrentFamilyNameType name2 = builder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, CurrentFamilyNameType.TYPE_NAME);
  name2.setValue("Ωνασης");
  name2.setLatinScript(false);

  attribute.getAttributeValues().add(name1);
  attribute.getAttributeValues().add(name2);

  Element xml = OpenSAMLTestBase.marshall(attribute);

  Attribute attribute2 = OpenSAMLTestBase.unmarshall(xml, Attribute.class);
  Assert.assertEquals(((CurrentFamilyNameType) attribute.getAttributeValues().get(0)).getValue(), ((CurrentFamilyNameType) attribute2
    .getAttributeValues().get(0)).getValue());
  Assert.assertEquals(((CurrentFamilyNameType) attribute.getAttributeValues().get(1)).getValue(), ((CurrentFamilyNameType) attribute2
    .getAttributeValues().get(1)).getValue());

  // Unmarshall again, but this time from the XML string ...
  String xmlString = XMLHelper.prettyPrintXML(xml);

  Attribute attribute3 = (Attribute) OpenSAMLTestBase.unmarshallFromInputStream(Configuration.getParserPool(),
    new ByteArrayInputStream(xmlString.getBytes("UTF-8")));
  Assert.assertEquals(((CurrentFamilyNameType) attribute.getAttributeValues().get(0)).getValue(), ((CurrentFamilyNameType) attribute3
    .getAttributeValues().get(0)).getValue());
  Assert.assertEquals(((CurrentFamilyNameType) attribute.getAttributeValues().get(1)).getValue(), ((CurrentFamilyNameType) attribute3
    .getAttributeValues().get(1)).getValue());
}
 
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:43,代码来源:CurrentFamilyNameTypeTest.java

示例8: testAttributeCreate

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
 * Test that creates an attribute and places a CurrentAddessType as a value.
 * 
 * @throws Exception
 *           for errors
 */
@Test
public void testAttributeCreate() throws Exception {

  Attribute attribute = OpenSAMLTestBase.createSamlObject(Attribute.class, Attribute.DEFAULT_ELEMENT_NAME);
  attribute.getNamespaceManager().registerNamespaceDeclaration(new Namespace(EidasConstants.EIDAS_NP_NS, "eidas"));
  attribute.setName(AttributeConstants.EIDAS_CURRENT_ADDRESS_ATTRIBUTE_NAME);
  attribute.setFriendlyName(AttributeConstants.EIDAS_CURRENT_ADDRESS_ATTRIBUTE_FRIENDLY_NAME);
  attribute.setNameFormat(Attribute.URI_REFERENCE);

  XMLObjectBuilder<CurrentAddressType> builder = OpenSAMLTestBase.getBuilder(CurrentAddressType.TYPE_NAME);
  CurrentAddressType address = builder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, 
    new QName(EidasConstants.EIDAS_NP_NS, CurrentAddressType.TYPE_NAME.getLocalPart(), "eidas"));
  fill(address);

  attribute.getAttributeValues().add(address);

  Element attrElement = OpenSAMLTestBase.marshall(attribute);

  System.out.println(XMLHelper.prettyPrintXML(attrElement));

  // Make sure we inserted the correct namespace prefix while marshalling the CurrentAddressType
  Assert.assertTrue((new String(Base64.decode(attrElement.getFirstChild().getFirstChild().getNodeValue()))).startsWith("<eidas:"));

  // Unmarshall
  Attribute attribute2 = OpenSAMLTestBase.unmarshall(attrElement, Attribute.class);

  Assert.assertNotNull(attribute2);
  Assert.assertEquals(AttributeConstants.EIDAS_CURRENT_ADDRESS_ATTRIBUTE_NAME, attribute2.getName());
  Assert.assertEquals(AttributeConstants.EIDAS_CURRENT_ADDRESS_ATTRIBUTE_FRIENDLY_NAME, attribute2.getFriendlyName());

  List<XMLObject> values = attribute.getAttributeValues();
  Assert.assertTrue(values.size() == 1);
  Assert.assertTrue(values.get(0) instanceof CurrentAddressType);
  CurrentAddressType address2 = (CurrentAddressType) values.get(0);
  verify(address, address2);
}
 
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:43,代码来源:CurrentAddressTypeTest.java

示例9: createAttribute

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/** QName for the attribute resource */
public static Attribute createAttribute(String name, String friendlyName,
		String nameFormat) {
	Attribute attribute = new AttributeBuilder().buildObject();
	attribute.setName(name);
	attribute.setFriendlyName(friendlyName);
	attribute.setNameFormat(nameFormat);
	return attribute;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:10,代码来源:AttributeUtil.java

示例10: createAttribute

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
private Attribute createAttribute(String name, String value) {
	Attribute attr = SAMLUtil.buildXMLObject(Attribute.class);
	attr.setName(name);
	XSAnyBuilder builder = new XSAnyBuilder();
	XSAny ep = builder.buildObject(SAMLConstants.SAML20_NS,
			AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME,
			SAMLConstants.SAML20_PREFIX);
	ep.setTextContent(value);
	ep.getUnknownAttributes().put(AttributeUtil.XSI_TYPE_ATTRIBUTE_NAME, AttributeUtil.XS_STRING);
	ep.addNamespace(new Namespace(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX));
	attr.getAttributeValues().add(ep);
	return attr;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:14,代码来源:UserAssertionImplTest.java

示例11: testNameFailure

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
 * Tests absent Name failure.
 * 
 * @throws ValidationException
 */
public void testNameFailure() throws ValidationException {
    Attribute attribute = (Attribute) target;

    attribute.setName(null);
    assertValidationFail("Name was null, should raise a Validation Exception");

    attribute.setName("");
    assertValidationFail("Name was empty string, should raise a Validation Exception");
    
    attribute.setName("    ");
    assertValidationFail("Name was white space, should raise a Validation Exception");
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:18,代码来源:AttributeSchemaTest.java

示例12: testSingleElementMarshall

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, Attribute.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    Attribute attribute = (Attribute) buildXMLObject(qname);

    attribute.setName(expectedName);

    assertEquals(expectedDOM, attribute);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:10,代码来源:AttributeTest.java

示例13: testSingleElementOptionalAttributesMarshall

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, Attribute.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    Attribute attribute = (Attribute) buildXMLObject(qname);

    attribute.setName(expectedName);
    attribute.setNameFormat(expectedNameFormat);
    attribute.setFriendlyName(expectedFriendlyName);

    assertEquals(expectedOptionalAttributesDOM, attribute);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:12,代码来源:AttributeTest.java

示例14: buildStringAttribute

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
/**
    * Builds a SAML Attribute of type String
    * 
    * @param name
    * @param value
    * @param builderFactory
    * @return
    * @throws ConfigurationException
    */
   private Attribute buildStringAttribute(String name, String value, XMLObjectBuilderFactory builderFactory) throws ConfigurationException {
SAMLObjectBuilder attrBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
Attribute attrFirstName = (Attribute) attrBuilder.buildObject();
attrFirstName.setName(name);

// Set custom Attributes
XMLObjectBuilder stringBuilder = getSAMLBuilder().getBuilder(XSString.TYPE_NAME);
XSString attrValueFirstName = (XSString) stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
attrValueFirstName.setValue(value);

attrFirstName.getAttributeValues().add(attrValueFirstName);
return attrFirstName;
   }
 
开发者ID:mwdb,项目名称:OA2C,代码行数:23,代码来源:LocalSamlTokenFactory.java

示例15: addAttribute

import org.opensaml.saml2.core.Attribute; //导入方法依赖的package包/类
public void addAttribute(String name, String format) {
	Attribute a = SAMLUtil.buildXMLObject(Attribute.class);
	a.setName(name);
	a.setNameFormat(format);
	request.getAttributes().add(a);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:7,代码来源:OIOAttributeQuery.java


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