package at.gv.egiz.eaaf.modules.pvp2.impl.builder.reqattr; import javax.xml.namespace.QName; import org.opensaml.common.impl.AbstractSAMLObjectUnmarshaller; import org.opensaml.xml.XMLObject; import org.opensaml.xml.io.UnmarshallingException; import org.opensaml.xml.util.XMLHelper; import org.w3c.dom.Attr; import at.gv.egiz.eaaf.modules.pvp2.PVPConstants; import at.gv.egiz.eaaf.modules.pvp2.api.reqattr.EAAFRequestedAttribute; public class EAAFRequestedAttributeUnmarshaller extends AbstractSAMLObjectUnmarshaller { protected final void processChildElement(final XMLObject parentSAMLObject, final XMLObject childSAMLObject) throws UnmarshallingException { final EAAFRequestedAttribute requestedAttr = (EAAFRequestedAttribute) parentSAMLObject; final QName childQName = childSAMLObject.getElementQName(); if ("AttributeValue".equals(childQName.getLocalPart()) && childQName.getNamespaceURI().equals(PVPConstants.EIDAS10_SAML_NS)) { requestedAttr.getAttributeValues().add(childSAMLObject); } else super.processChildElement(parentSAMLObject, childSAMLObject); } protected final void processAttribute(final XMLObject samlObject, final Attr attribute) throws UnmarshallingException { final EAAFRequestedAttribute requestedAttr = (EAAFRequestedAttribute) samlObject; if (attribute.getLocalName().equals(EAAFRequestedAttribute.NAME_ATTRIB_NAME)) { requestedAttr.setName(attribute.getValue()); } else if (attribute.getLocalName().equals(EAAFRequestedAttribute.NAME_FORMAT_ATTR)) { requestedAttr.setNameFormat(attribute.getValue()); } else if (attribute.getLocalName().equals(EAAFRequestedAttribute.FRIENDLY_NAME_ATT)) { requestedAttr.setFriendlyName(attribute.getValue()); } else if (attribute.getLocalName().equals(EAAFRequestedAttribute.IS_REQUIRED_ATTR)) { requestedAttr.setIsRequired(attribute.getValue()); } else { final QName attribQName = XMLHelper.getNodeQName(attribute); if (attribute.isId()) { requestedAttr.getUnknownAttributes().registerID(attribQName); } requestedAttr.getUnknownAttributes().put(attribQName, attribute.getValue()); } } }