org.opensaml.xml.util.XMLHelper Java Examples

The following examples show how to use org.opensaml.xml.util.XMLHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractXMLObjectMarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Prepares the given DOM caching XMLObject for adoption into another document. If the XMLObject has a parent then
 * all visible namespaces used by the given XMLObject and its descendants are declared within that subtree and the
 * parent's DOM is invalidated.
 * 
 * @param domCachingObject the XMLObject to prepare for adoption
 * 
 * @throws MarshallingException thrown if a namespace within the XMLObject's DOM subtree can not be resolved.
 */
private void prepareForAdoption(XMLObject domCachingObject) throws MarshallingException {
    if (domCachingObject.getParent() != null) {
        log.trace("Rooting all visible namespaces of XMLObject {} before adding it to new parent Element",
                domCachingObject.getElementQName());
        try {
            XMLHelper.rootNamespaces(domCachingObject.getDOM());
        } catch (XMLParserException e) {
            String errorMsg =
                    "Unable to root namespaces of cached DOM element, " + domCachingObject.getElementQName();
            log.error(errorMsg, e);
            throw new MarshallingException(errorMsg, e);
        }

        log.trace("Release DOM of XMLObject parent");
        domCachingObject.releaseParentDOM(true);
    }
}
 
Example #2
Source File: AffiliationDescriptorUnmarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@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());
    }
}
 
Example #3
Source File: HttpSOAPClient.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #4
Source File: AbstractXMLObjectUnmarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: ResponseUnmarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    Response response = (Response) samlObject;
    
    QName attrName = XMLHelper.getNodeQName(attribute);
    if (Response.SOAP11_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
        response.setSOAP11MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (Response.SOAP11_ACTOR_ATTR_NAME.equals(attrName)) {
        response.setSOAP11Actor(attribute.getValue()); 
    } else if (Response.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME.equals(attribute.getLocalName())) {
        response.setAssertionConsumerServiceURL(attribute.getValue());
    } else { 
        super.processAttribute(samlObject, attribute);
    }
        
}
 
Example #6
Source File: RequestMarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    Request request = (Request) xmlObject;
    
    if (request.getProviderName() != null) {
        domElement.setAttributeNS(null, Request.PROVIDER_NAME_ATTRIB_NAME, request.getProviderName());
    }
    if (request.isPassiveXSBoolean() != null) {
        domElement.setAttributeNS(null, Request.IS_PASSIVE_NAME_ATTRIB_NAME,
                request.isPassiveXSBoolean().toString());
    }
    if (request.isSOAP11MustUnderstandXSBoolean() != null) {
        XMLHelper.marshallAttribute(Request.SOAP11_MUST_UNDERSTAND_ATTR_NAME, 
                request.isSOAP11MustUnderstandXSBoolean().toString(), domElement, false);
    }
    if (request.getSOAP11Actor() != null) {
        XMLHelper.marshallAttribute(Request.SOAP11_ACTOR_ATTR_NAME, 
                request.getSOAP11Actor(), domElement, false);
    }
    
}
 
Example #7
Source File: AuthorityBindingMarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@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());
    }
}
 
Example #8
Source File: EncryptionPropertyUnmarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    EncryptionProperty ep = (EncryptionProperty) xmlObject;

    if (attribute.getLocalName().equals(EncryptionProperty.ID_ATTRIB_NAME)) {
        ep.setID(attribute.getValue());
        attribute.getOwnerElement().setIdAttributeNode(attribute, true);
    } else if (attribute.getLocalName().equals(EncryptionProperty.TARGET_ATTRIB_NAME)) {
        ep.setTarget(attribute.getValue());
    } else {
        QName attributeName = XMLHelper.getNodeQName(attribute);
        if (attribute.isId()) {
            ep.getUnknownAttributes().registerID(attributeName);
        }
        ep.getUnknownAttributes().put(attributeName, attribute.getValue());
    }
}
 
Example #9
Source File: AttributeUnmarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@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());
    }
}
 
Example #10
Source File: AuthnContextDeclUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    AuthnContextDecl authnCtcDecl = (AuthnContextDecl) xmlObject;

    QName attribQName = XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute
            .getPrefix());

    if (attribute.isId()) {
        authnCtcDecl.getUnknownAttributes().registerID(attribQName);
    }

    authnCtcDecl.getUnknownAttributes().put(attribQName, attribute.getValue());
}
 
Example #11
Source File: SurNameMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException {
    SurName name = (SurName) samlObject;

    if (name.getName() != null) {
        XMLHelper.appendTextContent(domElement, name.getName());
    }
}
 
Example #12
Source File: BaseMessageEncoder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log the encoded message to the protocol message logger.
 * 
 * @param messageContext the message context to process
 */
protected void logEncodedMessage(MessageContext messageContext) {
    if(protocolMessageLog.isDebugEnabled() && messageContext.getOutboundMessage() != null){
        if (messageContext.getOutboundMessage().getDOM() == null) {
            try {
                marshallMessage(messageContext.getOutboundMessage());
            } catch (MessageEncodingException e) {
                log.error("Unable to marshall message for logging purposes: " + e.getMessage());
                return;
            }
        }
        protocolMessageLog.debug("\n" + XMLHelper.prettyPrintXML(messageContext.getOutboundMessage().getDOM()));
    }
}
 
Example #13
Source File: XSQNameUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void unmarshallTextContent(XMLObject xmlObject, Text content) throws UnmarshallingException {
    String textContent = DatatypeHelper.safeTrimOrNullString(content.getWholeText());
    if (textContent != null) {
        XSQName qname = (XSQName) xmlObject;
        qname.setValue(XMLHelper.constructQName(textContent, XMLHelper.getElementAncestor(content)));
    }
}
 
Example #14
Source File: ActionMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException {
    Action action = (Action) samlObject;

    if (action.getContents() != null) {
        XMLHelper.appendTextContent(domElement, action.getContents());
    }
}
 
Example #15
Source File: ResourceContentTypeUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    ResourceContentType resourceContent = (ResourceContentType) xmlObject;

    QName attribQName = XMLHelper.getNodeQName(attribute);
    if (attribute.isId()) {
        resourceContent.getUnknownAttributes().registerID(attribQName);
    }
    resourceContent.getUnknownAttributes().put(attribQName, attribute.getValue());
}
 
Example #16
Source File: AbstractXMLObjectUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unmarshalls the attributes from the given DOM Attr into the given XMLObject. If the attribute is an XML namespace
 * declaration the attribute is passed to
 * {@link AbstractXMLObjectUnmarshaller#unmarshallNamespaceAttribute(XMLObject, Attr)}. If it is an schema type
 * decleration (xsi:type) it is ignored because this attribute is handled by {@link #buildXMLObject(Element)}. All
 * other attributes are passed to the {@link #processAttribute(XMLObject, Attr)}
 * 
 * @param attribute the attribute to be unmarshalled
 * @param xmlObject the XMLObject that will recieve information from the DOM attribute
 * 
 * @throws UnmarshallingException thrown if there is a problem unmarshalling an attribute
 */
protected void unmarshallAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    QName attribName = XMLHelper.getNodeQName(attribute);
    log.trace("Pre-processing attribute {}", attribName);
    String attributeNamespace = DatatypeHelper.safeTrimOrNullString(attribute.getNamespaceURI());
    
    if (DatatypeHelper.safeEquals(attributeNamespace, XMLConstants.XMLNS_NS)) {
        unmarshallNamespaceAttribute(xmlObject, attribute);
    } else if (DatatypeHelper.safeEquals(attributeNamespace, XMLConstants.XSI_NS)) {
        unmarshallSchemaInstanceAttributes(xmlObject, attribute);
    } else {
        if (log.isTraceEnabled()) {
            log.trace("Attribute {} is neither a schema type nor namespace, calling processAttribute()",
                    XMLHelper.getNodeQName(attribute));
        }
        String attributeNSURI = attribute.getNamespaceURI();
        String attributeNSPrefix;
        if (attributeNSURI != null) {
            attributeNSPrefix = attribute.lookupPrefix(attributeNSURI);
            if (attributeNSPrefix == null && XMLConstants.XML_NS.equals(attributeNSURI)) {
                attributeNSPrefix = XMLConstants.XML_PREFIX;
            }
            xmlObject.getNamespaceManager().registerAttributeName(attribName);
        }

        checkIDAttribute(attribute);

        processAttribute(xmlObject, attribute);
    }
}
 
Example #17
Source File: ResourceContentTypeMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    ResourceContentType resourceContent  = (ResourceContentType)xmlObject;
    
    Attr attribute;
    for (Entry<QName, String> entry : resourceContent.getUnknownAttributes().entrySet()) {
        attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
        attribute.setValue(entry.getValue());
        domElement.setAttributeNodeNS(attribute);
        if (Configuration.isIDAttribute(entry.getKey())
                || resourceContent.getUnknownAttributes().isIDAttribute(entry.getKey())) {
            attribute.getOwnerElement().setIdAttributeNode(attribute, true);
        }
    }
}
 
Example #18
Source File: ActionNamespaceMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException {
    ActionNamespace actionNamespace = (ActionNamespace) xmlObject;

    if (!DatatypeHelper.isEmpty(actionNamespace.getValue())) {
        XMLHelper.appendTextContent(domElement, actionNamespace.getValue());
    }
}
 
Example #19
Source File: BodyMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    Body body = (Body) xmlObject;

    Attr attribute;
    for (Entry<QName, String> entry : body.getUnknownAttributes().entrySet()) {
        attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
        attribute.setValue(entry.getValue());
        domElement.setAttributeNodeNS(attribute);
        if (Configuration.isIDAttribute(entry.getKey()) 
                || body.getUnknownAttributes().isIDAttribute(entry.getKey())) {
            attribute.getOwnerElement().setIdAttributeNode(attribute, true);
        }
    }
}
 
Example #20
Source File: KeywordsMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException {
    Keywords words = (Keywords) samlObject;

    if (words.getKeywords() != null) {
        StringBuilder sb = new StringBuilder();
        for (String s : words.getKeywords()) {
            sb.append(s);
            sb.append(' ');
        }
        XMLHelper.appendTextContent(domElement, sb.toString());
    }
}
 
Example #21
Source File: AbstractXMLObject.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor.
 * 
 * @param namespaceURI the namespace the element is in
 * @param elementLocalName the local name of the XML element this Object represents
 * @param namespacePrefix the prefix for the given namespace
 */
protected AbstractXMLObject(String namespaceURI, String elementLocalName, String namespacePrefix) {
    nsManager = new NamespaceManager(this);
    idIndex = new IDIndex(this);
    elementQname = XMLHelper.constructQName(namespaceURI, elementLocalName, namespacePrefix);
    if(namespaceURI != null){
        setElementNamespacePrefix(namespacePrefix);
    }
}
 
Example #22
Source File: XMLConfigurator.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads the configuration docuement.
 * 
 * @param configuration the configurationd document
 * @throws ConfigurationException thrown if the configuration file(s) can not be be read or invalid
 */
public void load(Document configuration) throws ConfigurationException {
    log.debug("Loading configuration from XML Document");
    log.trace("{}", XMLHelper.nodeToString(configuration.getDocumentElement()));

    // Schema validation
    log.debug("Schema validating configuration Document");
    validateConfiguration(configuration);
    log.debug("Configuration document validated");

    load(configuration.getDocumentElement());
}
 
Example #23
Source File: XSIntegerMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException {
    XSInteger xsiInteger = (XSInteger) xmlObject;

    if (xsiInteger.getValue() != null) {
        XMLHelper.appendTextContent(domElement, xsiInteger.getValue().toString());
    }
}
 
Example #24
Source File: TelephoneNumberMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException {
    TelephoneNumber number = (TelephoneNumber) samlObject;

    if (number.getNumber() != null) {
        XMLHelper.appendTextContent(domElement, number.getNumber());
    }
}
 
Example #25
Source File: ResourceContentTypeMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException {
    ResourceContentType resourceContent = (ResourceContentType) xmlObject;
    
    if(resourceContent.getValue() != null){
        XMLHelper.appendTextContent(domElement, resourceContent.getValue());
    }
}
 
Example #26
Source File: AbstractXMLObjectMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the xmlns attributes for any namespaces set on the given XMLObject.
 * 
 * @param xmlObject the XMLObject
 * @param domElement the DOM element the namespaces will be added to
 */
protected void marshallNamespaces(XMLObject xmlObject, Element domElement) {
    log.trace("Marshalling namespace attributes for XMLObject {}", xmlObject.getElementQName());
    Set<Namespace> namespaces = xmlObject.getNamespaces();

    for (Namespace namespace : namespaces) {
        if (!namespace.alwaysDeclare()) {
            if (DatatypeHelper.safeEquals(namespace.getNamespacePrefix(), XMLConstants.XML_PREFIX)
                    || DatatypeHelper.safeEquals(namespace.getNamespaceURI(), XMLConstants.XML_NS)) {
                // the "xml" namespace never needs to be declared
                continue;
            }

            String declared = XMLHelper.lookupNamespaceURI(domElement, namespace.getNamespacePrefix());
            if (declared != null && namespace.getNamespaceURI().equals(declared)) {
                log.trace("Namespace {} has already been declared on an ancestor of {} no need to add it here",
                        namespace, xmlObject.getElementQName());
                continue;
            }
        }
        log.trace("Adding namespace declaration {} to {}", namespace, xmlObject.getElementQName());
        String nsURI = DatatypeHelper.safeTrimOrNullString(namespace.getNamespaceURI());
        String nsPrefix = DatatypeHelper.safeTrimOrNullString(namespace.getNamespacePrefix());

        XMLHelper.appendNamespaceDeclaration(domElement, nsURI, nsPrefix);
    }
}
 
Example #27
Source File: SubjectConfirmationUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    SubjectConfirmation sc = (SubjectConfirmation) samlObject;

    QName attrName = XMLHelper.getNodeQName(attribute);
    if (SubjectConfirmation.SOAP11_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
        sc.setSOAP11MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (SubjectConfirmation.SOAP11_ACTOR_ATTR_NAME.equals(attrName)) {
        sc.setSOAP11Actor(attribute.getValue()); 
    } else if (attribute.getLocalName().equals(SubjectConfirmation.METHOD_ATTRIB_NAME)) {
        sc.setMethod(attribute.getValue());
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
Example #28
Source File: AttributeValueTypeMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    AttributeValueType attributeValue = (AttributeValueType) xmlObject;

    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);
        }
    }
}
 
Example #29
Source File: SecurityTokenReferenceMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    SecurityTokenReference str = (SecurityTokenReference) xmlObject;
    
    if (!DatatypeHelper.isEmpty(str.getWSUId())) {
        XMLHelper.marshallAttribute(SecurityTokenReference.WSU_ID_ATTR_NAME, str.getWSUId(), domElement, true);
    }
    
    List<String> usages = str.getWSSEUsages();
    if (usages != null && ! usages.isEmpty()) {
        XMLHelper.marshallAttribute(SecurityTokenReference.WSSE_USAGE_ATTR_NAME, usages, domElement, false);
    }
    
    XMLHelper.marshallAttributeMap(str.getUnknownAttributes(), domElement);
}
 
Example #30
Source File: StatusMessageMarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException {
    StatusMessage statusMessage = (StatusMessage) samlObject;

    if (statusMessage.getMessage() != null) {
        XMLHelper.appendTextContent(domElement, statusMessage.getMessage());
    }
}