Java Code Examples for javax.xml.soap.SOAPBody#getFault()
The following examples show how to use
javax.xml.soap.SOAPBody#getFault() .
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: SchemaValidatorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void validate(SOAPMessageContext context, String mode) { try { SOAPBody body = context.getMessage().getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { return; } Node payloadNode = body.getFirstChild(); ValidatorHelper.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles); } catch (Exception var6) { dumpMessage(context.getMessage(), mode, LOG); LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage()); throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6); } LOG.info("Message validation done."); }
Example 2
Source File: SchemaValidatorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void validate(SOAPMessageContext context, String mode) { try { SOAPBody body = context.getMessage().getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { return; } Node payloadNode = body.getFirstChild(); ValidatorHelper.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles); } catch (Exception var6) { dumpMessage(context.getMessage(), mode, LOG); LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage()); throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6); } LOG.info("Message validation done."); }
Example 3
Source File: SchemaValidatorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void validate(SOAPMessageContext context, String mode) { try { SOAPBody body = context.getMessage().getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { return; } Node payloadNode = body.getFirstChild(); ValidatorHelper.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles); } catch (Exception var6) { dumpMessage(context.getMessage(), mode, LOG); LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage()); throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6); } LOG.info("Message validation done."); }
Example 4
Source File: SchemaValidatorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void validate(SOAPMessageContext context, String mode) { try { SOAPBody body = context.getMessage().getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { return; } Node payloadNode = body.getFirstChild(); ValidatorHelper.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles); } catch (Exception var6) { dumpMessage(context.getMessage(), mode, LOG); LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage()); throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6); } LOG.info("Message validation done."); }
Example 5
Source File: SoapFaultHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private String getSoapFaultCode(SOAPMessage msg) throws SOAPException{ SOAPPart part = msg.getSOAPPart(); if(part !=null){ SOAPEnvelope soapEnvelope = part.getEnvelope(); if(soapEnvelope !=null){ SOAPBody body = soapEnvelope.getBody(); if(body !=null){ SOAPFault fault=body.getFault(); if(fault !=null && !StringUtils.isEmpty(fault.getFaultString()) && fault.getFaultString().contains("SOA-")){ return fault.getFaultString(); } } } } return null; }
Example 6
Source File: SoapFaultHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private String getSoapFaultCode(SOAPMessage msg) throws SOAPException { SOAPPart part = msg.getSOAPPart(); if (part != null) { SOAPEnvelope soapEnvelope = part.getEnvelope(); if (soapEnvelope != null) { SOAPBody body = soapEnvelope.getBody(); if (body != null) { SOAPFault fault = body.getFault(); if (fault != null && !StringUtils.isEmpty(fault.getFaultString()) && fault.getFaultString().contains("SOA-")) { return fault.getFaultString(); } } } } return null; }
Example 7
Source File: SchemaValidatorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void validate(SOAPMessageContext context, String mode) { try { SOAPBody body = context.getMessage().getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { return; } Node payloadNode = body.getFirstChild(); ValidatorHelper.Companion.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles); } catch (Exception var6) { dumpMessage(context.getMessage(), mode, LOG); LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage()); throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6); } LOG.info("Message validation done."); }
Example 8
Source File: SoapFaultHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private String getSoapFaultCode(SOAPMessage msg) throws SOAPException{ SOAPPart part = msg.getSOAPPart(); if(part !=null){ SOAPEnvelope soapEnvelope = part.getEnvelope(); if(soapEnvelope !=null){ SOAPBody body = soapEnvelope.getBody(); if(body !=null){ SOAPFault fault=body.getFault(); if(fault !=null && !StringUtils.isEmpty(fault.getFaultString()) && fault.getFaultString().contains("SOA-")){ return fault.getFaultString(); } } } } return null; }
Example 9
Source File: SoapFaultHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private String getSoapFaultCode(SOAPMessage msg) throws SOAPException{ SOAPPart part = msg.getSOAPPart(); if(part !=null){ SOAPEnvelope soapEnvelope = part.getEnvelope(); if(soapEnvelope !=null){ SOAPBody body = soapEnvelope.getBody(); if(body !=null){ SOAPFault fault=body.getFault(); if(fault !=null && !StringUtils.isEmpty(fault.getFaultString()) && fault.getFaultString().contains("SOA-")){ return fault.getFaultString(); } } } } return null; }
Example 10
Source File: SoapValueParser.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
private void parseValuesFromSoapBody(SOAPMessage soapMessage, SOAPBody soapBody, ItemMap mapping, Set<String> itemCommands, Map<ItemConfiguration, String> itemConfigurationToValues, ItemConfiguration originalItemConfiguration) { SOAPFault soapFault = null; if (soapBody.hasFault()) { soapFault = soapBody.getFault(); } boolean anyValueMissing = false; boolean soapFaultHandled = false; for (String itemCommand : itemCommands) { ItemConfiguration itemConfiguration = deriveConfiguration(itemCommand, originalItemConfiguration); String value; if (soapFault == null) { value = parseValueFromSoapBody(itemConfiguration, soapBody, mapping); anyValueMissing |= (value == null); } else { value = parseValueFromSoapFault(itemConfiguration, soapFault, mapping); soapFaultHandled |= (value != null); } itemConfigurationToValues.put(itemConfiguration, value); } // log the SOAP Message once if it contained an unhandled fault or if it did not contain an expected item if (soapFault != null && !soapFaultHandled) { logger.warn("Fault received from FritzBox for item {} in SOAP response {}", originalItemConfiguration, soapToString(soapMessage)); } else if (anyValueMissing) { logger.debug("Some values received from FritzBox for item {} could not be found in SOAP response {}", originalItemConfiguration, soapToString(soapMessage)); // which items exacly were missing was already logged earlier } }
Example 11
Source File: SendMTConverterUtils.java From opencps-v2 with GNU Affero General Public License v3.0 | 4 votes |
private static SOAPMessage convertSendMTToXML(SendMT sendMT) { try { JAXBContext jaxbContext = JAXBContext.newInstance(SendMT.class); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage message = mf.createMessage(); SOAPBody body = message.getSOAPBody(); SOAPHeader soapheader = message.getSOAPHeader(); soapheader.detachNode(); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); // output pretty printed jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //process marshaller jaxbMarshaller.marshal(sendMT, body); //jaxbMarshaller.marshal(sendMT, System.out); message.saveChanges(); // Process convert SOAP-ENV to soapenv SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); // SOAPHeader header = message.getSOAPHeader(); SOAPBody bodyConvert = message.getSOAPBody(); SOAPFault fault = bodyConvert.getFault(); envelope.removeNamespaceDeclaration(envelope.getPrefix()); envelope.addNamespaceDeclaration(Constants.PREFERRED_PREFIX, Constants.SOAP_ENV_NAMESPACE); envelope.addNamespaceDeclaration(Constants.PREFERRED_PREFIX_TEM, Constants.SOAP_ENV_NAMESPACE_TEM); envelope.setPrefix(Constants.PREFERRED_PREFIX); bodyConvert.setPrefix(Constants.PREFERRED_PREFIX); if (fault != null) { fault.setPrefix(Constants.PREFERRED_PREFIX); } message.saveChanges(); return message; } catch (Exception e) { _log.error(e); } return null; }
Example 12
Source File: SOAPActionSpoofingActiveScanRule.java From zap-extensions with Apache License 2.0 | 4 votes |
int scanResponse(HttpMessage msg, HttpMessage originalMsg) { if (msg.getResponseBody().length() == 0) return EMPTY_RESPONSE; String responseContent = new String(msg.getResponseBody().getBytes()); responseContent = responseContent.trim(); if (responseContent.length() <= 0) { return EMPTY_RESPONSE; } SOAPMessage soapMsg = null; try { MessageFactory factory = MessageFactory.newInstance(); soapMsg = factory.createMessage( new MimeHeaders(), new ByteArrayInputStream( responseContent.getBytes( Charset.forName(msg.getResponseBody().getCharset())))); /* Looks for fault code. */ SOAPBody body = soapMsg.getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { /* * The web service server has detected something was wrong with the SOAPAction * header so it rejects the request. */ return FAULT_CODE; } // Body child. NodeList bodyList = body.getChildNodes(); if (bodyList.getLength() <= 0) return EMPTY_RESPONSE; /* Prepares original request to compare it. */ String originalContent = originalMsg.getResponseBody().toString(); SOAPMessage originalSoapMsg = factory.createMessage( new MimeHeaders(), new ByteArrayInputStream( originalContent.getBytes( Charset.forName( originalMsg.getResponseBody().getCharset())))); /* Comparison between original response body and attack response body. */ SOAPBody originalBody = originalSoapMsg.getSOAPBody(); NodeList originalBodyList = originalBody.getChildNodes(); if (bodyList.getLength() == originalBodyList.getLength()) { boolean match = true; for (int i = 0; i < bodyList.getLength() && match; i++) { Node node = bodyList.item(i); Node oNode = originalBodyList.item(i); String nodeName = node.getNodeName().trim(); String oNodeName = oNode.getNodeName().trim(); if (!nodeName.equals(oNodeName)) { match = false; } } if (match) { /* * Both responses have the same content. The SOAPAction header has been ignored. * SOAPAction Spoofing attack cannot be done if this happens. */ return SOAPACTION_IGNORED; } else { /* * The SOAPAction header has been processed and an operation which is not the * original one has been executed. */ return SOAPACTION_EXECUTED; } } else { /* * The SOAPAction header has been processed and an operation which is not the * original one has been executed. */ return SOAPACTION_EXECUTED; } } catch (IOException | SOAPException e) { LOG.info("Exception thrown when scanning: ", e); return INVALID_FORMAT; } }