Examples of OctetStreamData


Examples of javax.xml.crypto.OctetStreamData

    }

    public Data transform(Data data, XMLCryptoContext context) throws TransformException {
        LOG.log(POILogger.DEBUG, "transform(data,context)");
        LOG.log(POILogger.DEBUG, "data java type: " + data.getClass().getName());
        OctetStreamData octetStreamData = (OctetStreamData) data;
        LOG.log(POILogger.DEBUG, "URI: " + octetStreamData.getURI());
        InputStream octetStream = octetStreamData.getOctetStream();
       
        RelationshipsDocument relDoc;
        try {
            relDoc = RelationshipsDocument.Factory.parse(octetStream);
        } catch (Exception e) {
            throw new TransformException(e.getMessage(), e);
        }
        LOG.log(POILogger.DEBUG, "relationships document", relDoc);
       
        CTRelationships rels = relDoc.getRelationships();
        List<CTRelationship> relList = rels.getRelationshipList();
        Iterator<CTRelationship> relIter = rels.getRelationshipList().iterator();
        while (relIter.hasNext()) {
            CTRelationship rel = relIter.next();
            /*
             * See: ISO/IEC 29500-2:2008(E) - 13.2.4.24 Relationships Transform
             * Algorithm.
             */
            if (!this.sourceIds.contains(rel.getId())) {
                LOG.log(POILogger.DEBUG, "removing element: " + rel.getId());
                relIter.remove();
            } else {
                if (!rel.isSetTargetMode()) {
                    rel.setTargetMode(STTargetMode.INTERNAL);
                }
            }
        }
       
        // TODO: remove non element nodes ???
        LOG.log(POILogger.DEBUG, "# Relationship elements", relList.size());
       
        XmlSort.sort(rels, new Comparator<XmlCursor>(){
            public int compare(XmlCursor c1, XmlCursor c2) {
                String id1 = ((CTRelationship)c1.getObject()).getId();
                String id2 = ((CTRelationship)c2.getObject()).getId();
                return id1.compareTo(id2);
            }
        });

        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            XmlOptions xo = new XmlOptions();
            xo.setSaveNoXmlDecl();
            relDoc.save(bos, xo);
            return new OctetStreamData(new ByteArrayInputStream(bos.toByteArray()));
        } catch (IOException e) {
            throw new TransformException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

            if (os != null) {
                os.write(buf);
                return null;
            }
            return new OctetStreamData(new ByteArrayInputStream(buf));
        } catch (Exception ex) {
            throw new TransformException(ex);
        }
    }
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

            AttachmentUtils.canonizeMimeHeaders(os, attachment.getHeaders());
            processAttachment(context, os, attachmentUri, attachment);

            if (os == null) {
                String mimeType = attachment.getMimeType();
                return new OctetStreamData(
                        new ByteArrayInputStream(
                                ((ByteArrayOutputStream)outputStream).toByteArray()
                        ),
                        attachmentUri, mimeType);
            }
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

            String uri = ref.getURI();
            if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
                try {
                    FileInputStream fis = new FileInputStream(new File
                        (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
                    return new OctetStreamData(fis,ref.getURI(),ref.getType());
                } catch (Exception e) { throw new URIReferenceException(e); }
            }

            // fallback on builtin deref
            return defaultUd.dereference(ref, ctx);
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

            String uri = ref.getURI();
            if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
                try {
                    FileInputStream fis = new FileInputStream(new File
                        (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
                    return new OctetStreamData(fis,ref.getURI(),ref.getType());
                } catch (Exception e) { throw new URIReferenceException(e); }
            }

            // fallback on builtin deref
            return defaultUd.dereference(ref, ctx);
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

        }
       
        public boolean validate(XMLValidateContext vCtx)
            throws XMLSignatureException {
            this.dis = new ByteArrayInputStream(id.getBytes());
            this.derefData = new OctetStreamData(this.dis);
            return status;
        }
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

        public OctetStreamURIDereferencer(byte[] in) {
            data = (byte[]) in.clone();
        }
       
        public Data dereference(URIReference ref, XMLCryptoContext ctxt) {
            return new OctetStreamData(new ByteArrayInputStream(data));
        }
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

            XMLSignatureInput output = new XMLSignatureInput(bf1.getBytes());
            if (os != null) {
                output.updateOutputStream(os);
                return null;
            }
            return new OctetStreamData(output.getOctetStream());
        } catch (Exception ex) {
            throw new TransformException(ex);
        }
    }
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

        } 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());
        }
    }
View Full Code Here

Examples of javax.xml.crypto.OctetStreamData

                logger.log(Level.SEVERE, LogStringsMessages.WSS_1759_TRANSFORM_ERROR(ex.getMessage()),ex);
                throw new TransformException(ex);
            }
           
           
            return new OctetStreamData(new ByteArrayInputStream(baos.getBytes(),0,baos.getLength()));
        }
        throw new UnsupportedOperationException("Data type"+data+" not yet supported");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.