本文整理汇总了Java中org.opensaml.xml.XMLObjectBuilder类的典型用法代码示例。如果您正苦于以下问题:Java XMLObjectBuilder类的具体用法?Java XMLObjectBuilder怎么用?Java XMLObjectBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLObjectBuilder类属于org.opensaml.xml包,在下文中一共展示了XMLObjectBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Constructs the XMLObject that the given DOM Element will be unmarshalled into. If the DOM element has an XML
* Schema type defined this method will attempt to retrieve an XMLObjectBuilder, from the factory given at
* construction time, using the schema type. If no schema type is present or no builder is registered with the
* factory for the schema type, the elements QName is used. Once the builder is found the XMLObject is create by
* invoking {@link XMLObjectBuilder#buildObject(String, String, String)}. Extending classes may wish to override
* this logic if more than just schema type or element name (e.g. element attributes or content) need to be used to
* determine which XMLObjectBuilder should be used to create the XMLObject.
*
* @param domElement the DOM Element the created XMLObject will represent
*
* @return the empty XMLObject that DOM Element can be unmarshalled into
*
* @throws UnmarshallingException thrown if there is now XMLObjectBuilder registered for the given DOM Element
*/
protected XMLObject buildXMLObject(Element domElement) throws UnmarshallingException {
if (log.isTraceEnabled()) {
log.trace("Building XMLObject for {}", XMLHelper.getNodeQName(domElement));
}
XMLObjectBuilder xmlObjectBuilder;
xmlObjectBuilder = xmlObjectBuilderFactory.getBuilder(domElement);
if (xmlObjectBuilder == null) {
xmlObjectBuilder = xmlObjectBuilderFactory.getBuilder(Configuration.getDefaultProviderQName());
if (xmlObjectBuilder == null) {
String errorMsg = "Unable to locate builder for " + XMLHelper.getNodeQName(domElement);
log.error(errorMsg);
throw new UnmarshallingException(errorMsg);
} else {
if (log.isTraceEnabled()) {
log.trace("No builder was registered for {} but the default builder {} was available, using it.",
XMLHelper.getNodeQName(domElement), xmlObjectBuilder.getClass().getName());
}
}
}
return xmlObjectBuilder.buildObject(domElement);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:AbstractXMLObjectUnmarshaller.java
示例2: createXSString
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Utility method for creating an OpenSAML object given its type and assigns the value.
*
* @param clazz
* the class to create
* @param value
* the string value to assign
* @return the XML object or {@code null} if value is {@code null}
*/
private <T extends XSString> T createXSString(Class<T> clazz, String value) {
if (value == null) {
return null;
}
QName elementName = null;
String localName = null;
try {
elementName = (QName) clazz.getDeclaredField("DEFAULT_ELEMENT_NAME").get(null);
localName = (String) clazz.getDeclaredField("DEFAULT_ELEMENT_LOCAL_NAME").get(null);
}
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | SecurityException e) {
throw new RuntimeException(e);
}
XMLObjectBuilder<?> builder = Configuration.getBuilderFactory().getBuilder(elementName);
XMLObject object = builder.buildObject(new QName(this.getElementQName().getNamespaceURI(), localName, this.getElementQName().getPrefix()));
T xsstring = clazz.cast(object);
xsstring.setValue(value);
return xsstring;
}
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:29,代码来源:CurrentAddressStructuredTypeImpl.java
示例3: createAttributeStatement
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的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
示例4: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Create XMLObject from a given QName
*
* @param objectQName: QName of the object to be built into a XMLObject
* @return built xmlObject
* @throws EntitlementException
*/
private static XMLObject buildXMLObject(QName objectQName) throws EntitlementException {
XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
if (builder == null) {
throw new EntitlementException("Unable to retrieve builder for object QName "
+ objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
objectQName.getPrefix());
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:18,代码来源:WSXACMLMessageReceiver.java
示例5: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Builds SAML Elements
*
* @param objectQName
* @return
* @throws SSOAgentException
*/
private static XMLObject buildXMLObject(QName objectQName) throws SSOAgentException {
doBootstrap();
XMLObjectBuilder builder =
org.opensaml.xml.Configuration.getBuilderFactory()
.getBuilder(objectQName);
if (builder == null) {
throw new SSOAgentException("Unable to retrieve builder for object QName " +
objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
objectQName.getPrefix());
}
开发者ID:wso2-extensions,项目名称:identity-agent-sso,代码行数:20,代码来源:SSOAgentUtils.java
示例6: createSamlObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Utility method for creating an OpenSAML object given its element name.
*
* @param clazz
* the class to create
* @param elementName
* the element name for the XML object to create
* @return the XML object
*/
public static <T extends XMLObject> T createSamlObject(Class<T> clazz, QName elementName) {
if (!XMLObject.class.isAssignableFrom(clazz)) {
throw new RuntimeException(String.format("%s is not a XMLObject class", clazz.getName()));
}
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
XMLObjectBuilder<?> builder = builderFactory.getBuilder(elementName);
if (builder == null) {
// No builder registered for the given element name. Try creating a builder for the default element name.
builder = builderFactory.getBuilder(getDefaultElementName(clazz));
}
Object object = builder.buildObject(elementName);
return clazz.cast(object);
}
开发者ID:litsec,项目名称:eidas-opensaml,代码行数:23,代码来源:OpenSAMLTestBase.java
示例7: testTransliteratedAttribute
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的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.xml.XMLObjectBuilder; //导入依赖的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: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Build a new empty object of the requested type.
*
* The requested type must have a DEFAULT_ELEMENT_NAME attribute describing the element type as a QName.
*
* @param <T> SAML Object type
*/
@SuppressWarnings("unchecked")
public static <T extends XMLObject> T buildXMLObject(Class<T> type) {
try {
QName objectQName = getElementQName(type);
XMLObjectBuilder<T> builder = Configuration.getBuilderFactory().getBuilder(objectQName);
if (builder == null) {
throw new InvalidParameterException("No builder exists for object: " + objectQName.getLocalPart());
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(), objectQName.getPrefix());
} catch (SecurityException e) {
throw new RuntimeException(e);
}
}
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:21,代码来源:SAMLUtil.java
示例10: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Builds SAML Objects for a given QName
*
* @param pQName Element QName for the SAML Object
* @return SAML Object
*/
private static XMLObject buildXMLObject(QName pQName) {
XMLObjectBuilder lObjectBuilder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(pQName);
if (lObjectBuilder == null) {
throw new ExInternal("Cannot get builder for QName: " + pQName);
}
return lObjectBuilder.buildObject(pQName.getNamespaceURI(), pQName.getLocalPart(), pQName.getPrefix());
}
开发者ID:Fivium,项目名称:FOXopen,代码行数:16,代码来源:SAMLResponseCommand.java
示例11: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
protected static XMLObject buildXMLObject(QName objectQName) throws IdentityProviderException {
XMLObjectBuilder builder = Configuration.getBuilderFactory().getBuilder(objectQName);
if (builder == null) {
throw new IdentityProviderException("Unable to retrieve builder for object QName " + objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(), objectQName.getPrefix());
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:8,代码来源:SAML2TokenBuilder.java
示例12: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Builds SAML Elements
*
* @param objectQName
* @return
* @throws SAMLSSOException
*/
private static XMLObject buildXMLObject(QName objectQName) throws SAMLSSOException {
XMLObjectBuilder builder =
org.opensaml.xml.Configuration.getBuilderFactory()
.getBuilder(objectQName);
if (builder == null) {
throw new SAMLSSOException("Unable to retrieve builder for object QName " +
objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
objectQName.getPrefix());
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:19,代码来源:SSOUtils.java
示例13: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
public static XMLObject buildXMLObject(QName objectQName) throws Exception {
XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(
objectQName);
if (builder == null) {
throw new Exception("Unable to retrieve builder for object QName " + objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
objectQName.getPrefix());
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:11,代码来源:Util.java
示例14: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Builds SAML Elements
*
* @param objectQName
* @return
* @throws IdentityException
*/
private XMLObject buildXMLObject(QName objectQName) throws IdentityException {
XMLObjectBuilder builder =
org.opensaml.xml.Configuration.getBuilderFactory()
.getBuilder(objectQName);
if (builder == null) {
throw IdentityException.error("Unable to retrieve builder for object QName " +
objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
objectQName.getPrefix());
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:19,代码来源:DefaultSSOSigner.java
示例15: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Create XMLObject from a given QName
*
* @param objectQName: QName of the object to be built into a XMLObject
* @return built xmlObject
* @throws EntitlementProxyException
*/
private XMLObject buildXMLObject(QName objectQName) throws EntitlementProxyException {
XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
if (builder == null) {
throw new EntitlementProxyException("Unable to retrieve builder for object QName "
+ objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
objectQName.getPrefix());
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:18,代码来源:WSXACMLEntitlementServiceClient.java
示例16: sign
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Signs the given metadata document root.
*
* @param metadata metadata document
* @param signingCredential credential used to sign the document
*/
private static void sign(SignableSAMLObject metadata, Credential signingCredential) {
XMLObjectBuilder<Signature> sigBuilder = Configuration.getBuilderFactory().getBuilder(
Signature.DEFAULT_ELEMENT_NAME);
Signature signature = sigBuilder.buildObject(Signature.DEFAULT_ELEMENT_NAME);
signature.setSigningCredential(signingCredential);
metadata.setSignature(signature);
try {
Signer.signObject(signature);
} catch (SignatureException e) {
log.error("Error when attempting to sign object", e);
System.exit(1);
}
}
开发者ID:apigee,项目名称:java-opensaml2,代码行数:21,代码来源:MetadataTool.java
示例17: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
/**
* Builds the requested XMLObject.
*
* @param objectQName name of the XMLObject
*
* @return the build XMLObject
*/
public XMLObject buildXMLObject(QName objectQName){
XMLObjectBuilder builder = Configuration.getBuilderFactory().getBuilder(objectQName);
if(builder == null){
fail("Unable to retrieve builder for object QName " + objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(), objectQName.getPrefix());
}
开发者ID:apigee,项目名称:java-opensaml2,代码行数:15,代码来源:BaseTestCase.java
示例18: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
public static <T extends XMLObject> T buildXMLObject(Class<T> clazz, QName objectQName) {
XMLObjectBuilder<T> builder = Configuration.getBuilderFactory().getBuilder(objectQName);
if (builder == null) {
throw new RuntimeException("Unable to retrieve builder for object QName " + objectQName);
}
return builder.buildObject(objectQName);
}
开发者ID:e-Contract,项目名称:dssp,代码行数:8,代码来源:TestUtils.java
示例19: buildStringAttribute
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的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
示例20: buildXMLObject
import org.opensaml.xml.XMLObjectBuilder; //导入依赖的package包/类
public static XMLObject buildXMLObject(QName objectQName)
throws Exception {
XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
if (builder == null) {
throw new Exception("Unable to retrieve builder for object QName "
+ objectQName);
}
return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
objectQName.getPrefix());
}
开发者ID:wso2,项目名称:carbon-commons,代码行数:12,代码来源:Util.java
注:本文中的org.opensaml.xml.XMLObjectBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论