Package org.jcp.xml.dsig.internal

Examples of org.jcp.xml.dsig.internal.DigesterOutputStream


      } catch (NoSuchAlgorithmException nsae) {
          throw new XMLSignatureException(nsae);
      }
  }
  md.reset();
  DigesterOutputStream dos;
  Boolean cache = (Boolean)
            context.getProperty("javax.xml.crypto.dsig.cacheReference");
        if (cache != null && cache.booleanValue() == true) {
            this.derefData = copyDerefData(dereferencedData);
            dos = new DigesterOutputStream(md, true);
        } else {
            dos = new DigesterOutputStream(md);
        }
  OutputStream os = new UnsyncBufferedOutputStream(dos);
        Data data = dereferencedData;
        for (int i = 0, size = transforms.size(); i < size; i++) {
      DOMTransform transform = (DOMTransform) transforms.get(i);
      try {
                if (i < size - 1) {
                    data = transform.transform(data, context);
                } else {
                    data = transform.transform(data, context, os);
                }
      } catch (TransformException te) {
    throw new XMLSignatureException(te);
      }
        }
 
  try {
      if (data != null) {
          XMLSignatureInput xi;
          // explicitly use C14N 1.1 when generating signature
    // first check system property, then context property
    boolean c14n11 = useC14N11;
    String c14nalg = CanonicalizationMethod.INCLUSIVE;
          if (context instanceof XMLSignContext) {
        if (!c14n11) {
                  Boolean prop = (Boolean) context.getProperty
          ("org.apache.xml.security.useC14N11");
            c14n11 = (prop != null && prop.booleanValue() == true);
      if (c14n11) {
                c14nalg = "http://www.w3.org/2006/12/xml-c14n11";
      }
        } else {
            c14nalg = "http://www.w3.org/2006/12/xml-c14n11";
        }
    }
          if (data instanceof ApacheData) {
              xi = ((ApacheData) data).getXMLSignatureInput();
          } else if (data instanceof OctetStreamData) {
              xi = new XMLSignatureInput
      (((OctetStreamData)data).getOctetStream());
          } else if (data instanceof NodeSetData) {
        TransformService spi = null;
        try {
            spi = TransformService.getInstance(c14nalg, "DOM");
        } catch (NoSuchAlgorithmException nsae) {
            spi = TransformService.getInstance
                (c14nalg, "DOM", provider);
        }
                    data = spi.transform(data, context);
              xi = new XMLSignatureInput
            (((OctetStreamData)data).getOctetStream());
          } else {
              throw new XMLSignatureException("unrecognized Data type");
          }
          if (context instanceof XMLSignContext && c14n11
        && !xi.isOctetStream() && !xi.isOutputStreamSet()) {
        DOMTransform t = new DOMTransform
      (TransformService.getInstance(c14nalg, "DOM"));
        Element transformsElem = null;
        String dsPrefix = DOMUtils.getSignaturePrefix(context);
        if (allTransforms.isEmpty()) {
                transformsElem = DOMUtils.createElement(
          refElem.getOwnerDocument(),
          "Transforms", XMLSignature.XMLNS, dsPrefix);
          refElem.insertBefore(transformsElem,
          DOMUtils.getFirstChildElement(refElem));
        } else {
                transformsElem = DOMUtils.getFirstChildElement(refElem);
        }
              t.marshal(transformsElem, dsPrefix, (DOMCryptoContext) context);
        allTransforms.add(t);
              xi.updateOutputStream(os, true);
    } else {
              xi.updateOutputStream(os);
    }
      }
      os.flush();
      if (cache != null && cache.booleanValue() == true) {
                this.dis = dos.getInputStream();
            }
            return dos.getDigestValue();
  } catch (NoSuchAlgorithmException e) {
      throw new XMLSignatureException(e);
  } catch (TransformException e) {
      throw new XMLSignatureException(e);
  } catch (MarshalException e) {
View Full Code Here


      } catch (NoSuchAlgorithmException nsae) {
          throw new XMLSignatureException(nsae);
      }
  }
  md.reset();
  DigesterOutputStream dos;
  Boolean cache = (Boolean)
            context.getProperty("javax.xml.crypto.dsig.cacheReference");
        if (cache != null && cache.booleanValue() == true) {
            this.derefData = copyDerefData(dereferencedData);
            dos = new DigesterOutputStream(md, true);
        } else {
            dos = new DigesterOutputStream(md);
        }
  OutputStream os = new UnsyncBufferedOutputStream(dos);
        Data data = dereferencedData;
        for (int i = 0, size = transforms.size(); i < size; i++) {
      DOMTransform transform = (DOMTransform) transforms.get(i);
      try {
                if (i < size - 1) {
                    data = transform.transform(data, context);
                } else {
                    data = transform.transform(data, context, os);
                }
      } catch (TransformException te) {
    throw new XMLSignatureException(te);
      }
        }
 
  try {
      if (data != null) {
          XMLSignatureInput xi;
          if (data instanceof ApacheData) {
              xi = ((ApacheData) data).getXMLSignatureInput();
          } else if (data instanceof OctetStreamData) {
              xi = new XMLSignatureInput
      (((OctetStreamData)data).getOctetStream());
          } else if (data instanceof NodeSetData) {
        TransformService spi = null;
        try {
            spi = TransformService.getInstance
                (CanonicalizationMethod.INCLUSIVE, "DOM");
        } catch (NoSuchAlgorithmException nsae) {
            spi = TransformService.getInstance
                (CanonicalizationMethod.INCLUSIVE, "DOM", provider);
        }
                    data = spi.transform(data, context);
              xi = new XMLSignatureInput
            (((OctetStreamData)data).getOctetStream());
          } else {
              throw new XMLSignatureException("unrecognized Data type");
          }
          xi.updateOutputStream(os);
      }
      os.flush();
      if (cache != null && cache.booleanValue() == true) {
                this.dis = dos.getInputStream();
            }
            return dos.getDigestValue();
  } catch (Exception e) {
      throw new XMLSignatureException(e);
  }
    }
View Full Code Here

      } catch (NoSuchAlgorithmException nsae) {
          throw new XMLSignatureException(nsae);
      }
  }
  md.reset();
  DigesterOutputStream dos;
  Boolean cache = (Boolean)
            context.getProperty("javax.xml.crypto.dsig.cacheReference");
        if (cache != null && cache.booleanValue() == true) {
            this.derefData = copyDerefData(dereferencedData);
            dos = new DigesterOutputStream(md, true);
        } else {
            dos = new DigesterOutputStream(md);
        }
  OutputStream os = new UnsyncBufferedOutputStream(dos);
        Data data = dereferencedData;
        for (int i = 0, size = transforms.size(); i < size; i++) {
      DOMTransform transform = (DOMTransform) transforms.get(i);
      try {
                if (i < size - 1) {
                    data = transform.transform(data, context);
                } else {
                    data = transform.transform(data, context, os);
                }
      } catch (TransformException te) {
    throw new XMLSignatureException(te);
      }
        }
 
  try {
      if (data != null) {
          XMLSignatureInput xi;
          // explicitly use C14N 1.1 when generating signature
    // first check system property, then context property
    boolean c14n11 = useC14N11;
    String c14nalg = CanonicalizationMethod.INCLUSIVE;
          if (context instanceof XMLSignContext) {
        if (!c14n11) {
                  Boolean prop = (Boolean) context.getProperty
          ("org.apache.xml.security.useC14N11");
            c14n11 = (prop != null && prop.booleanValue() == true);
      if (c14n11) {
                c14nalg = "http://www.w3.org/2006/12/xml-c14n11";
      }
        } else {
            c14nalg = "http://www.w3.org/2006/12/xml-c14n11";
        }
    }
          if (data instanceof ApacheData) {
              xi = ((ApacheData) data).getXMLSignatureInput();
          } else if (data instanceof OctetStreamData) {
              xi = new XMLSignatureInput
      (((OctetStreamData)data).getOctetStream());
          } else if (data instanceof NodeSetData) {
        TransformService spi = null;
        try {
            spi = TransformService.getInstance(c14nalg, "DOM");
        } catch (NoSuchAlgorithmException nsae) {
            spi = TransformService.getInstance
                (c14nalg, "DOM", provider);
        }
                    data = spi.transform(data, context);
              xi = new XMLSignatureInput
            (((OctetStreamData)data).getOctetStream());
          } else {
              throw new XMLSignatureException("unrecognized Data type");
          }
          if (context instanceof XMLSignContext && c14n11
        && !xi.isOctetStream() && !xi.isOutputStreamSet()) {
        DOMTransform t = new DOMTransform
      (TransformService.getInstance(c14nalg, "DOM"));
        Element transformsElem = null;
        String dsPrefix = DOMUtils.getSignaturePrefix(context);
        if (allTransforms.isEmpty()) {
                transformsElem = DOMUtils.createElement(
          refElem.getOwnerDocument(),
          "Transforms", XMLSignature.XMLNS, dsPrefix);
          refElem.insertBefore(transformsElem,
          DOMUtils.getFirstChildElement(refElem));
        } else {
                transformsElem = DOMUtils.getFirstChildElement(refElem);
        }
              t.marshal(transformsElem, dsPrefix, (DOMCryptoContext) context);
        allTransforms.add(t);
              xi.updateOutputStream(os, true);
    } else {
              xi.updateOutputStream(os);
    }
      }
      os.flush();
      if (cache != null && cache.booleanValue() == true) {
                this.dis = dos.getInputStream();
            }
            return dos.getDigestValue();
  } catch (Exception e) {
      throw new XMLSignatureException(e);
  }
    }
View Full Code Here

      } catch (NoSuchAlgorithmException nsae) {
          throw new XMLSignatureException(nsae);
      }
  }
  md.reset();
  DigesterOutputStream dos;
  Boolean cache = (Boolean)
            context.getProperty("javax.xml.crypto.dsig.cacheReference");
        if (cache != null && cache.booleanValue() == true) {
            this.derefData = copyDerefData(dereferencedData);
            dos = new DigesterOutputStream(md, true);
        } else {
            dos = new DigesterOutputStream(md);
        }
  OutputStream os = new UnsyncBufferedOutputStream(dos);
        Data data = dereferencedData;
        for (int i = 0, size = transforms.size(); i < size; i++) {
      DOMTransform transform = (DOMTransform) transforms.get(i);
      try {
                if (i < size - 1) {
                    data = transform.transform(data, context);
                } else {
                    data = transform.transform(data, context, os);
                }
      } catch (TransformException te) {
    throw new XMLSignatureException(te);
      }
        }
 
  try {
      if (data != null) {
          XMLSignatureInput xi;
          if (data instanceof ApacheData) {
              xi = ((ApacheData) data).getXMLSignatureInput();
          } else if (data instanceof OctetStreamData) {
              xi = new XMLSignatureInput
      (((OctetStreamData)data).getOctetStream());
          } else if (data instanceof NodeSetData) {
        TransformService spi = null;
        try {
            spi = TransformService.getInstance
                (CanonicalizationMethod.INCLUSIVE, "DOM");
        } catch (NoSuchAlgorithmException nsae) {
            spi = TransformService.getInstance
                (CanonicalizationMethod.INCLUSIVE, "DOM", provider);
        }
                    data = spi.transform(data, context);
              xi = new XMLSignatureInput
            (((OctetStreamData)data).getOctetStream());
          } else {
              throw new XMLSignatureException("unrecognized Data type");
          }
          xi.updateOutputStream(os);
      }
      os.flush();
      if (cache != null && cache.booleanValue() == true) {
                this.dis = dos.getInputStream();
            }
            return dos.getDigestValue();
  } catch (Exception e) {
      throw new XMLSignatureException(e);
  }
    }
View Full Code Here

            } catch (NoSuchAlgorithmException nsae) {
                throw new XMLSignatureException(nsae);
            }
        }
        md.reset();
        DigesterOutputStream dos;
        Boolean cache = (Boolean)
            context.getProperty("javax.xml.crypto.dsig.cacheReference");
        if (cache != null && cache.booleanValue() == true) {
            this.derefData = copyDerefData(dereferencedData);
            dos = new DigesterOutputStream(md, true);
        } else {
            dos = new DigesterOutputStream(md);
        }
        OutputStream os = new UnsyncBufferedOutputStream(dos);
        Data data = dereferencedData;
        for (int i = 0, size = transforms.size(); i < size; i++) {
            DOMTransform transform = (DOMTransform) transforms.get(i);
            try {
                if (i < size - 1) {
                    data = transform.transform(data, context);
                } else {
                    data = transform.transform(data, context, os);
                }
            } catch (TransformException te) {
                throw new XMLSignatureException(te);
            }
        }

        try {
            if (data != null) {
                XMLSignatureInput xi;
                if (data instanceof ApacheData) {
                    xi = ((ApacheData) data).getXMLSignatureInput();
                } else if (data instanceof OctetStreamData) {
                    xi = new XMLSignatureInput
                        (((OctetStreamData)data).getOctetStream());
                } else if (data instanceof NodeSetData) {
                    TransformService spi = TransformService.getInstance
                        (CanonicalizationMethod.INCLUSIVE, "DOM");
                    data = spi.transform(data, context);
                    xi = new XMLSignatureInput
                        (((OctetStreamData)data).getOctetStream());
                } else {
                    throw new XMLSignatureException("unrecognized Data type");
                }
                xi.updateOutputStream(os);
            }
            os.flush();
            if (cache != null && cache.booleanValue() == true) {
                this.dis = dos.getInputStream();
            }
            return dos.getDigestValue();
        } catch (Exception e) {
            throw new XMLSignatureException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.jcp.xml.dsig.internal.DigesterOutputStream

Copyright © 2018 www.massapicom. 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.