本文整理汇总了Java中org.opensaml.xml.XMLObjectBuilderFactory类的典型用法代码示例。如果您正苦于以下问题:Java XMLObjectBuilderFactory类的具体用法?Java XMLObjectBuilderFactory怎么用?Java XMLObjectBuilderFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMLObjectBuilderFactory类属于org.opensaml.xml包,在下文中一共展示了XMLObjectBuilderFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildSOAPMessage
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
@Override
protected Envelope buildSOAPMessage(final SAMLObject samlMessage) {
final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
final SOAPObjectBuilder<Envelope> envBuilder =
(SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
final Envelope envelope = envBuilder.buildObject(
SOAPConstants.SOAP11_NS, Envelope.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);
final SOAPObjectBuilder<Body> bodyBuilder =
(SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
final Body body = bodyBuilder.buildObject(
SOAPConstants.SOAP11_NS, Body.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例2: buildRSAKeyValue
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
* Builds an {@link RSAKeyValue} XMLObject from the Java security RSA public key type.
*
* @param rsaPubKey a native Java {@link RSAPublicKey}
* @return an {@link RSAKeyValue} XMLObject
*/
public static RSAKeyValue buildRSAKeyValue(RSAPublicKey rsaPubKey) {
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
RSAKeyValue rsaKeyValue = (RSAKeyValue) builderFactory
.getBuilder(RSAKeyValue.DEFAULT_ELEMENT_NAME)
.buildObject(RSAKeyValue.DEFAULT_ELEMENT_NAME);
Modulus modulus = (Modulus) builderFactory
.getBuilder(Modulus.DEFAULT_ELEMENT_NAME)
.buildObject(Modulus.DEFAULT_ELEMENT_NAME);
Exponent exponent = (Exponent) builderFactory
.getBuilder(Exponent.DEFAULT_ELEMENT_NAME)
.buildObject(Exponent.DEFAULT_ELEMENT_NAME);
modulus.setValueBigInt(rsaPubKey.getModulus());
rsaKeyValue.setModulus(modulus);
exponent.setValueBigInt(rsaPubKey.getPublicExponent());
rsaKeyValue.setExponent(exponent);
return rsaKeyValue;
}
示例3: buildDSAKeyValue
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
* Builds a {@link DSAKeyValue} XMLObject from the Java security DSA public key type.
*
* @param dsaPubKey a native Java {@link DSAPublicKey}
* @return an {@link DSAKeyValue} XMLObject
*/
public static DSAKeyValue buildDSAKeyValue(DSAPublicKey dsaPubKey) {
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
DSAKeyValue dsaKeyValue = (DSAKeyValue) builderFactory
.getBuilder(DSAKeyValue.DEFAULT_ELEMENT_NAME)
.buildObject(DSAKeyValue.DEFAULT_ELEMENT_NAME);
Y y = (Y) builderFactory.getBuilder(Y.DEFAULT_ELEMENT_NAME).buildObject(Y.DEFAULT_ELEMENT_NAME);
G g = (G) builderFactory.getBuilder(G.DEFAULT_ELEMENT_NAME).buildObject(G.DEFAULT_ELEMENT_NAME);
P p = (P) builderFactory.getBuilder(P.DEFAULT_ELEMENT_NAME).buildObject(P.DEFAULT_ELEMENT_NAME);
Q q = (Q) builderFactory.getBuilder(Q.DEFAULT_ELEMENT_NAME).buildObject(Q.DEFAULT_ELEMENT_NAME);
y.setValueBigInt(dsaPubKey.getY());
dsaKeyValue.setY(y);
g.setValueBigInt(dsaPubKey.getParams().getG());
dsaKeyValue.setG(g);
p.setValueBigInt(dsaPubKey.getParams().getP());
dsaKeyValue.setP(p);
q.setValueBigInt(dsaPubKey.getParams().getQ());
dsaKeyValue.setQ(q);
return dsaKeyValue;
}
示例4: Encrypter
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
* Constructor.
*
*/
public Encrypter() {
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
encryptedDataUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedData.DEFAULT_ELEMENT_NAME);
encryptedKeyUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedKey.DEFAULT_ELEMENT_NAME);
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
keyInfoBuilder = (XMLSignatureBuilder<KeyInfo>) builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);
jcaProviderName = null;
}
示例5: buildSOAPMessage
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
* Builds the SOAP message to be encoded.
*
* @param samlMessage body of the SOAP message
*
* @return the SOAP message
*/
@SuppressWarnings("unchecked")
protected Envelope buildSOAPMessage(SAMLObject samlMessage) {
log.debug("Building SOAP message");
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory
.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
Envelope envelope = envBuilder.buildObject();
log.debug("Adding SAML message to the SOAP message's body");
SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
.getBuilder(Body.DEFAULT_ELEMENT_NAME);
Body body = bodyBuilder.buildObject();
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例6: buildSOAPMessage
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
* Builds the SOAP message to be encoded.
*
* @param samlMessage body of the SOAP message
*
* @return the SOAP message
*/
@SuppressWarnings("unchecked")
protected Envelope buildSOAPMessage(SAMLObject samlMessage) {
if (log.isDebugEnabled()) {
log.debug("Building SOAP message");
}
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory
.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
Envelope envelope = envBuilder.buildObject();
if (log.isDebugEnabled()) {
log.debug("Adding SAML message to the SOAP message's body");
}
SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
.getBuilder(Body.DEFAULT_ELEMENT_NAME);
Body body = bodyBuilder.buildObject();
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例7: getSAMLBuilder
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
private static XMLObjectBuilderFactory getSAMLBuilder() throws ConfigurationException {
if (builderFactory == null) {
// OpenSAML 2.3
DefaultBootstrap.bootstrap();
builderFactory = Configuration.getBuilderFactory();
nameIdBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(NameID.DEFAULT_ELEMENT_NAME);
confirmationMethodBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
subjectConfirmationBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
subjectBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Subject.DEFAULT_ELEMENT_NAME);
attrStatementBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AttributeStatement.DEFAULT_ELEMENT_NAME);
audienceRestrictionnBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AudienceRestriction.DEFAULT_ELEMENT_NAME);
audienceBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Audience.DEFAULT_ELEMENT_NAME);
authStatementBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnStatement.DEFAULT_ELEMENT_NAME);
authContextBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnContext.DEFAULT_ELEMENT_NAME);
authContextClassRefBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
issuerBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
assertionBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
}
return builderFactory;
}
示例8: SOAP11Encoder
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/** Constructor. */
@SuppressWarnings("unchecked")
public SOAP11Encoder() {
super();
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
}
示例9: HandlerChainAwareHTTPSOAP11Encoder
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/** Constructor. */
public HandlerChainAwareHTTPSOAP11Encoder() {
super();
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
}
示例10: createSamlObject
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的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);
}
示例11: testMarshallAndUnmarshallStructured
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
* Tests marshalling and unmarshalling of {@code CurrentAddressStructuredType}.
*
* @throws Exception
* for errors
*/
@Test
public void testMarshallAndUnmarshallStructured() throws Exception {
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
Object object = builderFactory.getBuilder(CurrentAddressStructuredType.TYPE_NAME).buildObject(CurrentAddressStructuredType.TYPE_NAME
.getNamespaceURI(), CurrentAddressStructuredType.TYPE_NAME.getLocalPart(), "eidas");
CurrentAddressStructuredType address = CurrentAddressStructuredType.class.cast(object);
fill(address);
// Marshall
Element element = OpenSAMLTestBase.marshall(address);
Assert.assertNotNull(element);
// Unmarshall element
CurrentAddressStructuredType address2 = OpenSAMLTestBase.unmarshall(element, CurrentAddressStructuredType.class);
verify(address, address2);
// Test unmarshall again
String xml = XMLHelper.prettyPrintXML(element);
Document doc = Configuration.getParserPool().parse(new ByteArrayInputStream(xml.toString().getBytes("UTF-8")));
CurrentAddressStructuredType address3 = OpenSAMLTestBase.unmarshall(doc.getDocumentElement(), CurrentAddressStructuredType.class);
verify(address, address3);
}
示例12: testMarshallAndUnmarshall
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
* Tests marshalling and unmarshalling of {@code CurrentAddressType}.
*
* @throws Exception
* for errors
*/
@Test
public void testMarshallAndUnmarshall() throws Exception {
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
Object object = builderFactory.getBuilder(CurrentAddressType.TYPE_NAME).buildObject(CurrentAddressType.TYPE_NAME.getNamespaceURI(),
CurrentAddressType.TYPE_NAME.getLocalPart(), "eidas");
CurrentAddressType address = CurrentAddressType.class.cast(object);
fill(address);
// Marshall
Element element = OpenSAMLTestBase.marshall(address);
Assert.assertNotNull(element);
// Verify that we got one child element that is the Base64 encoding.
NodeList childs = element.getChildNodes();
Assert.assertEquals(1, childs.getLength());
String base64 = childs.item(0).getNodeValue();
byte[] bytes = Base64.decode(base64);
Assert.assertTrue((new String(bytes)).startsWith("<eidas:"));
// Unmarshall element
CurrentAddressType address2 = OpenSAMLTestBase.unmarshall(element, CurrentAddressType.class);
verify(address, address2);
String swedishEidString = address2.toSwedishEidString();
Assert.assertEquals("LocatorDesignator=6%20tr;LocatorName=10;Thoroughfare=Korta%20gatan;PostName=Solna;PostCode=19174", swedishEidString);
// Test unmarshall again
String xml = XMLHelper.prettyPrintXML(element);
Document doc = Configuration.getParserPool().parse(new ByteArrayInputStream(xml.toString().getBytes("UTF-8")));
CurrentAddressType address3 = OpenSAMLTestBase.unmarshall(doc.getDocumentElement(), CurrentAddressType.class);
verify(address, address3);
}
示例13: getMetadata
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
* Gets the metadata from every registered provider and places each within a newly created EntitiesDescriptor.
*
* {@inheritDoc}
*/
public XMLObject getMetadata() throws MetadataProviderException {
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SAMLObjectBuilder<EntitiesDescriptor> builder = (SAMLObjectBuilder<EntitiesDescriptor>) builderFactory
.getBuilder(EntitiesDescriptor.DEFAULT_ELEMENT_NAME);
EntitiesDescriptor metadataRoot = builder.buildObject();
Lock readLock = providerLock.readLock();
readLock.lock();
XMLObject providerMetadata;
try {
for (MetadataProvider provider : providers) {
providerMetadata = provider.getMetadata();
if (providerMetadata instanceof EntitiesDescriptor) {
metadataRoot.getEntitiesDescriptors().add((EntitiesDescriptor) providerMetadata);
} else if (providerMetadata instanceof EntityDescriptor) {
metadataRoot.getEntityDescriptors().add((EntityDescriptor) providerMetadata);
}
}
} catch (MetadataProviderException e) {
throw e;
} finally {
readLock.unlock();
}
return metadataRoot;
}
示例14: buildStringAttribute
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的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;
}
示例15: generateSOAPEnvelope
import org.opensaml.xml.XMLObjectBuilderFactory; //导入依赖的package包/类
/**
*
* @param artifactResolutionRequest
* @return
*/
protected Envelope generateSOAPEnvelope(ArtifactResolve artifactResolutionRequest) {
XMLObjectBuilderFactory xmlObjectBuilderFactory = Configuration.getBuilderFactory();
Envelope envelope = (Envelope) xmlObjectBuilderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME).buildObject(Envelope.DEFAULT_ELEMENT_NAME);
Body body = (Body) xmlObjectBuilderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME).buildObject(Body.DEFAULT_ELEMENT_NAME);
body.getUnknownXMLObjects().add(artifactResolutionRequest);
envelope.setBody(body);
return envelope;
}