Java Code Examples for org.opensaml.xml.util.XMLHelper#getNodeQName()

The following examples show how to use org.opensaml.xml.util.XMLHelper#getNodeQName() . 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: 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 2
Source File: SubjectConfirmationDataUnmarshaller.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 {
    SubjectConfirmationData subjectCD = (SubjectConfirmationData) samlObject;

    if (attribute.getLocalName().equals(SubjectConfirmationData.NOT_BEFORE_ATTRIB_NAME)
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        subjectCD.setNotBefore(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else if (attribute.getLocalName().equals(SubjectConfirmationData.NOT_ON_OR_AFTER_ATTRIB_NAME)
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        subjectCD.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else if (attribute.getLocalName().equals(SubjectConfirmationData.RECIPIENT_ATTRIB_NAME)) {
        subjectCD.setRecipient(attribute.getValue());
    } else if (attribute.getLocalName().equals(SubjectConfirmationData.IN_RESPONSE_TO_ATTRIB_NAME)) {
        subjectCD.setInResponseTo(attribute.getValue());
    } else if (attribute.getLocalName().equals(SubjectConfirmationData.ADDRESS_ATTRIB_NAME)) {
        subjectCD.setAddress(attribute.getValue());
    } else {
        QName attribQName = XMLHelper.getNodeQName(attribute);
        if (attribute.isId()) {
            subjectCD.getUnknownAttributes().registerID(attribQName);
        }
        subjectCD.getUnknownAttributes().put(attribQName, attribute.getValue());
    }
}
 
Example 3
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 4
Source File: EntityDescriptorUnmarshaller.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 {
    EntityDescriptor entityDescriptor = (EntityDescriptor) samlObject;

    if (attribute.getLocalName().equals(EntityDescriptor.ENTITY_ID_ATTRIB_NAME)) {
        entityDescriptor.setEntityID(attribute.getValue());
    } else if (attribute.getLocalName().equals(EntityDescriptor.ID_ATTRIB_NAME)) {
        entityDescriptor.setID(attribute.getValue());
        attribute.getOwnerElement().setIdAttributeNode(attribute, true);
    } else if (attribute.getLocalName().equals(TimeBoundSAMLObject.VALID_UNTIL_ATTRIB_NAME)
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        entityDescriptor.setValidUntil(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else if (attribute.getLocalName().equals(CacheableSAMLObject.CACHE_DURATION_ATTRIB_NAME)) {
        entityDescriptor.setCacheDuration(XMLHelper.durationToLong(attribute.getValue()));
    } else {
        QName attribQName = XMLHelper.getNodeQName(attribute);
        if (attribute.isId()) {
            entityDescriptor.getUnknownAttributes().registerID(attribQName);
        }
        entityDescriptor.getUnknownAttributes().put(attribQName, attribute.getValue());
    }
}
 
Example 5
Source File: RequestUnmarshaller.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 {
    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);
    }
}
 
Example 6
Source File: AbstractXMLObjectUnmarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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()));
    }
}
 
Example 7
Source File: ContactPersonUnmarshaller.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 {
    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());
    }
}
 
Example 8
Source File: EncryptedHeaderUnmarshaller.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 {
    EncryptedHeader eh = (EncryptedHeader) xmlObject;
    QName attrName = XMLHelper.getNodeQName(attribute);
    if (EncryptedHeader.WSU_ID_ATTR_NAME.equals(attrName)) {
        eh.setWSUId(attribute.getValue());
        attribute.getOwnerElement().setIdAttributeNode(attribute, true);
    } else if (EncryptedHeader.SOAP11_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
        eh.setSOAP11MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (EncryptedHeader.SOAP11_ACTOR_ATTR_NAME.equals(attrName)) {
        eh.setSOAP11Actor(attribute.getValue());
    } else if (EncryptedHeader.SOAP12_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
        eh.setSOAP12MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (EncryptedHeader.SOAP12_ROLE_ATTR_NAME.equals(attrName)) {
        eh.setSOAP12Role(attribute.getValue());
    } else if (EncryptedHeader.SOAP12_RELAY_ATTR_NAME.equals(attrName)) {
        eh.setSOAP12Relay(XSBooleanValue.valueOf(attribute.getValue()));
    } else {
        super.processAttribute(xmlObject, attribute);
    }
}
 
Example 9
Source File: AbstractXMLObjectUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unmarshalls given Element's children. For each child an unmarshaller is retrieved using
 * {@link UnmarshallerFactory#getUnmarshaller(Element)}. The unmarshaller is then used to unmarshall the child
 * element and the resultant XMLObject is passed to {@link #processChildElement(XMLObject, XMLObject)} for further
 * processing.
 * 
 * @param xmlObject the parent object of the unmarshalled children
 * @param childElement the child element to be unmarshalled
 * 
 * @throws UnmarshallingException thrown if an error occurs unmarshalling the chilren elements
 */
protected void unmarshallChildElement(XMLObject xmlObject, Element childElement) throws UnmarshallingException {
    log.trace("Unmarshalling child elements of XMLObject {}", xmlObject.getElementQName());

    Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(childElement);

    if (unmarshaller == null) {
        unmarshaller = unmarshallerFactory.getUnmarshaller(Configuration.getDefaultProviderQName());
        if (unmarshaller == null) {
            String errorMsg = "No unmarshaller available for " + XMLHelper.getNodeQName(childElement)
                    + ", child of " + xmlObject.getElementQName();
            log.error(errorMsg);
            throw new UnmarshallingException(errorMsg);
        } else {
            if (log.isTraceEnabled()) {
                log.trace("No unmarshaller was registered for {}, child of {}. Using default unmarshaller.",
                        XMLHelper.getNodeQName(childElement), xmlObject.getElementQName());
            }
        }
    }

    if (log.isTraceEnabled()) {
        log.trace("Unmarshalling child element {}with unmarshaller {}", XMLHelper.getNodeQName(childElement),
                unmarshaller.getClass().getName());
    }
    processChildElement(xmlObject, unmarshaller.unmarshall(childElement));
}
 
Example 10
Source File: AttributeValueTypeUnmarshaller.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 {
    AttributeValueType attributeValue = (AttributeValueType) xmlObject;

    QName attribQName = XMLHelper.getNodeQName(attribute);
    if (attribute.isId()) {
        attributeValue.getUnknownAttributes().registerID(attribQName);
    }
    attributeValue.getUnknownAttributes().put(attribQName, attribute.getValue());
    
    if(attribute.getLocalName().equals(AttributeValueType.DATA_TYPE_ATTRIB_NAME)){
    	attributeValue.setDataType(DatatypeHelper.safeTrimOrNullString(attribute.getValue()));
    }
}
 
Example 11
Source File: OrganizationUnmarshaller.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 {
    Organization org = (Organization) samlObject;

    QName attribQName = XMLHelper.getNodeQName(attribute);
    if (attribute.isId()) {
        org.getUnknownAttributes().registerID(attribQName);
    }
    org.getUnknownAttributes().put(attribQName, attribute.getValue());
}
 
Example 12
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 13
Source File: GeneratedKeyUnmarshaller.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 {
    GeneratedKey key = (GeneratedKey) samlObject;

    QName attrName = XMLHelper.getNodeQName(attribute);
    if (GeneratedKey.SOAP11_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
        key.setSOAP11MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (GeneratedKey.SOAP11_ACTOR_ATTR_NAME.equals(attrName)) {
        key.setSOAP11Actor(attribute.getValue()); 
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
Example 14
Source File: SessionKeyUnmarshaller.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 {
    SessionKey key = (SessionKey) samlObject;

    QName attrName = XMLHelper.getNodeQName(attribute);
    if (SessionKey.SOAP11_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
        key.setSOAP11MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (SessionKey.SOAP11_ACTOR_ATTR_NAME.equals(attrName)) {
        key.setSOAP11Actor(attribute.getValue()); 
    } else if (attribute.getLocalName().equals(SessionKey.ALGORITHM_ATTRIB_NAME)) {
        key.setAlgorithm(attribute.getValue());
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
Example 15
Source File: ChannelBindingsUnmarshaller.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 {
    ChannelBindings cb = (ChannelBindings) xmlObject;
    
    QName attrName = XMLHelper.getNodeQName(attribute);
    if (attribute.getLocalName().equals(ChannelBindings.TYPE_ATTRIB_NAME)) {
        cb.setType(attribute.getValue());
    } else if (ChannelBindings.SOAP11_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
        cb.setSOAP11MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (ChannelBindings.SOAP11_ACTOR_ATTR_NAME.equals(attrName)) {
        cb.setSOAP11Actor(attribute.getValue()); 
    } else {
        super.processAttribute(xmlObject, attribute);
    }       
}
 
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: AbstractXMLObjectUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that the given DOM Element's XSI type or namespace qualified element name matches the target QName of this
 * unmarshaller.
 * 
 * @param domElement the DOM element to check
 * 
 * @throws UnmarshallingException thrown if the DOM Element does not match the target of this unmarshaller
 */
protected void checkElementIsTarget(Element domElement) throws UnmarshallingException {
    QName elementName = XMLHelper.getNodeQName(domElement);

    if (targetQName == null) {
        log.trace(
                "Targeted QName checking is not available for this unmarshaller, DOM Element {} was not verified",
                elementName);
        return;
    }

    log.trace("Checking that {} meets target criteria.", elementName);

    QName type = XMLHelper.getXSIType(domElement);

    if (type != null && type.equals(targetQName)) {
        log.trace("{} schema type matches target.", elementName);
        return;
    } else {
        if (elementName.equals(targetQName)) {
            log.trace("{} element name matches target.", elementName);
            return;
        } else {
            String errorMsg = "This unmarshaller only operates on " + targetQName + " elements not " + elementName;
            log.error(errorMsg);
            throw new UnmarshallingException(errorMsg);
        }
    }
}
 
Example 18
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 19
Source File: RelayStateUnmarshaller.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 {
    RelayState relayState = (RelayState) xmlObject;
    
    QName attrName = XMLHelper.getNodeQName(attribute);
    if (RelayState.SOAP11_MUST_UNDERSTAND_ATTR_NAME.equals(attrName)) {
        relayState.setSOAP11MustUnderstand(XSBooleanValue.valueOf(attribute.getValue()));
    } else if (RelayState.SOAP11_ACTOR_ATTR_NAME.equals(attrName)) {
        relayState.setSOAP11Actor(attribute.getValue()); 
    } else {
        super.processAttribute(xmlObject, attribute);
    }
    
}
 
Example 20
Source File: AbstractXMLObjectUnmarshaller.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Check whether the attribute's QName is registered in the global ID attribute registry. If it is, and the
 * specified attribute's DOM Level 3 Attr.isId() is false (due to lack of schema validation, for example), then
 * declare the attribute as an ID type in the DOM on the attribute's owning element. This is to handle cases where
 * the underlying DOM needs to accurately reflect an attribute's ID-ness, for example ID reference resolution within
 * the Apache XML Security library.
 * 
 * @param attribute the DOM attribute to be checked
 */
protected void checkIDAttribute(Attr attribute) {
    QName attribName = XMLHelper.getNodeQName(attribute);
    if (Configuration.isIDAttribute(attribName) && !attribute.isId()) {
        attribute.getOwnerElement().setIdAttributeNode(attribute, true);
    }
}