Ejemplo n.º 1
0
  public boolean verify(DigestCalculatorProvider calculatorProvider) throws CMSException {
    try {
      ContentInfo content = digestedData.getEncapContentInfo();
      DigestCalculator calc = calculatorProvider.get(digestedData.getDigestAlgorithm());

      OutputStream dOut = calc.getOutputStream();

      dOut.write(((ASN1OctetString) content.getContent()).getOctets());

      return Arrays.areEqual(digestedData.getDigest(), calc.getDigest());
    } catch (OperatorCreationException e) {
      throw new CMSException("unable to create digest calculator: " + e.getMessage(), e);
    } catch (IOException e) {
      throw new CMSException("unable process content: " + e.getMessage(), e);
    }
  }
Ejemplo n.º 2
0
  /**
   * Return the digested content
   *
   * @return the digested content
   * @throws CMSException if there is an exception un-compressing the data.
   */
  public CMSProcessable getDigestedContent() throws CMSException {
    ContentInfo content = digestedData.getEncapContentInfo();

    try {
      return new CMSProcessableByteArray(
          content.getContentType(), ((ASN1OctetString) content.getContent()).getOctets());
    } catch (Exception e) {
      throw new CMSException("exception reading digested stream.", e);
    }
  }
Ejemplo n.º 3
0
  public CMSDigestedData(ContentInfo contentInfo) throws CMSException {
    this.contentInfo = contentInfo;

    try {
      this.digestedData = DigestedData.getInstance(contentInfo.getContent());
    } catch (ClassCastException e) {
      throw new CMSException("Malformed content.", e);
    } catch (IllegalArgumentException e) {
      throw new CMSException("Malformed content.", e);
    }
  }
Ejemplo n.º 4
0
 public AlgorithmIdentifier getDigestAlgorithm() {
   return digestedData.getDigestAlgorithm();
 }