List of usage examples for org.w3c.dom Element getOwnerDocument
public Document getOwnerDocument();
Document
object associated with this node. From source file:com.vmware.identity.saml.impl.TokenAuthorityImpl.java
@Override public SamlToken issueToken(SamlTokenSpec spec) { log.debug("Started issuing token for spec:{}", spec); Validate.notNull(spec);/*from w ww . j a v a 2 s .co m*/ final Config config = this.configExtractor.getConfig(); final SamlAuthorityConfiguration samlAuthorityConfig = config.getSamlAuthorityConfig(); final TokenRestrictions tokenRestrictions = config.getTokenRestrictions(); final DelegationHandler delegationHandler = new DelegationHandler(tokenRestrictions.getDelegationCount(), principalAttributesExtractor); final SignInfo signInfo = getSignInfo(samlAuthorityConfig); final TokenLifetimeRemediator lifetimeRemediator = new TokenLifetimeRemediator(signInfo, tokenRestrictions, config.getClockTolerance()); final boolean requesterIsTokenOwner = spec.requesterIsTokenOwner(); final DelegationInfo delegationInfo = delegationHandler.getDelegationInfo(requesterIsTokenOwner, spec.getDelegationSpec()); final int renewCount = new RenewRestrictor(requesterIsTokenOwner, tokenRestrictions.getRenewCount()) .processRequest(spec.getRenewSpec()); final SignatureAlgorithm signatureAlgorithm = getSignatureAlgorithm(spec.getSignatureAlgorithm(), samlAuthorityConfig); final List<Advice> advice = AdviceFilter.processRequest(requesterIsTokenOwner, spec.getRequestedAdvice(), spec.getPresentAdvice()); // move token issue time right before create assertion, PR 1550654. final Date issueInstantTime = new Date(); log.debug("Issue instant time: {}", issueInstantTime); final TimePeriod validity = lifetimeRemediator.remediateTokenValidity(spec, issueInstantTime); final Assertion assertion = createAssertion(spec, issueInstantTime, validity, delegationInfo, renewCount, advice, samlAuthorityConfig); final Element assertionElement = createSignatureAndSignAssertion(assertion, signatureAlgorithm, signInfo); final Document token = assertionElement.getOwnerDocument(); log.debug("Created token(issuance time: {}):\n{}", issueInstantTime, XMLHelper.nodeToString(token.getDocumentElement())); // we can use confirmation type from the spec because it is directly used // for the issued token without remediation. final ConfirmationType confirmationType = spec.getConfirmationData().getType(); return new SamlToken(token, signatureAlgorithm, validity, confirmationType, delegationInfo.isDelegableToken(), renewCount > 0); }
From source file:com.legstar.jaxb.gen.CobolJAXBCustomizer.java
/** * Inject a XmlTransform element in the JAXB schema bindings annotation. * <p/>// www . j av a2 s . co m * If the element is already present we update its attributes. * * @param schemabindingsEl the schema bindings node * @param jaxbNamespace the JAXB namespace * @param jaxbNamespacePrefix the JAXB namespace prefix */ public void injectJaxbXmlTransformAnnotation(final Element schemabindingsEl, final String jaxbNamespace, final String jaxbNamespacePrefix) { Element xmltransformEl = null; NodeList nl = schemabindingsEl.getElementsByTagNameNS(jaxbNamespace, JAXB_XMLTRANSFORM); if (nl.getLength() > 0) { xmltransformEl = (Element) nl.item(0); } else { xmltransformEl = schemabindingsEl.getOwnerDocument().createElementNS(jaxbNamespace, jaxbNamespacePrefix + ':' + JAXB_XMLTRANSFORM); schemabindingsEl.appendChild(xmltransformEl); } if (getJaxbGenModel().needTypeNameXmlTransform()) { injectJaxbTypeNameXmlTransformAnnotation(xmltransformEl, jaxbNamespace, jaxbNamespacePrefix); } if (getJaxbGenModel().needElementNameXmlTransform()) { injectJaxbElementNameXmlTransformAnnotation(xmltransformEl, jaxbNamespace, jaxbNamespacePrefix); } }
From source file:com.legstar.jaxb.gen.CobolJAXBCustomizer.java
/** * Inject a TypeNameXmlTransform element in the JAXB XmlTransform * annotation.//from ww w . j av a 2s . c o m * <p/> * If the element is already present we update its attributes. * * @param xmltransformEl the XmlTransform node * @param jaxbNamespace the JAXB namespace * @param jaxbNamespacePrefix the JAXB namespace prefix */ public void injectJaxbTypeNameXmlTransformAnnotation(final Element xmltransformEl, final String jaxbNamespace, final String jaxbNamespacePrefix) { Element typenamexmltransformEl = null; NodeList nl = xmltransformEl.getElementsByTagNameNS(jaxbNamespace, JAXB_TYPENAME); if (nl.getLength() > 0) { typenamexmltransformEl = (Element) nl.item(0); } else { typenamexmltransformEl = xmltransformEl.getOwnerDocument().createElementNS(jaxbNamespace, jaxbNamespacePrefix + ':' + JAXB_TYPENAME); xmltransformEl.appendChild(typenamexmltransformEl); } if (getJaxbGenModel().getTypeNamePrefix() != null) { typenamexmltransformEl.setAttribute(JAXB_PREFIX, getJaxbGenModel().getTypeNamePrefix()); } if (getJaxbGenModel().getTypeNameSuffix() != null) { typenamexmltransformEl.setAttribute(JAXB_SUFFIX, getJaxbGenModel().getTypeNameSuffix()); } }
From source file:com.legstar.jaxb.gen.CobolJAXBCustomizer.java
/** * Inject a ElementNameXmlTransform element in the JAXB XmlTransform * annotation./*from w w w . j a v a 2 s . c o m*/ * <p/> * If the element is already present we update its attributes. * * @param xmltransformEl the XmlTransform node * @param jaxbNamespace the JAXB namespace * @param jaxbNamespacePrefix the JAXB namespace prefix */ public void injectJaxbElementNameXmlTransformAnnotation(final Element xmltransformEl, final String jaxbNamespace, final String jaxbNamespacePrefix) { Element elementnamexmltransformEl = null; NodeList nl = xmltransformEl.getElementsByTagNameNS(jaxbNamespace, JAXB_ELEMENTNAME); if (nl.getLength() > 0) { elementnamexmltransformEl = (Element) nl.item(0); } else { elementnamexmltransformEl = xmltransformEl.getOwnerDocument().createElementNS(jaxbNamespace, jaxbNamespacePrefix + ':' + JAXB_ELEMENTNAME); xmltransformEl.appendChild(elementnamexmltransformEl); } if (getJaxbGenModel().getElementNamePrefix() != null) { elementnamexmltransformEl.setAttribute(JAXB_PREFIX, getJaxbGenModel().getElementNamePrefix()); } if (getJaxbGenModel().getElementNameSuffix() != null) { elementnamexmltransformEl.setAttribute(JAXB_SUFFIX, getJaxbGenModel().getElementNameSuffix()); } }
From source file:de.betterform.xml.xforms.action.LoadAction.java
private void handleEmbedding(String absoluteURI, HashMap map, boolean includeCSS, boolean includeScript) throws XFormsException { // if(this.targetAttribute == null) return; //todo: handle multiple params if (absoluteURI.indexOf("?") > 0) { String name = absoluteURI.substring(absoluteURI.indexOf("?") + 1); String value = name.substring(name.indexOf("=") + 1, name.length()); name = name.substring(0, name.indexOf("=")); this.container.getProcessor().setContextParam(name, value); }//from www.j a v a2 s . c om if (this.targetAttribute == null) { map.put("uri", absoluteURI); map.put("show", this.showAttribute); // dispatch internal betterform event this.container.dispatch(this.target, BetterFormEventNames.LOAD_URI, map); return; } if (!("embed".equals(this.showAttribute))) { throw new XFormsException("@show must be 'embed' if @target is given but was: '" + this.showAttribute + "' on Element " + DOMUtil.getCanonicalPath(this.element)); } //todo: dirty dirty dirty String evaluatedTarget = evalAttributeValueTemplates(this.targetAttribute, this.element); if (LOGGER.isDebugEnabled()) { LOGGER.debug("targetid evaluated to: " + evaluatedTarget); } Node embed = getEmbeddedDocument(absoluteURI); if (embed == null) { //todo: review: context info params containing a '-' fail during access in javascript! //todo: the following property should have been 'resource-uri' according to spec map.put("resourceUri", absoluteURI); this.container.dispatch(this.target, XFormsEventNames.LINK_EXCEPTION, map); return; } // Check for 'ClientSide' events (DOMFocusIN / DOMFocusOUT / xforms-select) String utilizedEvents = this.getEventsInSubform(embed); // fetch CSS / JavaScript String inlineCssRules = ""; String externalCssRules = ""; String inlineJavaScript = ""; String externalJavaScript = ""; if (includeCSS) { inlineCssRules = getInlineCSS(embed); externalCssRules = getExternalCSS(embed); } if (includeScript) { inlineJavaScript = getInlineJavaScript(embed); externalJavaScript = getExternalJavaScript(embed); } if (Config.getInstance().getProperty("webprocessor.doIncludes", "false").equals("true")) { embed = doIncludes(embed, absoluteURI); } embed = extractFragment(absoluteURI, embed); if (LOGGER.isDebugEnabled()) { DOMUtil.prettyPrintDOM(embed); } Element embeddedNode; Element targetElem = getTargetElement(evaluatedTarget); //Test if targetElem exist. if (targetElem != null) { // destroy existing embedded form within targetNode if (targetElem.hasChildNodes()) { destroyembeddedModels(targetElem); Initializer.disposeUIElements(targetElem); } // import referenced embedded form into host document embeddedNode = (Element) this.container.getDocument().importNode(embed, true); //import namespaces NamespaceResolver.applyNamespaces(targetElem.getOwnerDocument().getDocumentElement(), (Element) embeddedNode); // keep original targetElem id within hostdoc embeddedNode.setAttributeNS(null, "id", targetElem.getAttributeNS(null, "id")); //copy all Attributes that might have been on original mountPoint to embedded node DOMUtil.copyAttributes(targetElem, embeddedNode, null); targetElem.getParentNode().replaceChild(embeddedNode, targetElem); //create model for it this.container.createEmbeddedForm((Element) embeddedNode); // dispatch internal betterform event this.container.dispatch((EventTarget) embeddedNode, BetterFormEventNames.EMBED_DONE, map); if (getModel().isReady()) { map.put("uri", absoluteURI); map.put("show", this.showAttribute); map.put("targetElement", embeddedNode); map.put("nameTarget", evaluatedTarget); map.put("xlinkTarget", getXFormsAttribute(targetElem, "id")); map.put("inlineCSS", inlineCssRules); map.put("externalCSS", externalCssRules); map.put("inlineJavascript", inlineJavaScript); map.put("externalJavascript", externalJavaScript); map.put("utilizedEvents", utilizedEvents); this.container.dispatch((EventTarget) embeddedNode, BetterFormEventNames.EMBED, map); this.container.dispatch(this.target, BetterFormEventNames.LOAD_URI, map); } // storeInContext(absoluteURI, this.showAttribute); } else { String message = "Element reference for targetid: " + this.targetAttribute + " not found. " + DOMUtil.getCanonicalPath(this.element); /* Element div = this.element.getOwnerDocument().createElementNS("", "div"); div.setAttribute("class", "bfException"); div.setTextContent("Element reference for targetid: " + this.targetAttribute + "not found. " + DOMUtil.getCanonicalPath(this.element)); Element body = (Element) this.container.getDocument().getElementsByTagName("body").item(0); body.insertBefore(div, DOMUtil.getFirstChildElement(body)); */ map.put("message", message); map.put("exceptionPath", DOMUtil.getCanonicalPath(this.element)); this.container.dispatch(this.target, BetterFormEventNames.EXCEPTION, map); //throw new XFormsException(message); } }
From source file:de.qucosa.webapi.v1.DocumentResource.java
private void addHashValue(Element fileElement, DatastreamProfile dsp) { if ((fileElement == null) || (dsp == null)) return;/*from w ww . jav a2 s . com*/ String hashType = dsp.getDsChecksumType(); String hashValue = dsp.getDsChecksum(); if ((hashType != null) && (hashValue != null) && !hashType.isEmpty() && !hashValue.isEmpty()) { Element hashValueElement = fileElement.getOwnerDocument().createElement("HashValue"); Element typeElement = fileElement.getOwnerDocument().createElement("Type"); Element valueElement = fileElement.getOwnerDocument().createElement("Value"); fileElement.appendChild(hashValueElement); hashValueElement.appendChild(typeElement); hashValueElement.appendChild(valueElement); typeElement.setTextContent(hashType); valueElement.setTextContent(hashValue); } }
From source file:org.opentraces.metatracker.net.OpenTracesClient.java
/** * Do XML over HTTP request and retun response. */// w ww . j a v a2 s. c om private Element doRequest(Element anElement) throws ClientException { // Create URL to use String url = protocolURL; if (agentKey != null) { url = url + "?agentkey=" + agentKey; } else { // Must be login url = url + "?timeout=" + timeout; } p("doRequest: " + url + " req=" + anElement.getTagName()); // Perform request/response HttpClient httpclient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); Element replyElement = null; try { // Make sure the server knows what kind of a response we will accept httpPost.addHeader("Accept", "text/xml"); // Also be sure to tell the server what kind of content we are sending httpPost.addHeader("Content-Type", "application/xml"); String xmlString = DOMUtil.dom2String(anElement.getOwnerDocument()); StringEntity entity = new StringEntity(xmlString, "UTF-8"); entity.setContentType("application/xml"); httpPost.setEntity(entity); // Execute HTTP Post Request HttpResponse response = httpclient.execute(httpPost); // Parse response Document replyDoc = DOMUtil.parse(response.getEntity().getContent()); replyElement = replyDoc.getDocumentElement(); p("doRequest: rsp=" + replyElement.getTagName()); } catch (Throwable t) { throw new ClientException("Error in doRequest: " + t); } finally { } return replyElement; }
From source file:be.fedict.eid.applet.service.signer.facets.XAdESXLSignatureFacet.java
public void postSign(Element signatureElement, List<X509Certificate> signingCertificateChain) { LOG.debug("XAdES-X-L post sign phase"); for (X509Certificate xCert : signingCertificateChain) { LOG.debug("Cert chain: " + xCert.getSubjectX500Principal()); }/*from ww w . j ava2s .c om*/ // check for XAdES-BES Element qualifyingPropertiesElement = (Element) findSingleNode(signatureElement, "ds:Object/xades:QualifyingProperties"); if (null == qualifyingPropertiesElement) { throw new IllegalArgumentException("no XAdES-BES extension present"); } // create basic XML container structure Document document = signatureElement.getOwnerDocument(); String xadesNamespacePrefix; if (null != qualifyingPropertiesElement.getPrefix()) { xadesNamespacePrefix = qualifyingPropertiesElement.getPrefix() + ":"; } else { xadesNamespacePrefix = ""; } Element unsignedPropertiesElement = (Element) findSingleNode(qualifyingPropertiesElement, "xades:UnsignedProperties"); if (null == unsignedPropertiesElement) { unsignedPropertiesElement = document.createElementNS(XADES_NAMESPACE, xadesNamespacePrefix + "UnsignedProperties"); qualifyingPropertiesElement.appendChild(unsignedPropertiesElement); } Element unsignedSignaturePropertiesElement = (Element) findSingleNode(unsignedPropertiesElement, "xades:UnsignedSignatureProperties"); if (null == unsignedSignaturePropertiesElement) { unsignedSignaturePropertiesElement = document.createElementNS(XADES_NAMESPACE, xadesNamespacePrefix + "UnsignedSignatureProperties"); unsignedPropertiesElement.appendChild(unsignedSignaturePropertiesElement); } // create the XAdES-T time-stamp Node signatureValueNode = findSingleNode(signatureElement, "ds:SignatureValue"); RevocationData tsaRevocationDataXadesT = new RevocationData(); LOG.debug("creating XAdES-T time-stamp"); XAdESTimeStampType signatureTimeStamp = createXAdESTimeStamp(Collections.singletonList(signatureValueNode), tsaRevocationDataXadesT, this.c14nAlgoId, this.timeStampService, this.objectFactory, this.xmldsigObjectFactory); // marshal the XAdES-T extension try { this.marshaller.marshal(this.objectFactory.createSignatureTimeStamp(signatureTimeStamp), unsignedSignaturePropertiesElement); } catch (JAXBException e) { throw new RuntimeException("JAXB error: " + e.getMessage(), e); } // xadesv141::TimeStampValidationData if (tsaRevocationDataXadesT.hasRevocationDataEntries()) { ValidationDataType validationData = createValidationData(tsaRevocationDataXadesT); try { this.marshaller.marshal(this.xades141ObjectFactory.createTimeStampValidationData(validationData), unsignedSignaturePropertiesElement); } catch (JAXBException e) { throw new RuntimeException("JAXB error: " + e.getMessage(), e); } } if (null == this.revocationDataService) { /* * Without revocation data service we cannot construct the XAdES-C * extension. */ return; } // XAdES-C: complete certificate refs CompleteCertificateRefsType completeCertificateRefs = this.objectFactory .createCompleteCertificateRefsType(); CertIDListType certIdList = this.objectFactory.createCertIDListType(); completeCertificateRefs.setCertRefs(certIdList); List<CertIDType> certIds = certIdList.getCert(); for (int certIdx = 1; certIdx < signingCertificateChain.size(); certIdx++) { /* * We skip the signing certificate itself according to section * 4.4.3.2 of the XAdES 1.4.1 specification. */ X509Certificate certificate = signingCertificateChain.get(certIdx); CertIDType certId = XAdESSignatureFacet.getCertID(certificate, this.objectFactory, this.xmldsigObjectFactory, this.digestAlgorithm, false); certIds.add(certId); } // XAdES-C: complete revocation refs CompleteRevocationRefsType completeRevocationRefs = this.objectFactory.createCompleteRevocationRefsType(); RevocationData revocationData = this.revocationDataService.getRevocationData(signingCertificateChain); if (revocationData.hasCRLs()) { CRLRefsType crlRefs = this.objectFactory.createCRLRefsType(); completeRevocationRefs.setCRLRefs(crlRefs); List<CRLRefType> crlRefList = crlRefs.getCRLRef(); List<byte[]> crls = revocationData.getCRLs(); for (byte[] encodedCrl : crls) { CRLRefType crlRef = this.objectFactory.createCRLRefType(); crlRefList.add(crlRef); X509CRL crl; try { crl = (X509CRL) this.certificateFactory.generateCRL(new ByteArrayInputStream(encodedCrl)); } catch (CRLException e) { throw new RuntimeException("CRL parse error: " + e.getMessage(), e); } CRLIdentifierType crlIdentifier = this.objectFactory.createCRLIdentifierType(); crlRef.setCRLIdentifier(crlIdentifier); String issuerName; try { issuerName = PrincipalUtil.getIssuerX509Principal(crl).getName().replace(",", ", "); } catch (CRLException e) { throw new RuntimeException("CRL encoding error: " + e.getMessage(), e); } crlIdentifier.setIssuer(issuerName); crlIdentifier.setIssueTime(this.datatypeFactory .newXMLGregorianCalendar(new DateTime(crl.getThisUpdate()).toGregorianCalendar())); crlIdentifier.setNumber(getCrlNumber(crl)); DigestAlgAndValueType digestAlgAndValue = XAdESSignatureFacet.getDigestAlgAndValue(encodedCrl, this.objectFactory, this.xmldsigObjectFactory, this.digestAlgorithm); crlRef.setDigestAlgAndValue(digestAlgAndValue); } } if (revocationData.hasOCSPs()) { OCSPRefsType ocspRefs = this.objectFactory.createOCSPRefsType(); completeRevocationRefs.setOCSPRefs(ocspRefs); List<OCSPRefType> ocspRefList = ocspRefs.getOCSPRef(); List<byte[]> ocsps = revocationData.getOCSPs(); for (byte[] ocsp : ocsps) { OCSPRefType ocspRef = this.objectFactory.createOCSPRefType(); ocspRefList.add(ocspRef); DigestAlgAndValueType digestAlgAndValue = XAdESSignatureFacet.getDigestAlgAndValue(ocsp, this.objectFactory, this.xmldsigObjectFactory, this.digestAlgorithm); ocspRef.setDigestAlgAndValue(digestAlgAndValue); OCSPIdentifierType ocspIdentifier = this.objectFactory.createOCSPIdentifierType(); ocspRef.setOCSPIdentifier(ocspIdentifier); OCSPResp ocspResp; try { ocspResp = new OCSPResp(ocsp); } catch (IOException e) { throw new RuntimeException("OCSP decoding error: " + e.getMessage(), e); } Object ocspResponseObject; try { ocspResponseObject = ocspResp.getResponseObject(); } catch (OCSPException e) { throw new RuntimeException("OCSP error: " + e.getMessage(), e); } BasicOCSPResp basicOcspResp = (BasicOCSPResp) ocspResponseObject; Date producedAt = basicOcspResp.getProducedAt(); ocspIdentifier.setProducedAt(this.datatypeFactory .newXMLGregorianCalendar(new DateTime(producedAt).toGregorianCalendar())); ResponderIDType responderId = this.objectFactory.createResponderIDType(); ocspIdentifier.setResponderID(responderId); RespID respId = basicOcspResp.getResponderId(); ResponderID ocspResponderId = respId.toASN1Object(); DERTaggedObject derTaggedObject = (DERTaggedObject) ocspResponderId.toASN1Object(); if (2 == derTaggedObject.getTagNo()) { ASN1OctetString keyHashOctetString = (ASN1OctetString) derTaggedObject.getObject(); responderId.setByKey(keyHashOctetString.getOctets()); } else { X509Name name = X509Name.getInstance(derTaggedObject.getObject()); responderId.setByName(name.toString()); } } } // marshal XAdES-C NodeList unsignedSignaturePropertiesNodeList = ((Element) qualifyingPropertiesElement) .getElementsByTagNameNS(XADES_NAMESPACE, "UnsignedSignatureProperties"); Node unsignedSignaturePropertiesNode = unsignedSignaturePropertiesNodeList.item(0); try { this.marshaller.marshal(this.objectFactory.createCompleteCertificateRefs(completeCertificateRefs), unsignedSignaturePropertiesNode); this.marshaller.marshal(this.objectFactory.createCompleteRevocationRefs(completeRevocationRefs), unsignedSignaturePropertiesNode); } catch (JAXBException e) { throw new RuntimeException("JAXB error: " + e.getMessage(), e); } // XAdES-X Type 1 timestamp List<Node> timeStampNodesXadesX1 = new LinkedList<Node>(); timeStampNodesXadesX1.add(signatureValueNode); Node signatureTimeStampNode = findSingleNode(unsignedSignaturePropertiesNode, "xades:SignatureTimeStamp"); timeStampNodesXadesX1.add(signatureTimeStampNode); Node completeCertificateRefsNode = findSingleNode(unsignedSignaturePropertiesNode, "xades:CompleteCertificateRefs"); timeStampNodesXadesX1.add(completeCertificateRefsNode); Node completeRevocationRefsNode = findSingleNode(unsignedSignaturePropertiesNode, "xades:CompleteRevocationRefs"); timeStampNodesXadesX1.add(completeRevocationRefsNode); RevocationData tsaRevocationDataXadesX1 = new RevocationData(); LOG.debug("creating XAdES-X time-stamp"); XAdESTimeStampType timeStampXadesX1 = createXAdESTimeStamp(timeStampNodesXadesX1, tsaRevocationDataXadesX1, this.c14nAlgoId, this.timeStampService, this.objectFactory, this.xmldsigObjectFactory); ValidationDataType timeStampXadesX1ValidationData; if (tsaRevocationDataXadesX1.hasRevocationDataEntries()) { timeStampXadesX1ValidationData = createValidationData(tsaRevocationDataXadesX1); } else { timeStampXadesX1ValidationData = null; } // marshal XAdES-X try { this.marshaller.marshal(this.objectFactory.createSigAndRefsTimeStamp(timeStampXadesX1), unsignedSignaturePropertiesNode); if (null != timeStampXadesX1ValidationData) { this.marshaller.marshal( this.xades141ObjectFactory.createTimeStampValidationData(timeStampXadesX1ValidationData), unsignedSignaturePropertiesNode); } } catch (JAXBException e) { throw new RuntimeException("JAXB error: " + e.getMessage(), e); } // XAdES-X-L CertificateValuesType certificateValues = this.objectFactory.createCertificateValuesType(); List<Object> certificateValuesList = certificateValues.getEncapsulatedX509CertificateOrOtherCertificate(); for (X509Certificate certificate : signingCertificateChain) { EncapsulatedPKIDataType encapsulatedPKIDataType = this.objectFactory.createEncapsulatedPKIDataType(); try { encapsulatedPKIDataType.setValue(certificate.getEncoded()); } catch (CertificateEncodingException e) { throw new RuntimeException("certificate encoding error: " + e.getMessage(), e); } certificateValuesList.add(encapsulatedPKIDataType); } RevocationValuesType revocationValues = createRevocationValues(revocationData); // marshal XAdES-X-L try { this.marshaller.marshal(this.objectFactory.createCertificateValues(certificateValues), unsignedSignaturePropertiesNode); this.marshaller.marshal(this.objectFactory.createRevocationValues(revocationValues), unsignedSignaturePropertiesNode); } catch (JAXBException e) { throw new RuntimeException("JAXB error: " + e.getMessage(), e); } }
From source file:com.autentia.mvn.plugin.changes.BugzillaChangesMojo.java
/** * Replaces the current release node in the changes.xml document * /* w w w . jav a2s .co m*/ * @param elementRelease * @param changesXml * @throws MojoExecutionException */ private void replaceReleaseNode(final Element elementRelease, final byte[] changesXml) throws MojoExecutionException { try { // formamos el documento obtenido final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); final DocumentBuilder db = dbf.newDocumentBuilder(); final ByteArrayInputStream bais = new ByteArrayInputStream(changesXml); final Document docChanges = db.parse(bais); // recuperamos el nodo de la release // slo debe haber un elemento final Node releaseNode = docChanges.getElementsByTagName(ELEMENT_RELEASE).item(0); final Node importNode = elementRelease.getOwnerDocument().importNode(releaseNode, true); elementRelease.getParentNode().replaceChild(importNode, elementRelease); } catch (final ParserConfigurationException e) { this.getLog().error("Error reading file " + this.xmlPath, e); throw new MojoExecutionException("Error reading file " + this.xmlPath, e); } catch (final SAXException e) { this.getLog().error("Error reading file " + this.xmlPath, e); throw new MojoExecutionException("Error reading file " + this.xmlPath, e); } catch (final IOException e) { this.getLog().error("Error reading file " + this.xmlPath, e); throw new MojoExecutionException("Error reading file " + this.xmlPath, e); } }
From source file:org.gvnix.service.roo.addon.addon.ws.export.WSExportWsdlConfigServiceImpl.java
/** * Get XML document representation from WSDL if valid. * <p>/* ww w . j a v a 2s . c o m*/ * Check WSDL is not RPC Encoded and has only one compatible port. * </p> * * @param url from WSDL file to export * @return XML document representation of WSDL */ protected Document checkWSDLFile(String url) { // Check URL connection and WSDL format Element root = securityService.getWsdl(url).getDocumentElement(); Validate.isTrue(!WsdlParserUtils.isRpcEncoded(root), "This Wsdl '" + url + "' is RPC Encoded and is not supported by the Add-on."); // Check if is compatible port defined with SOAP12 or SOAP11. WsdlParserUtils.checkCompatiblePort(root); return root.getOwnerDocument(); }