List of usage examples for org.w3c.dom Node getLocalName
public String getLocalName();
From source file:org.guanxi.sp.engine.service.saml2.WebBrowserSSOAuthConsumerService.java
/** * Constructs a Bag of attributes from the SAML Response * * @param responseDocument The SAML Response containing the attributes * @param guardSession the Guard's session ID * @return Bag of attributes/*from w w w.j a va 2s . com*/ * @throws GuanxiException if an error occurred */ private Bag getBag(ResponseDocument responseDocument, String guardSession) throws GuanxiException { Bag bag = new Bag(); bag.setSessionID(guardSession); try { bag.setSamlResponse(Utils.base64(responseDocument.toString().getBytes())); AssertionType[] assertions = null; if (isEncrypted(responseDocument)) { assertions = getAssertionsFromDecryptedResponse(responseDocument); } else { assertions = responseDocument.getResponse().getAssertionArray(); } for (AssertionType assertion : assertions) { if (assertion.getAttributeStatementArray().length == 0) { // No attributes available return bag; } if (assertion.getSubject() != null) { if (assertion.getSubject().getNameID() != null) { bag.addAttribute(subjectNameIDAttributeName, assertion.getSubject().getNameID().getStringValue()); } } AttributeStatementType attributeStatement = assertion.getAttributeStatementArray(0); AttributeType[] attributes = attributeStatement.getAttributeArray(); String attributeOID = null; for (AttributeType attribute : attributes) { if (attribute.getNameFormat().equals(SAML.SAML2_ATTRIBUTE_PROFILE_BASIC)) { XmlObject[] attributeValues = attribute.getAttributeValueArray(); for (int cc = 0; cc < attributeValues.length; cc++) { String attrValue = attributeValues[cc].getDomNode().getFirstChild().getNodeValue(); bag.addAttribute(attribute.getName(), attrValue); } } else if (attribute.getNameFormat().equals(SAML.SAML2_ATTRIBUTE_PROFILE_X500_LDAP)) { // Remove the prefix from the attribute name attributeOID = attribute.getName().replaceAll(EduPersonOID.ATTRIBUTE_NAME_PREFIX, ""); XmlObject[] attributeValues = attribute.getAttributeValueArray(); for (int cc = 0; cc < attributeValues.length; cc++) { // Is it a scoped attribute? if (attributeValues[cc].getDomNode().getAttributes() .getNamedItem(EduPerson.EDUPERSON_SCOPE_ATTRIBUTE) != null) { String attrValue = attributeValues[cc].getDomNode().getFirstChild().getNodeValue(); attrValue += EduPerson.EDUPERSON_SCOPED_DELIMITER; attrValue += attributeValues[cc].getDomNode().getAttributes() .getNamedItem(EduPerson.EDUPERSON_SCOPE_ATTRIBUTE).getNodeValue(); if (attributeHasFriendlyName(attribute)) { bag.addAttribute(attribute.getFriendlyName(), attrValue); } bag.addAttribute(attribute.getName(), attrValue); bag.addAttribute(attributeOID, attrValue); } // What about eduPersonTargetedID? else if (attributeOID.equals(EduPersonOID.OID_EDUPERSON_TARGETED_ID)) { NodeList attrValueNodes = attributeValues[cc].getDomNode().getChildNodes(); Node attrValueNode = null; for (int c = 0; c < attrValueNodes.getLength(); c++) { attrValueNode = attrValueNodes.item(c); if (attrValueNode.getLocalName() != null) { if (attrValueNode.getLocalName().equals("NameID")) break; } } if (attrValueNode != null) { NameIDDocument nameIDDoc = NameIDDocument.Factory.parse(attrValueNode); if (attributeHasFriendlyName(attribute)) { bag.addAttribute(attribute.getFriendlyName(), nameIDDoc.getNameID().getStringValue()); } bag.addAttribute(attribute.getName(), nameIDDoc.getNameID().getStringValue()); bag.addAttribute(attributeOID, nameIDDoc.getNameID().getStringValue()); bag.addAttribute("namequalifier", nameIDDoc.getNameID().getNameQualifier()); bag.addAttribute("spnamequalifier", nameIDDoc.getNameID().getSPNameQualifier()); } } else { if (attributeValues[cc].getDomNode().getFirstChild() != null) { if (attributeValues[cc].getDomNode().getFirstChild().getNodeValue() != null) { if (attributeHasFriendlyName(attribute)) { bag.addAttribute(attribute.getFriendlyName(), attributeValues[cc] .getDomNode().getFirstChild().getNodeValue()); } bag.addAttribute(attribute.getName(), attributeValues[cc].getDomNode().getFirstChild().getNodeValue()); bag.addAttribute(attributeOID, attributeValues[cc].getDomNode().getFirstChild().getNodeValue()); } } } } // for (int cc=0; cc < obj.length; cc++) } // else if (attribute.getNameFormat().equals(SAML.SAML2_ATTRIBUTE_PROFILE_X500_LDAP)) { } // for (AttributeType attribute : attributes) } // for (EncryptedElementType assertion : assertions) return bag; } catch (XmlException xe) { throw new GuanxiException(xe.getMessage()); } }
From source file:org.gege.caldavsyncadapter.caldav.CaldavFacade.java
public ArrayList<CalendarEvent> getCalendarEvents(DavCalendar calendar) throws URISyntaxException, ClientProtocolException, IOException, ParserConfigurationException, SAXException { ArrayList<CalendarEvent> calendarEventList = new ArrayList<CalendarEvent>(); String requestBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<D:propfind xmlns:D=\"DAV:\">" + "<D:prop>" + "<D:getetag/>" + "</D:prop>" + "</D:propfind>"; HttpPropFind request = null;//from ww w.j a v a 2 s . c om /*request = new HttpPropFind(); request.setURI(calendar.getURI()); request.setHeader("Host", targetHost.getHostName()); request.setHeader("Depth", "1"); request.setHeader("Content-Type", "application/xml;charset=\"UTF-8\""); try { request.setEntity(new StringEntity(requestBody, "UTF-8")); } catch (UnsupportedEncodingException e) { throw new AssertionError("UTF-8 is unknown"); }*/ request = this.createPropFindRequest(calendar.getURI(), requestBody, 1); Log.d(TAG, "Getting eTag by PROPFIND at " + request.getURI()); HttpResponse response = httpClient.execute(targetHost, request, mContext); BufferedReader reader = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), "UTF-8")); String line; String body = ""; do { line = reader.readLine(); if (line != null) body += line; } while (line != null); Log.d(TAG, "HttpResponse status=" + response.getStatusLine() + " body= " + body); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document dom = builder.parse(new InputSource(new ByteArrayInputStream(body.getBytes("utf-8")))); Element root = dom.getDocumentElement(); NodeList items = root.getElementsByTagNameNS("*", "getetag"); for (int i = 0; i < items.getLength(); i++) { CalendarEvent calendarEvent = new CalendarEvent(this.mAccount, this.mProvider); Node node = items.item(i); if (node.getTextContent().trim().length() == 0) continue; // not an event calendarEvent.setETag(node.getTextContent().trim()); //calendarEvent.calendarURL = this.url; calendarEvent.calendarURL = calendar.getURI().toURL(); node = node.getParentNode(); // prop node = node.getParentNode(); // propstat node = node.getParentNode(); // response NodeList children = node.getChildNodes(); for (int j = 0; j < children.getLength(); j++) { Node childNode = children.item(j); if ((childNode.getLocalName() != null) && (childNode.getLocalName().equalsIgnoreCase("href"))) { calendarEvent.setUri(new URI(childNode.getTextContent().trim())); } } calendarEventList.add(calendarEvent); } return calendarEventList; }
From source file:com.marklogic.dom.NodeImpl.java
/** {@inheritDoc} */ public boolean isEqualNode(Node other) { // Note that normalization can affect equality; to avoid this, // nodes should be normalized before being compared. // For the moment, normalization cannot be done. if (other == null) return false; if (getNodeType() != other.getNodeType()) return false; if (!getLocalName().equals(other.getLocalName())) return false; if (notequals(getNamespaceURI(), other.getNamespaceURI())) return false; if (notequals(getPrefix(), other.getPrefix())) return false; if (notequals(getNodeValue(), other.getNodeValue())) return false; if (hasChildNodes() != other.hasChildNodes()) return false; if (hasAttributes() != other.hasAttributes()) return false; if (hasChildNodes()) { NamedNodeMap thisAttr = getAttributes(); NamedNodeMap otherAttr = other.getAttributes(); if (thisAttr.getLength() != otherAttr.getLength()) return false; for (int i = 0; i < thisAttr.getLength(); i++) if (thisAttr.item(i).isEqualNode(otherAttr.item(i))) return false; }//from w ww.j a va 2 s .c o m if (hasAttributes()) { NodeList thisChild = getChildNodes(); NodeList otherChild = other.getChildNodes(); if (thisChild.getLength() != otherChild.getLength()) return false; for (int i = 0; i < thisChild.getLength(); i++) if (thisChild.item(i).isEqualNode(otherChild.item(i))) return false; } return true; }
From source file:org.exist.xquery.modules.jfreechart.Configuration.java
/** * Read configuration from node and initialize configuration. * @throws XPathException Thrown when an element cannot be read. *///from w ww . j av a2 s . com public void parse(Node configuration) throws XPathException { if (configuration.getNodeType() == Node.ELEMENT_NODE && configuration.getLocalName().equals("configuration")) { //Get the First Child Node child = configuration.getFirstChild(); while (child != null) { //Parse each of the child nodes if (child.getNodeType() == Node.ELEMENT_NODE && child.hasChildNodes()) { if (child.getLocalName().equals("title")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'title' cannot be parsed"); } else { title = value; } } else if (child.getLocalName().equals("categoryAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'categoryAxisLabel' cannot be parsed"); } else { categoryAxisLabel = value; } } else if (child.getLocalName().equals("categoryAxisColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'categoryAxisColor' cannot be parsed"); } else { categoryAxisColor = value; } } else if (child.getLocalName().equals("valueAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'valueAxisLabel' cannot be parsed"); } else { valueAxisLabel = value; } } else if (child.getLocalName().equals("valueAxisColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'valueAxisColor' cannot be parsed"); } else { valueAxisColor = value; } } else if (child.getLocalName().equals("timeAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'timeAxisLabel' cannot be parsed"); } else { timeAxisLabel = value; } } else if (child.getLocalName().equals("timeAxisColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'timeAxisColor' cannot be parsed"); } else { timeAxisColor = value; } } else if (child.getLocalName().equals("domainAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'domainAxisLabel' cannot be parsed"); } else { domainAxisLabel = value; } } else if (child.getLocalName().equals("rangeAxisLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'rangeAxisLabel' cannot be parsed"); } else { rangeAxisLabel = value; } } else if (child.getLocalName().equals("pieSectionLabel")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'pieSectionLabel' cannot be parsed"); } else { pieSectionLabel = value; } } else if (child.getLocalName().equals("pieSectionNumberFormat")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'pieSectionNumberFormat' cannot be parsed"); } else { pieSectionNumberFormat = value; } } else if (child.getLocalName().equals("pieSectionPercentFormat")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'pieSectionPercentFormat' cannot be parsed"); } else { pieSectionPercentFormat = value; } } else if (child.getLocalName().equals("orientation")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'orientation' cannot be parsed"); } else if ("HORIZONTAL".equalsIgnoreCase(value)) { orientation = PlotOrientation.HORIZONTAL; } else if ("VERTICAL".equalsIgnoreCase(value)) { orientation = PlotOrientation.VERTICAL; } else { throw new XPathException("Wrong value for 'orientation'"); } } else if (child.getLocalName().equals("tableOrder")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'tableOrder' cannot be parsed"); } else if ("COLUMN".equalsIgnoreCase(value)) { order = TableOrder.BY_COLUMN; } else if ("ROW".equalsIgnoreCase(value)) { order = TableOrder.BY_ROW; } else { throw new XPathException("Wrong value for 'tableOrder'"); } } else if (child.getLocalName().equals("legend")) { Boolean value = parseBoolean(getValue(child)); if (value == null) { throw new XPathException("Value for 'legend' cannot be parsed"); } else { generateLegend = value; } } else if (child.getLocalName().equals("tooltips")) { Boolean value = parseBoolean(getValue(child)); if (value == null) { throw new XPathException("Value for 'tooltips' cannot be parsed"); } else { generateTooltips = value; } } else if (child.getLocalName().equals("urls")) { Boolean value = parseBoolean(getValue(child)); if (value == null) { throw new XPathException("Value for 'urls' cannot be parsed"); } else { generateUrls = value; } } else if (child.getLocalName().equals("width")) { Integer value = parseInteger(getValue(child)); if (value == null) { throw new XPathException("Value for 'width' cannot be parsed"); } else { imageWidth = value; } } else if (child.getLocalName().equals("height")) { Integer value = parseInteger(getValue(child)); if (value == null) { throw new XPathException("Value for 'height' cannot be parsed"); } else { imageHeight = value; } } else if (child.getLocalName().equals("titleColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'titleColor' cannot be parsed"); } else { titleColor = value; } } else if (child.getLocalName().equals("chartBackgroundColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'chartBackgroundColor' cannot be parsed"); } else { chartBackgroundColor = value; } } else if (child.getLocalName().equals("plotBackgroundColor")) { Color value = Colour.getColor(getValue(child)); if (value == null) { throw new XPathException("Value for 'plotBackgroundColor' cannot be parsed"); } else { plotBackgroundColor = value; } } else if (child.getLocalName().equals("seriesColors")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'seriesColors' cannot be parsed"); } else { seriesColors = value; } } else if (child.getLocalName().equals("sectionColors")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'sectionColors' cannot be parsed"); } else { sectionColors = value; } } else if (child.getLocalName().equals("sectionColorsDelimiter")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'sectionColorsDelimiter' cannot be parsed"); } else { sectionColorsDelimiter = value; } } else if (child.getLocalName().equals("rangeLowerBound")) { Double value = parseDouble(getValue(child)); if (value == null) { throw new XPathException("Value for 'rangeLowerBound' cannot be parsed"); } else { rangeLowerBound = value; } } else if (child.getLocalName().equals("rangeUpperBound")) { Double value = parseDouble(getValue(child)); if (value == null) { throw new XPathException("Value for 'rangeUpperBound' cannot be parsed"); } else { rangeUpperBound = value; } } else if (child.getLocalName().equals("categoryItemLabelGeneratorClass")) { String value = getValue(child); if (value == null) { throw new XPathException( "Value for 'categoryItemLabelGeneratorClass' cannot be parsed"); } else { categoryItemLabelGeneratorClass = value; } } else if (child.getLocalName().equals("categoryItemLabelGeneratorParameter")) { String value = getValue(child); if (value == null) { throw new XPathException( "Value for 'categoryItemLabelGeneratorParameter' cannot be parsed"); } else { categoryItemLabelGeneratorParameter = value; } } else if (child.getLocalName().equals("categoryItemLabelGeneratorNumberFormat")) { String value = getValue(child); if (value == null) { throw new XPathException( "Value for 'categoryItemLabelGeneratorNumberFormat' cannot be parsed"); } else { categoryItemLabelGeneratorNumberFormat = value; } } else if (child.getLocalName().equals("imageType")) { String value = getValue(child); if (value == null) { throw new XPathException("Value for 'imageType' cannot be parsed"); } else { imageType = value; } } } //next node child = child.getNextSibling(); } } }
From source file:chat.viska.xmpp.HandshakerPipe.java
/** * Checks the feature list and see if any feature should negotiate next. Also * flags any informational {@link StreamFeature}s as negotiated. Also sets the * field {@code negotiatingFeature}.//from w w w. j a v a 2s. co m * @param document XML sent by the server. * @return {@link StreamFeature} selected to negotiate. */ @Nullable private Element consumeStreamFeatures(final Document document) { final List<Node> announcedFeatures = DomUtils.convertToList(document.getDocumentElement().getChildNodes()); if (announcedFeatures.size() == 0) { return null; } for (StreamFeature informational : INFORMATIONAL_FEATURES) { for (Node announced : announcedFeatures) { if (informational.getNamespace().equals(announced.getNamespaceURI()) && informational.getName().equals(announced.getLocalName())) { if (this.negotiatedFeatures.add(informational)) { this.eventStream.onNext(new FeatureNegotiatedEvent(this, informational)); } } } } for (StreamFeature supported : FEATURES_ORDER) { for (Node announced : announcedFeatures) { if (supported.getNamespace().equals(announced.getNamespaceURI()) && supported.getName().equals(announced.getLocalName())) { this.negotiatingFeature = supported; return (Element) announced; } } } return null; }
From source file:it.cnr.icar.eric.server.common.Utility.java
public org.w3c.dom.Element getSignatureElement(SOAPMessage msg) throws javax.xml.soap.SOAPException, javax.xml.transform.TransformerException { org.w3c.dom.Element sigElement = null; javax.xml.transform.Transformer xFormer = javax.xml.transform.TransformerFactory.newInstance() .newTransformer();//from w w w . ja va 2 s . c o m // grab info out of msg javax.xml.soap.SOAPPart msgPart = msg.getSOAPPart(); javax.xml.transform.Source msgSource = msgPart.getContent(); // transform javax.xml.transform.dom.DOMResult domResult = new javax.xml.transform.dom.DOMResult(); xFormer.transform(msgSource, domResult); //root node is the soap:Envelope Node envelopeNode = domResult.getNode(); //now you have the node. the following code strips off the envelope of //the soap message to get to the actual content // Advance to envelope node in case of text nodes preceding it while ((envelopeNode.getLocalName() == null) || (!envelopeNode.getLocalName().equalsIgnoreCase("envelope"))) { envelopeNode = envelopeNode.getFirstChild(); } // Advance to header within envelope node Node headerNode = envelopeNode.getFirstChild(); while ((headerNode.getLocalName() == null) || (!headerNode.getLocalName().equalsIgnoreCase("header"))) { headerNode = headerNode.getNextSibling(); } //System.err.println("headerNode name is: " + headerNode.getLocalName()); // Advance to signature node within header Node sigNode = headerNode.getFirstChild(); if (sigNode == null) { return null; } //System.err.println("sigNode: " + sigNode); while ((sigNode.getLocalName() == null) || (!sigNode.getLocalName().equalsIgnoreCase("signature"))) { sigNode = sigNode.getNextSibling(); if (sigNode == null) { return null; } } //Desired Signature element may be inside a SOAP-SEC signature element if (!sigNode.getNamespaceURI().equals("http://www.w3.org/2000/09/xmldsig#")) { sigNode = sigNode.getFirstChild(); while ((sigNode.getLocalName() == null) || (!sigNode.getLocalName().equalsIgnoreCase("signature"))) { sigNode = sigNode.getNextSibling(); } } if (sigNode.getNamespaceURI().equals("http://www.w3.org/2000/09/xmldsig#")) { if (sigNode instanceof org.w3c.dom.Element) { sigElement = (org.w3c.dom.Element) sigNode; } } return sigElement; }
From source file:de.qucosa.webapi.v1.DocumentResource.java
private Tuple<Collection<String>> updateWith(Document targetDocument, final Document updateDocument, List<FileUpdateOperation> fileUpdateOperations) throws XPathExpressionException, IOException, FedoraClientException { Element targetRoot = (Element) targetDocument.getElementsByTagName("Opus_Document").item(0); Element updateRoot = (Element) updateDocument.getElementsByTagName("Opus_Document").item(0); Set<String> distinctUpdateFieldList = new LinkedHashSet<>(); NodeList updateFields = updateRoot.getChildNodes(); for (int i = 0; i < updateFields.getLength(); i++) { distinctUpdateFieldList.add(updateFields.item(i).getNodeName()); }/*from w w w . j a v a 2s .c om*/ for (String fn : distinctUpdateFieldList) { // cannot use getElementsByTagName() here because it searches recursively for (Node victim : getChildNodesByName(targetRoot, fn)) { if (!victim.getLocalName().equals("File")) { targetRoot.removeChild(victim); } } } for (int i = 0; i < updateFields.getLength(); i++) { // Update node needs to be cloned, otherwise it will // be removed from updateFields by adoptNode(). Node updateNode = updateFields.item(i).cloneNode(true); if (updateNode.hasChildNodes() && !updateNode.getLocalName().equals("File")) { targetDocument.adoptNode(updateNode); targetRoot.appendChild(updateNode); } } List<String> purgeDatastreamList = new LinkedList<>(); if ((Boolean) xPath.evaluate("//File", updateDocument, XPathConstants.BOOLEAN)) { updateFileElementsInPlace(targetDocument, updateDocument, fileUpdateOperations, targetRoot, updateRoot, purgeDatastreamList); } targetDocument.normalizeDocument(); return new Tuple<>(distinctUpdateFieldList, purgeDatastreamList); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.harvester.FileHarvestController.java
/** * Parse an XML node for all subnodes with qualified name "rdf:type", and return each's "rdf:resource" value in a list. * @param descriptionNode the RDF description node * @return a list of rdf:types of the given description node *///from w w w. j av a 2s . com private ArrayList<String> getRdfTypes(Node descriptionNode) { ArrayList<String> rdfTypesList = new ArrayList<String>(); NodeList children = descriptionNode.getChildNodes(); int numChildren = children.getLength(); for (int i = 0; i < numChildren; i++) { Node child = children.item(i); String namespace = child.getNamespaceURI(); String name = child.getLocalName(); String fullName = namespace + name; if (fullName.equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")) { NamedNodeMap attributes = child.getAttributes(); Node resourceAttribute = attributes.getNamedItemNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "resource"); if (resourceAttribute != null) { //String attributeNamespace = resourceAttribute.getNamespaceURI(); String value = resourceAttribute.getNodeValue(); //rdfTypesList.add(attributeNamespace + value); rdfTypesList.add(value); } } } return rdfTypesList; }
From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLSignatureVerifier.java
@SuppressWarnings("unchecked") private boolean validateSignatureProperty(SignatureProperty signatureProperty, String signatureId) { if (!signatureProperty.getId().equals("idSignatureTime")) { LOG.error("Unexpected SignatureProperty: expected id=idSignatureTime " + "but got: " + signatureProperty.getId()); return false; }//from w ww. j a va 2s .c o m if (!signatureProperty.getTarget().equals("#" + signatureId)) { LOG.error("Unexpected SignatureProperty: expected target=#" + signatureId + "but got: " + signatureProperty.getTarget()); return false; } List<XMLStructure> signatureTimeContent = signatureProperty.getContent(); if (signatureTimeContent.size() != 1) { LOG.error("Unexpected SignatureTime content."); return false; } DOMStructure signatureTimeDOM = (DOMStructure) signatureTimeContent.get(0); Node signatureTimeElement = signatureTimeDOM.getNode(); if (!signatureTimeElement.getNamespaceURI().equals(OOXMLSignatureFacet.OOXML_DIGSIG_NS)) { LOG.error("Invalid SignatureTime element: NS=" + signatureTimeElement.getNamespaceURI()); return false; } if (!signatureTimeElement.getLocalName().equals("SignatureTime")) { LOG.error("Invalid SignatureTime element: Name=" + signatureTimeElement.getLocalName()); return false; } if (signatureTimeElement.getChildNodes().getLength() != 2) { LOG.error("Invalid SignatureTime element: Childs=" + signatureTimeElement.getChildNodes().getLength() + ", expected 2 (Format+Value)"); return false; } // format element Node formatElement = signatureTimeElement.getChildNodes().item(0); if (!formatElement.getNamespaceURI().equals(OOXMLSignatureFacet.OOXML_DIGSIG_NS)) { LOG.error("Invalid SignatureTime.Format element: NS=" + formatElement.getNamespaceURI()); return false; } if (!formatElement.getLocalName().equals("Format")) { LOG.error("Invalid SignatureTime.Format element: Name=" + formatElement.getLocalName()); return false; } // value element Node valueElement = signatureTimeElement.getChildNodes().item(1); if (!valueElement.getNamespaceURI().equals(OOXMLSignatureFacet.OOXML_DIGSIG_NS)) { LOG.error("Invalid SignatureTime.Value element: NS=" + valueElement.getNamespaceURI()); return false; } if (!valueElement.getLocalName().equals("Value")) { LOG.error("Invalid SignatureTime.Value element: Name=" + valueElement.getLocalName()); return false; } // TODO: validate value? return true; }
From source file:com.hp.hpl.inkml.InkMLDOMParser.java
/** * Method to bind Canvas element//from w w w . ja va2 s . c o m * * @param element the Canvas element * @param definitions the definitions data object to resolve the reference attributes * @return Canvas data object * @throws InkMLException */ protected Canvas getCanvas(final Element element, final Definitions definitions) throws InkMLException { final Canvas canvas = new Canvas(); // Extract and set Attribute values final NamedNodeMap attrMap = element.getAttributes(); final int length = attrMap.getLength(); for (int i = 0; i < length; i++) { final Node attr = attrMap.item(i); canvas.setAttribute(attr.getLocalName(), attr.getNodeValue()); } final NodeList list = element.getElementsByTagName("traceFormat"); if (list.getLength() != 0) { canvas.setTraceFormat(this.getTraceFormat((Element) list.item(0), definitions)); } return canvas; }