doc = DocumentHelper.readDocument(octetStream); } catch (Exception e) { throw new TransformException(e.getMessage(), e);
public Object transformValue(String attrName, Object value) throws TransformException { try { Transform validator = (Transform) fieldCompactions.get(attrName); return validator != null ? validator.unpack(value) : value; } catch (ClassCastException e) { throw new TransformException("invalid attribute value for '" + attrName + "'"); } } }
public InputStream canonicalize(InputStream input,OutputStream outputStream) throws javax.xml.crypto.dsig.TransformException { try{ if(outputStream == null){ return input; }else{ byte [] data = new byte[128]; while(true){ int len = input.read(data); if(len <= 0) break; outputStream.write(data,0,len); } } return null; }catch(Exception ex){ log.log(Level.SEVERE, "WSS1000.error.canonicalizing", new Object[] {ex.getMessage()}); throw new javax.xml.crypto.dsig.TransformException(ex.getMessage()); } } }
public InputStream canonicalize(InputStream input,OutputStream outputStream) throws javax.xml.crypto.dsig.TransformException { try{ if(outputStream == null){ return input; }else{ byte [] data = new byte[128]; while(true){ int len = input.read(data); if(len <= 0) break; outputStream.write(data,0,len); } } }catch(Exception ex){ log.log(Level.SEVERE, "WSS1001.error.canonicalizing.image", new Object[] {ex.getMessage()}); throw new javax.xml.crypto.dsig.TransformException(ex.getMessage()); } return null; } }
@Override public Map<String, Object> pack(Map<String, Object> instance) throws TransformException { if (instance == null) { throw new TransformException("instance must not be null"); throw new TransformException("attribute must not be null: " + attrName); throw new TransformException("invalid attribute value for '" + attrName + "'");
protected Attachment attachmentRequestCallback(XMLCryptoContext context, String attachmentId) throws TransformException { CallbackHandler attachmentCallbackHandler = (CallbackHandler) context.getProperty(ATTACHMENT_CALLBACKHANDLER); if (attachmentCallbackHandler == null) { throw new TransformException("No attachment callbackhandler supplied"); } AttachmentRequestCallback attachmentRequestCallback = new AttachmentRequestCallback(); attachmentRequestCallback.setAttachmentId(attachmentId); try { attachmentCallbackHandler.handle(new Callback[]{attachmentRequestCallback}); } catch (Exception e) { throw new TransformException(e); } List<Attachment> attachments = attachmentRequestCallback.getAttachments(); if (attachments == null || attachments.isEmpty() || !attachmentId.equals(attachments.get(0).getId())) { throw new TransformException("Attachment not found"); } return attachments.get(0); }
@Override public Map<String, Object> unpack(Map<String, Object> instance) throws TransformException { if (instance == null) { throw new TransformException("instance must not be null"); } Map<String, Object> mindlessClone = new LinkedHashMap<String, Object>(); for (Map.Entry<String, Object> e : instance.entrySet()) { String attrName = e.getKey(); Attribute attribute = schema.getAttribute(attrName); if (attribute == null) { mindlessClone.put(attrName, e.getValue()); continue; } Object inbound = e.getValue(); if (inbound == null) { if (attribute.isNullable()) { mindlessClone.put(attrName, null); continue; } throw new TransformException("attribute must not be null: " + attrName); } Transform validator = fieldCompactions.get(attrName); Object untransformed = validator.unpack(inbound); mindlessClone.put(attrName, untransformed); } return mindlessClone; }
private static Set getNodeSet(Data data)throws javax.xml.crypto.dsig.TransformException{ HashSet nodeSet = new HashSet(); if(data instanceof NodeSetData){ Iterator it = ((NodeSetData)data).iterator(); while(it.hasNext()){ Object node = it.next(); if(MessageConstants.debug){ logger.log(Level.FINEST,"Data is "+node); } nodeSet.add(node); } }else if(data instanceof OctetStreamData ){ try{ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //new com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl(); factory.setNamespaceAware(true); Document doc = factory.newDocumentBuilder().parse(((OctetStreamData)data).getOctetStream()); toNodeSet(doc,nodeSet); }catch(Exception ex){ logger.log(Level.SEVERE,"WSS1322.str_transform",ex); throw new javax.xml.crypto.dsig.TransformException(ex.getMessage()); } } return nodeSet; }
log.log(Level.SEVERE, "WSS1002.error.canonicalizing.textplain", new Object[] {e.getMessage()}); throw new javax.xml.crypto.dsig.TransformException(e); log.log(Level.SEVERE, "WSS1002.error.canonicalizing.textplain", new Object[] {e.getMessage()}); throw new javax.xml.crypto.dsig.TransformException(e);
public Data transform(Data data, XMLCryptoContext xMLCryptoContext) throws TransformException { if(algorithm == CanonicalizationMethod.EXCLUSIVE){ try { _exc14nCanonicalizer.init((TransformParameterSpec) _algSpec); } catch (InvalidAlgorithmParameterException ex) { logger.log(Level.SEVERE, LogStringsMessages.WSS_1758_TRANSFORM_INIT(),ex); throw new TransformException(ex); } _exc14nCanonicalizer.transform(data,xMLCryptoContext); } return null; }
protected void attachmentResultCallback(XMLCryptoContext context, Attachment attachment) throws TransformException { CallbackHandler attachmentCallbackHandler = (CallbackHandler) context.getProperty(ATTACHMENT_CALLBACKHANDLER); if (attachmentCallbackHandler == null) { throw new TransformException("No attachment callbackhandler supplied"); } AttachmentResultCallback attachmentResultCallback = new AttachmentResultCallback(); attachmentResultCallback.setAttachmentId(attachment.getId()); attachmentResultCallback.setAttachment(attachment); try { attachmentCallbackHandler.handle(new Callback[]{attachmentResultCallback}); } catch (Exception e) { throw new TransformException(e); } }
private javax.xml.crypto.Data canonicalize(AttachmentData data,OutputStream outputStream) throws javax.xml.crypto.dsig.TransformException{ try{ AttachmentPart attachment = data.getAttachmentPart(); ByteArrayOutputStream os = new ByteArrayOutputStream(); attachment.getDataHandler().writeTo(os); OutputStream byteStream = null; ByteArrayInputStream byteInputStream = new ByteArrayInputStream(os.toByteArray()); if(outputStream == null){ byteStream = new ByteArrayOutputStream(); }else{ byteStream = outputStream; } Canonicalizer canonicalizer = CanonicalizerFactory.getCanonicalizer(attachment.getContentType()); InputStream is = canonicalizer.canonicalize(byteInputStream,byteStream); if(is!= null) return new OctetStreamData(is); return null; }catch(javax.xml.crypto.dsig.TransformException te){ logger.log(Level.SEVERE,"WSS1318.ac.transform.error",te); throw te; }catch(Exception ex){ logger.log(Level.SEVERE,"WSS1318.ac.transform.error",ex); throw new javax.xml.crypto.dsig.TransformException(ex.getMessage()); } }
doc = DocumentHelper.readDocument(octetStream); } catch (Exception e) { throw new TransformException(e.getMessage(), e);
private Data canonicalize(AttachmentData attachmentData, OutputStream os) throws TransformException { try{ Attachment attachment = attachmentData.getAttachment(); InputStream is = attachment.asInputStream(); OutputStream byteStream = null; if (os == null) { byteStream = new ByteArrayOutputStream(); } else { byteStream = os; } Canonicalizer canonicalizer = CanonicalizerFactory.getCanonicalizer(attachment.getContentType()); InputStream resultIs = canonicalizer.canonicalize(is,byteStream); if(resultIs!= null) return new OctetStreamData(resultIs); return null; }catch(Exception ex){ throw new TransformException(ex.getMessage()); } } }
}catch(Exception ex){ logger.log(Level.SEVERE,"WSS1319.aco.transform.error",ex); throw new javax.xml.crypto.dsig.TransformException(ex.getMessage());
_canonicalizer.writeNamespace(nd.getPrefix(),nd.getNamespaceURI()); } catch (XMLStreamException ex) { throw new TransformException(ex); } catch (XMLStreamException ex) { logger.log(Level.SEVERE, LogStringsMessages.WSS_1759_TRANSFORM_ERROR(ex.getMessage()),ex); throw new TransformException(ex);
@Override public Data transform(Data data, XMLCryptoContext xc) throws TransformException { // ignore comments if dereferencing same-document URI that requires // you to omit comments, even if the Transform says otherwise - // this is to be compliant with section 4.3.3.3 of W3C Rec. if (data instanceof DOMSubTreeData) { DOMSubTreeData subTree = (DOMSubTreeData) data; if (subTree.excludeComments()) { try { apacheCanonicalizer = Canonicalizer.getInstance(C14N_11); boolean secVal = Utils.secureValidation(xc); apacheCanonicalizer.setSecureValidation(secVal); } catch (InvalidCanonicalizerException ice) { throw new TransformException ("Couldn't find Canonicalizer for: " + C14N_11 + ": " + ice.getMessage(), ice); } } } return canonicalize(data, xc); } }
@Override public Data transform(Data data, XMLCryptoContext xc) throws TransformException { // ignore comments if dereferencing same-document URI that requires // you to omit comments, even if the Transform says otherwise - // this is to be compliant with section 4.3.3.3 of W3C Rec. if (data instanceof DOMSubTreeData) { DOMSubTreeData subTree = (DOMSubTreeData) data; if (subTree.excludeComments()) { try { apacheCanonicalizer = Canonicalizer.getInstance (CanonicalizationMethod.INCLUSIVE); boolean secVal = Utils.secureValidation(xc); apacheCanonicalizer.setSecureValidation(secVal); } catch (InvalidCanonicalizerException ice) { throw new TransformException ("Couldn't find Canonicalizer for: " + CanonicalizationMethod.INCLUSIVE + ": " + ice.getMessage(), ice); } } } return canonicalize(data, xc); } }
@Override public Data transform(Data data, XMLCryptoContext xc) throws TransformException { // ignore comments if dereferencing same-document URI that require // you to omit comments, even if the Transform says otherwise - // this is to be compliant with section 4.3.3.3 of W3C Rec. if (data instanceof DOMSubTreeData) { DOMSubTreeData subTree = (DOMSubTreeData)data; if (subTree.excludeComments()) { try { apacheCanonicalizer = Canonicalizer.getInstance (CanonicalizationMethod.EXCLUSIVE); boolean secVal = Utils.secureValidation(xc); apacheCanonicalizer.setSecureValidation(secVal); } catch (InvalidCanonicalizerException ice) { throw new TransformException ("Couldn't find Canonicalizer for: " + CanonicalizationMethod.EXCLUSIVE + ": " + ice.getMessage(), ice); } } } return canonicalize(data, xc); } }