private void validateFault(SoapMessage message, SOAPFault fault, BindingOperationInfo bop) { if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) { Schema schema = EndpointReferenceUtils.getSchema(message.getExchange().getService() .getServiceInfos().get(0), message.getExchange().getBus()); Detail d = fault.getDetail(); try { validateFaultDetail(d, schema, bop); } catch (Exception e) { throw new SoapFault(e.getMessage(), e, message.getVersion().getReceiver()); } //We validated what we can from a fault standpoint message.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE); } }
public XSDResourceTypeIdentifier(Source xsd, ResourceTransformer resourceTransformer) { try { this.resourceTransformer = resourceTransformer; SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(xsd); this.validator = schema.newValidator(); } catch (SAXException ex) { LOG.severe(ex.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } }
public XSDResourceValidator(Source xsd, ResourceTransformer resourceTransformer) { try { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(xsd); this.validator = schema.newValidator(); } catch (SAXException ex) { LOG.severe(ex.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } }
@Override public boolean validate(Representation representation, Representation oldRepresentation) { try { validator.validate(new DOMSource((Node) representation.getAny())); } catch (SAXException ex) { return false; } catch (IOException ex) { LOG.severe(ex.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } return true; }
public XSDResourceValidator(Source xsd, ResourceTransformer resourceTransformer) { try { SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(xsd); this.validator = schema.newValidator(); } catch (SAXException ex) { LOG.severe(ex.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } }
public XSDResourceTypeIdentifier(Source xsd, ResourceTransformer resourceTransformer) { try { this.resourceTransformer = resourceTransformer; SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(xsd); this.validator = schema.newValidator(); } catch (SAXException ex) { LOG.severe(ex.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } }
@Override public boolean validate(Representation representation, Representation oldRepresentation) { try { validator.validate(new DOMSource((Node) representation.getAny())); } catch (SAXException ex) { return false; } catch (IOException ex) { LOG.severe(ex.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } return true; }
public XSLTResourceTransformer(Source xsl, ResourceValidator validator) { this.validator = validator; try { templates = TransformerFactory.newInstance().newTemplates(xsl); } catch (TransformerConfigurationException e) { LOG.severe(e.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } }
public XSLTResourceTransformer(Source xsl, ResourceValidator validator) { this.validator = validator; try { templates = TransformerFactory.newInstance().newTemplates(xsl); } catch (TransformerConfigurationException e) { LOG.severe(e.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } }
private String getAction(SoapMessage msg, SoapVersion version) { String action = (String)getOption(ConfigurationConstants.ACTION); if (action == null) { action = (String)msg.get(ConfigurationConstants.ACTION); } if (action == null && !ignoreActions) { LOG.warning("No security action was defined!"); throw new SoapFault("No security action was defined!", version.getReceiver()); } return action; }
@Override public ResourceTypeIdentifierResult identify(Representation representation) { try { validator.validate(new DOMSource((Node) representation.getAny())); } catch (SAXException ex) { return new ResourceTypeIdentifierResult(false, resourceTransformer); } catch (IOException ex) { LOG.severe(ex.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } return new ResourceTypeIdentifierResult(true, resourceTransformer); }
private String getAction(SoapMessage msg, SoapVersion version) { String action = (String)getOption(ConfigurationConstants.ACTION); if (action == null) { action = (String)msg.get(ConfigurationConstants.ACTION); } if (action == null && !ignoreActions) { LOG.warning("No security action was defined!"); throw new SoapFault("No security action was defined!", version.getReceiver()); } return action; }
@Override public ResourceTypeIdentifierResult identify(Representation representation) { try { validator.validate(new DOMSource((Node) representation.getAny())); } catch (SAXException ex) { return new ResourceTypeIdentifierResult(false, resourceTransformer); } catch (IOException ex) { LOG.severe(ex.getLocalizedMessage()); throw new SoapFault("Internal error", getSoapVersion().getReceiver()); } return new ResourceTypeIdentifierResult(true, resourceTransformer); }
@Override public Representation get(ReferenceParametersType ref) { String uuid = getUUID(ref); if (!storage.containsKey(uuid)) { throw new UnknownResource(); } String resource = storage.get(uuid); if (resource.isEmpty()) { return new Representation(); } Document doc = null; try { doc = StaxUtils.read(new StringReader(storage.get(uuid))); } catch (XMLStreamException e) { LOG.severe(e.getLocalizedMessage()); throw new SoapFault("Internal Error", getSoapVersion().getReceiver()); } Representation representation = new Representation(); representation.setAny(doc.getDocumentElement()); return representation; }
@Override public Representation get(ReferenceParametersType ref) { String uuid = getUUID(ref); if (!storage.containsKey(uuid)) { throw new UnknownResource(); } String resource = storage.get(uuid); if (resource.isEmpty()) { return new Representation(); } Document doc = null; try { doc = StaxUtils.read(new StringReader(storage.get(uuid))); } catch (XMLStreamException e) { LOG.severe(e.getLocalizedMessage()); throw new SoapFault("Internal Error", getSoapVersion().getReceiver()); } Representation representation = new Representation(); representation.setAny(doc.getDocumentElement()); return representation; }
Fault createSoap11Fault(SequenceFault sf) { return new SoapFault(sf.getReason(), sf.isSender() ? version.getSender() : version.getReceiver()); }
private static void updateSoap12FaultCodes(SoapFault f) { //per Soap 1.2 spec, the fault code MUST be one of the 5 values specified in the spec. //Soap 1.1 allows the soap fault code to be arbitrary (recommends the 4 values in the spec, but //explicitely mentions that it can be extended to include additional codes). Soap 1.2 however //requires the use of one of the 5 defined codes. Additional detail or more specific information //can be transferred via the SubCodes. QName fc = f.getFaultCode(); SoapVersion v = Soap12.getInstance(); if (fc.getNamespaceURI().equals(Soap12.SOAP_NAMESPACE) && (fc.equals(v.getReceiver()) || fc.equals(v.getSender()) || fc.equals(v.getMustUnderstand()) || fc.equals(v.getDateEncodingUnknown()) || fc.equals(v.getVersionMismatch()))) { //valid fault codes, don't change anything return; } f.setFaultCode(Soap12.getInstance().getReceiver()); if (f.getSubCodes() == null) { f.setRootSubCode(fc); } else if (!f.getSubCodes().contains(fc)) { f.getSubCodes().add(fc); } } public static SoapFault createFault(Fault f, SoapVersion v) {
private void validateFault(SoapMessage message, SOAPFault fault, BindingOperationInfo bop) { if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) { Schema schema = EndpointReferenceUtils.getSchema(message.getExchange().getService() .getServiceInfos().get(0), message.getExchange().getBus()); Detail d = fault.getDetail(); try { validateFaultDetail(d, schema, bop); } catch (Exception e) { throw new SoapFault(e.getMessage(), e, message.getVersion().getReceiver()); } //We validated what we can from a fault standpoint message.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE); } }
Fault createSoap12Fault(JMSFault jmsFault) { SoapFault fault = new SoapFault(jmsFault.getReason(), jmsFault.isSender() ? version.getSender() : version.getReceiver()); QName subCode = jmsFault.getSubCode(); fault.setSubCode(subCode); Object detail = jmsFault.getDetail(); if (null == detail) { return fault; } setDetail(fault, detail); return fault; }
Fault createSoap12Fault(JMSFault jmsFault) { SoapFault fault = new SoapFault(jmsFault.getReason(), jmsFault.isSender() ? version.getSender() : version.getReceiver()); QName subCode = jmsFault.getSubCode(); fault.setSubCode(subCode); Object detail = jmsFault.getDetail(); if (null == detail) { return fault; } setDetail(fault, detail); return fault; }