Java Code Examples for javax.xml.soap.SOAPElement#getChildNodes()
The following examples show how to use
javax.xml.soap.SOAPElement#getChildNodes() .
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: PartnerUtils.java From netbeans with Apache License 2.0 | 6 votes |
public static String getUniqueID(SOAPElement itinerary) { String uniqueID = ""; NodeList nodeList = itinerary.getChildNodes(); try { for(int index1=0; index1<nodeList.getLength() ; index1++) { Node node1 = nodeList.item(index1); if(node1.getNodeName().endsWith("ItineraryRef")) { for (int index2=0 ; index2<node1.getChildNodes().getLength() ; index2++) { Node node2 = node1.getChildNodes().item(index2); if(node2.getNodeName().endsWith("UniqueID")) { uniqueID = node2.getTextContent(); break; } } } } } catch (Exception ex) { } return uniqueID; }
Example 2
Source File: SignCode.java From Tomcat8-Source-Read with MIT License | 4 votes |
private String makeSigningRequest(List<File> filesToSign) throws SOAPException, IOException { log("Constructing the code signing request"); SOAPMessage message = SOAP_MSG_FACTORY.createMessage(); SOAPBody body = populateEnvelope(message, NS); SOAPElement requestSigning = body.addChildElement("requestSigning", NS); SOAPElement requestSigningRequest = requestSigning.addChildElement("requestSigningRequest", NS); addCredentials(requestSigningRequest, this.userName, this.password, this.partnerCode); SOAPElement applicationName = requestSigningRequest.addChildElement("applicationName", NS); applicationName.addTextNode(this.applicationName); SOAPElement applicationVersion = requestSigningRequest.addChildElement("applicationVersion", NS); applicationVersion.addTextNode(this.applicationVersion); SOAPElement signingServiceName = requestSigningRequest.addChildElement("signingServiceName", NS); signingServiceName.addTextNode(this.signingService); List<String> fileNames = getFileNames(filesToSign); SOAPElement commaDelimitedFileNames = requestSigningRequest.addChildElement("commaDelimitedFileNames", NS); commaDelimitedFileNames.addTextNode(StringUtils.join(fileNames)); SOAPElement application = requestSigningRequest.addChildElement("application", NS); application.addTextNode(getApplicationString(fileNames, filesToSign)); // Send the message SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); log("Sending signing request to server and waiting for response"); SOAPMessage response = connection.call(message, SIGNING_SERVICE_URL); if (debug) { ByteArrayOutputStream baos = new ByteArrayOutputStream(2 * 1024); response.writeTo(baos); log(baos.toString("UTF-8")); } log("Processing response"); SOAPElement responseBody = response.getSOAPBody(); // Should come back signed NodeList bodyNodes = responseBody.getChildNodes(); NodeList requestSigningResponseNodes = bodyNodes.item(0).getChildNodes(); NodeList returnNodes = requestSigningResponseNodes.item(0).getChildNodes(); String signingSetID = null; String signingSetStatus = null; for (int i = 0; i < returnNodes.getLength(); i++) { Node returnNode = returnNodes.item(i); if (returnNode.getLocalName().equals("signingSetID")) { signingSetID = returnNode.getTextContent(); } else if (returnNode.getLocalName().equals("signingSetStatus")) { signingSetStatus = returnNode.getTextContent(); } } if (!signingService.contains("TEST") && !"SIGNED".equals(signingSetStatus) || signingService.contains("TEST") && !"INITIALIZED".equals(signingSetStatus) ) { throw new BuildException("Signing failed. Status was: " + signingSetStatus); } return signingSetID; }
Example 3
Source File: SignCode.java From Tomcat8-Source-Read with MIT License | 4 votes |
private void downloadSignedFiles(List<File> filesToSign, String id) throws SOAPException, IOException { log("Downloading signed files. The signing set ID is: " + id); SOAPMessage message = SOAP_MSG_FACTORY.createMessage(); SOAPBody body = populateEnvelope(message, NS); SOAPElement getSigningSetDetails = body.addChildElement("getSigningSetDetails", NS); SOAPElement getSigningSetDetailsRequest = getSigningSetDetails.addChildElement("getSigningSetDetailsRequest", NS); addCredentials(getSigningSetDetailsRequest, this.userName, this.password, this.partnerCode); SOAPElement signingSetID = getSigningSetDetailsRequest.addChildElement("signingSetID", NS); signingSetID.addTextNode(id); SOAPElement returnApplication = getSigningSetDetailsRequest.addChildElement("returnApplication", NS); returnApplication.addTextNode("true"); // Send the message SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); log("Requesting signed files from server and waiting for response"); SOAPMessage response = connection.call(message, SIGNING_SERVICE_URL); log("Processing response"); SOAPElement responseBody = response.getSOAPBody(); // Check for success // Extract the signed file(s) from the ZIP NodeList bodyNodes = responseBody.getChildNodes(); NodeList getSigningSetDetailsResponseNodes = bodyNodes.item(0).getChildNodes(); NodeList returnNodes = getSigningSetDetailsResponseNodes.item(0).getChildNodes(); String result = null; String data = null; for (int i = 0; i < returnNodes.getLength(); i++) { Node returnNode = returnNodes.item(i); if (returnNode.getLocalName().equals("result")) { result = returnNode.getChildNodes().item(0).getTextContent(); } else if (returnNode.getLocalName().equals("signingSet")) { data = returnNode.getChildNodes().item(1).getTextContent(); } } if (!"0".equals(result)) { throw new BuildException("Download failed. Result code was: " + result); } extractFilesFromApplicationString(data, filesToSign); }
Example 4
Source File: SignCodeMojo.java From sling-whiteboard with Apache License 2.0 | 4 votes |
private String makeSigningRequest(SignedFiles signedFiles) throws SOAPException, IOException, MojoExecutionException { log("Constructing the code signing request"); SOAPMessage message = SOAP_MSG_FACTORY.createMessage(); SOAPBody body = populateEnvelope(message, NS); SOAPElement requestSigning = body.addChildElement("requestSigning", NS); SOAPElement requestSigningRequest = requestSigning.addChildElement("requestSigningRequest", NS); addCredentials(requestSigningRequest, this.userName, this.password, this.partnerCode); SOAPElement applicationName = requestSigningRequest.addChildElement("applicationName", NS); applicationName.addTextNode(this.applicationName); SOAPElement applicationVersion = requestSigningRequest.addChildElement("applicationVersion", NS); applicationVersion.addTextNode(this.applicationVersion); SOAPElement signingServiceName = requestSigningRequest.addChildElement("signingServiceName", NS); signingServiceName.addTextNode(this.signingService); SOAPElement commaDelimitedFileNames = requestSigningRequest.addChildElement("commaDelimitedFileNames", NS); commaDelimitedFileNames.addTextNode(signedFiles.getCommaSeparatedUploadFileNames()); SOAPElement application = requestSigningRequest.addChildElement("application", NS); application.addTextNode(signedFiles.getApplicationString()); // Send the message SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); log("Sending signing request to server and waiting for response"); SOAPMessage response = connection.call(message, SIGNING_SERVICE_URL); if ( getLog().isDebugEnabled()) { ByteArrayOutputStream baos = new ByteArrayOutputStream(2 * 1024); response.writeTo(baos); getLog().debug(baos.toString("UTF-8")); } log("Processing response"); SOAPElement responseBody = response.getSOAPBody(); // Should come back signed NodeList bodyNodes = responseBody.getChildNodes(); NodeList requestSigningResponseNodes = bodyNodes.item(0).getChildNodes(); NodeList returnNodes = requestSigningResponseNodes.item(0).getChildNodes(); String signingSetID = null; String signingSetStatus = null; StringBuilder errors = new StringBuilder(); for (int i = 0; i < returnNodes.getLength(); i++) { Node returnNode = returnNodes.item(i); if (returnNode.getLocalName().equals("signingSetID")) { signingSetID = returnNode.getTextContent(); } else if (returnNode.getLocalName().equals("signingSetStatus")) { signingSetStatus = returnNode.getTextContent(); } else if (returnNode.getLocalName().equals("result") ) { final NodeList returnChildNodes = returnNode.getChildNodes(); for (int j = 0; j < returnChildNodes.getLength(); j++ ) { if ( returnChildNodes.item(j).getLocalName().equals("errors") ) { extractErrors(returnChildNodes.item(j), errors); } } } } if (!signingService.contains("TEST") && !"SIGNED".equals(signingSetStatus) || signingService.contains("TEST") && !"INITIALIZED".equals(signingSetStatus) ) { throw new BuildException("Signing failed. Status was: " + signingSetStatus + " . Reported errors: " + errors + "."); } return signingSetID; }
Example 5
Source File: SignCodeMojo.java From sling-whiteboard with Apache License 2.0 | 4 votes |
private void downloadSignedFiles(SignedFiles signedFiles, String id) throws SOAPException, IOException, BuildException { log("Downloading signed files. The signing set ID is: " + id); SOAPMessage message = SOAP_MSG_FACTORY.createMessage(); SOAPBody body = populateEnvelope(message, NS); SOAPElement getSigningSetDetails = body.addChildElement("getSigningSetDetails", NS); SOAPElement getSigningSetDetailsRequest = getSigningSetDetails.addChildElement("getSigningSetDetailsRequest", NS); addCredentials(getSigningSetDetailsRequest, this.userName, this.password, this.partnerCode); SOAPElement signingSetID = getSigningSetDetailsRequest.addChildElement("signingSetID", NS); signingSetID.addTextNode(id); SOAPElement returnApplication = getSigningSetDetailsRequest.addChildElement("returnApplication", NS); returnApplication.addTextNode("true"); // Send the message SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); log("Requesting signed files from server and waiting for response"); SOAPMessage response = connection.call(message, SIGNING_SERVICE_URL); log("Processing response"); SOAPElement responseBody = response.getSOAPBody(); // Check for success // Extract the signed file(s) from the ZIP NodeList bodyNodes = responseBody.getChildNodes(); NodeList getSigningSetDetailsResponseNodes = bodyNodes.item(0).getChildNodes(); NodeList returnNodes = getSigningSetDetailsResponseNodes.item(0).getChildNodes(); String result = null; String data = null; for (int i = 0; i < returnNodes.getLength(); i++) { Node returnNode = returnNodes.item(i); if (returnNode.getLocalName().equals("result")) { result = returnNode.getChildNodes().item(0).getTextContent(); } else if (returnNode.getLocalName().equals("signingSet")) { data = returnNode.getChildNodes().item(1).getTextContent(); } } if (!"0".equals(result)) { throw new BuildException("Download failed. Result code was: " + result); } signedFiles.extractFilesFromApplicationString(data); }