本文整理汇总了Java中org.opensaml.xml.util.XMLHelper类的典型用法代码示例。如果您正苦于以下问题:Java XMLHelper类的具体用法?Java XMLHelper怎么用?Java XMLHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMLHelper类属于org.opensaml.xml.util包,在下文中一共展示了XMLHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: marshallAttributes
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
ChannelBindings cb = (ChannelBindings) xmlObject;
if (cb.getType() != null) {
domElement.setAttributeNS(null, ChannelBindings.TYPE_ATTRIB_NAME, cb.getType());
}
if (cb.isSOAP11MustUnderstandXSBoolean() != null) {
XMLHelper.marshallAttribute(ChannelBindings.SOAP11_MUST_UNDERSTAND_ATTR_NAME,
cb.isSOAP11MustUnderstandXSBoolean().toString(), domElement, false);
}
if (cb.getSOAP11Actor() != null) {
XMLHelper.marshallAttribute(ChannelBindings.SOAP11_ACTOR_ATTR_NAME,
cb.getSOAP11Actor(), domElement, false);
}
}
示例2: processAttribute
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
Policy policy = (Policy) xmlObject;
QName nameQName = new QName(Policy.NAME_ATTRIB_NAME);
QName attribQName =
XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
if (nameQName.equals(attribQName)) {
policy.setName(attribute.getValue());
} else if (Policy.WSU_ID_ATTR_NAME.equals(attribQName)) {
policy.setWSUId(attribute.getValue());
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
} else {
XMLHelper.unmarshallToAttributeMap(policy.getUnknownAttributes(), attribute);
}
}
示例3: marshallAttributes
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
PolicyReference pr = (PolicyReference) xmlObject;
if (pr.getURI() != null) {
domElement.setAttributeNS(null, PolicyReference.URI_ATTRIB_NAME, pr.getURI());
}
if (pr.getDigest() != null) {
domElement.setAttributeNS(null, PolicyReference.DIGEST_ATTRIB_NAME, pr.getDigest());
}
if (pr.getDigestAlgorithm() != null) {
domElement.setAttributeNS(null, PolicyReference.DIGEST_ALGORITHM_ATTRIB_NAME, pr.getDigestAlgorithm());
}
XMLHelper.marshallAttributeMap(pr.getUnknownAttributes(), domElement);
}
示例4: processAttribute
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
PolicyReference pr = (PolicyReference) xmlObject;
QName uriName = new QName(PolicyReference.URI_ATTRIB_NAME);
QName digestName = new QName(PolicyReference.DIGEST_ATTRIB_NAME);
QName digestAlgorithmName = new QName(PolicyReference.DIGEST_ALGORITHM_ATTRIB_NAME);
QName attribQName =
XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute .getPrefix());
if (uriName.equals(attribQName)) {
pr.setURI(attribute.getValue());
} else if (digestName.equals(attribQName)) {
pr.setDigest(attribute.getValue());
} else if (digestAlgorithmName.equals(attribQName)) {
pr.setDigestAlgorithm(attribute.getValue());
} else {
XMLHelper.unmarshallToAttributeMap(pr.getUnknownAttributes(), attribute);
}
}
示例5: processAttribute
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
AffiliationDescriptor descriptor = (AffiliationDescriptor) samlObject;
if (attribute.getLocalName().equals(AffiliationDescriptor.OWNER_ID_ATTRIB_NAME)) {
descriptor.setOwnerID(attribute.getValue());
} else if (attribute.getLocalName().equals(AffiliationDescriptor.ID_ATTRIB_NAME)) {
descriptor.setID(attribute.getValue());
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
} else if (attribute.getLocalName().equals(TimeBoundSAMLObject.VALID_UNTIL_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
descriptor.setValidUntil(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(CacheableSAMLObject.CACHE_DURATION_ATTRIB_NAME)) {
descriptor.setCacheDuration(XMLHelper.durationToLong(attribute.getValue()));
} else {
QName attribQName = XMLHelper.getNodeQName(attribute);
if (attribute.isId()) {
descriptor.getUnknownAttributes().registerID(attribQName);
}
descriptor.getUnknownAttributes().put(attribQName, attribute.getValue());
}
}
示例6: marshallAttributes
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
AttributeValueType attributeValue = (AttributeValueType) xmlObject;
if(!DatatypeHelper.isEmpty(attributeValue.getDataType())){
domElement.setAttributeNS(null,AttributeAssignmentType.DATA_TYPE_ATTRIB_NAME, attributeValue.getDataType());
}
Attr attribute;
for (Entry<QName, String> entry : attributeValue.getUnknownAttributes().entrySet()) {
attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
attribute.setValue(entry.getValue());
domElement.setAttributeNodeNS(attribute);
if (Configuration.isIDAttribute(entry.getKey())
|| attributeValue.getUnknownAttributes().isIDAttribute(entry.getKey())) {
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
}
}
}
示例7: marshallAttributes
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
SubjectConfirmation sc = (SubjectConfirmation) samlObject;
if (sc.isSOAP11MustUnderstandXSBoolean() != null) {
XMLHelper.marshallAttribute(SubjectConfirmation.SOAP11_MUST_UNDERSTAND_ATTR_NAME,
sc.isSOAP11MustUnderstandXSBoolean().toString(), domElement, false);
}
if (sc.getSOAP11Actor() != null) {
XMLHelper.marshallAttribute(SubjectConfirmation.SOAP11_ACTOR_ATTR_NAME,
sc.getSOAP11Actor(), domElement, false);
}
if (sc.getMethod() != null) {
domElement.setAttributeNS(null, SubjectConfirmation.METHOD_ATTRIB_NAME, sc.getMethod());
}
}
示例8: unmarshallSchemaInstanceAttributes
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/**
* Unmarshalls the XSI type, schemaLocation, and noNamespaceSchemaLocation attributes.
*
* @param xmlObject the xmlObject to recieve the namespace decleration
* @param attribute the namespace decleration attribute
*/
protected void unmarshallSchemaInstanceAttributes(XMLObject xmlObject, Attr attribute) {
QName attribName = XMLHelper.getNodeQName(attribute);
if (XMLConstants.XSI_TYPE_ATTRIB_NAME.equals(attribName)) {
log.trace("Saw XMLObject {} with an xsi:type of: {}", xmlObject.getElementQName(), attribute.getValue());
} else if (XMLConstants.XSI_SCHEMA_LOCATION_ATTRIB_NAME.equals(attribName)) {
log.trace("Saw XMLObject {} with an xsi:schemaLocation of: {}", xmlObject.getElementQName(),
attribute.getValue());
xmlObject.setSchemaLocation(attribute.getValue());
} else if (XMLConstants.XSI_NO_NAMESPACE_SCHEMA_LOCATION_ATTRIB_NAME.equals(attribName)) {
log.trace("Saw XMLObject {} with an xsi:noNamespaceSchemaLocation of: {}", xmlObject.getElementQName(),
attribute.getValue());
xmlObject.setNoNamespaceSchemaLocation(attribute.getValue());
} else if (XMLConstants.XSI_NIL_ATTRIB_NAME.equals(attribName)) {
log.trace("Saw XMLObject {} with an xsi:nil of: {}", xmlObject.getElementQName(),
attribute.getValue());
xmlObject.setNil(XSBooleanValue.valueOf(attribute.getValue()));
}
}
示例9: buildXMLObject
import org.opensaml.xml.util.XMLHelper; //导入依赖的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);
}
示例10: marshallAttributes
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
public void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException {
AuthorityBinding authorityBinding = (AuthorityBinding) samlElement;
if (authorityBinding.getAuthorityKind() != null) {
QName authKind = authorityBinding.getAuthorityKind();
domElement.setAttributeNS(null, AuthorityBinding.AUTHORITYKIND_ATTRIB_NAME, XMLHelper
.qnameToContentString(authKind));
}
if (authorityBinding.getBinding() != null) {
domElement.setAttributeNS(null, AuthorityBinding.BINDING_ATTRIB_NAME, authorityBinding.getBinding());
}
if (authorityBinding.getLocation() != null) {
domElement.setAttributeNS(null, AuthorityBinding.LOCATION_ATTRIB_NAME, authorityBinding.getLocation());
}
}
示例11: createRequestEntity
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/**
* Creates the request entity that makes up the POST message body.
*
* @param message message to be sent
* @param charset character set used for the message
*
* @return request entity that makes up the POST message body
*
* @throws SOAPClientException thrown if the message could not be marshalled
*/
protected RequestEntity createRequestEntity(Envelope message, Charset charset) throws SOAPClientException {
try {
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(message);
ByteArrayOutputStream arrayOut = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(arrayOut, charset);
if (log.isDebugEnabled()) {
log.debug("Outbound SOAP message is:\n" + XMLHelper.prettyPrintXML(marshaller.marshall(message)));
}
XMLHelper.writeNode(marshaller.marshall(message), writer);
return new ByteArrayRequestEntity(arrayOut.toByteArray(), "text/xml");
} catch (MarshallingException e) {
throw new SOAPClientException("Unable to marshall SOAP envelope", e);
}
}
示例12: deflateAndBase64Encode
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/**
* DEFLATE (RFC1951) compresses the given SAML message.
*
* @param message SAML message
*
* @return DEFLATE compressed message
*
* @throws MessageEncodingException thrown if there is a problem compressing the message
*/
protected String deflateAndBase64Encode(SAMLObject message) throws MessageEncodingException {
log.debug("Deflating and Base64 encoding SAML message");
try {
String messageStr = XMLHelper.nodeToString(marshallMessage(message));
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(bytesOut, deflater);
deflaterStream.write(messageStr.getBytes("UTF-8"));
deflaterStream.finish();
return Base64.encodeBytes(bytesOut.toByteArray(), Base64.DONT_BREAK_LINES);
} catch (IOException e) {
throw new MessageEncodingException("Unable to DEFLATE and Base64 encode SAML message", e);
}
}
示例13: processAttribute
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
ContactPerson person = (ContactPerson) samlObject;
if (attribute.getLocalName().equals(ContactPerson.CONTACT_TYPE_ATTRIB_NAME)) {
if (ContactPersonTypeEnumeration.TECHNICAL.toString().equals(attribute.getValue())) {
person.setType(ContactPersonTypeEnumeration.TECHNICAL);
} else if (ContactPersonTypeEnumeration.SUPPORT.toString().equals(attribute.getValue())) {
person.setType(ContactPersonTypeEnumeration.SUPPORT);
} else if (ContactPersonTypeEnumeration.ADMINISTRATIVE.toString().equals(attribute.getValue())) {
person.setType(ContactPersonTypeEnumeration.ADMINISTRATIVE);
} else if (ContactPersonTypeEnumeration.BILLING.toString().equals(attribute.getValue())) {
person.setType(ContactPersonTypeEnumeration.BILLING);
} else if (ContactPersonTypeEnumeration.OTHER.toString().equals(attribute.getValue())) {
person.setType(ContactPersonTypeEnumeration.OTHER);
} else {
super.processAttribute(samlObject, attribute);
}
} else {
QName attribQName = XMLHelper.getNodeQName(attribute);
if (attribute.isId()) {
person.getUnknownAttributes().registerID(attribQName);
}
person.getUnknownAttributes().put(attribQName, attribute.getValue());
}
}
示例14: populateVelocityContext
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/**
* Populate the Velocity context instance which will be used to render the POST body.
*
* @param velocityContext the Velocity context instance to populate with data
* @param messageContext the SAML message context source of data
* @param endpointURL endpoint URL to which to encode message
* @throws MessageEncodingException thrown if there is a problem encoding the message
*/
protected void populateVelocityContext(VelocityContext velocityContext, SAMLMessageContext messageContext,
String endpointURL) throws MessageEncodingException {
Encoder esapiEncoder = ESAPI.encoder();
String encodedEndpointURL = esapiEncoder.encodeForHTMLAttribute(endpointURL);
log.debug("Encoding action url of '{}' with encoded value '{}'", endpointURL, encodedEndpointURL);
velocityContext.put("action", encodedEndpointURL);
velocityContext.put("binding", getBindingURI());
log.debug("Marshalling and Base64 encoding SAML message");
if (messageContext.getOutboundSAMLMessage().getDOM() == null) {
marshallMessage(messageContext.getOutboundSAMLMessage());
}
try {
String messageXML = XMLHelper.nodeToString(messageContext.getOutboundSAMLMessage().getDOM());
String encodedMessage = Base64.encodeBytes(messageXML.getBytes("UTF-8"), Base64.DONT_BREAK_LINES);
if (messageContext.getOutboundSAMLMessage() instanceof RequestAbstractType) {
velocityContext.put("SAMLRequest", encodedMessage);
} else if (messageContext.getOutboundSAMLMessage() instanceof StatusResponseType) {
velocityContext.put("SAMLResponse", encodedMessage);
} else {
throw new MessageEncodingException(
"SAML message is neither a SAML RequestAbstractType or StatusResponseType");
}
} catch (UnsupportedEncodingException e) {
log.error("UTF-8 encoding is not supported, this VM is not Java compliant.");
throw new MessageEncodingException("Unable to encode message, UTF-8 encoding is not supported");
}
String relayState = messageContext.getRelayState();
if (checkRelayState(relayState)) {
String encodedRelayState = esapiEncoder.encodeForHTMLAttribute(relayState);
log.debug("Setting RelayState parameter to: '{}', encoded as '{}'", relayState, encodedRelayState);
velocityContext.put("RelayState", encodedRelayState);
}
}
示例15: processAttribute
import org.opensaml.xml.util.XMLHelper; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
Request request = (Request) samlObject;
QName attrName = XMLHelper.getNodeQName(attribute);
if (Request.SOAP11_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
request.setSOAP11MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
} else if (Request.SOAP11_ACTOR_ATTR_NAME.equals(attrName)) {
request.setSOAP11Actor(attribute.getValue());
} else if (Request.IS_PASSIVE_NAME_ATTRIB_NAME.equals(attribute.getLocalName())) {
request.setPassive(XSBooleanValue.valueOf(attribute.getValue()));
} else if (Request.PROVIDER_NAME_ATTRIB_NAME.equals(attribute.getLocalName())) {
request.setProviderName(attribute.getValue());
} else {
super.processAttribute(samlObject, attribute);
}
}