Example #1
0
  @Override
  public XMLSignatureInput engineResolveURI(ResourceResolverContext context)
      throws ResourceResolverException {

    final Attr uriAttr = context.attr;
    final String baseUriString = context.baseUri;
    String documentUri = uriAttr.getNodeValue();
    documentUri = decodeUrl(documentUri);
    final DSSDocument document = getDocument(documentUri);
    if (document != null) {

      // The input stream is closed automatically by XMLSignatureInput class

      // TODO-Bob (05/09/2014):  There is an error concerning the input streams base64 encoded. Some
      // extra bytes are added within the santuario which breaks the HASH.
      // TODO-Vin (05/09/2014): Can you create an isolated test-case JIRA DSS-?
      InputStream inputStream = document.openStream();
      //			final byte[] bytes = DSSUtils.toByteArray(inputStream);
      //			final String string = new String(bytes);
      //			inputStream = DSSUtils.toInputStream(bytes);
      final XMLSignatureInput result = new XMLSignatureInput(inputStream);
      result.setSourceURI(documentUri);
      final MimeType mimeType = document.getMimeType();
      if (mimeType != null) {
        result.setMIMEType(mimeType.getMimeTypeString());
      }
      return result;
    } else {

      Object exArgs[] = {"The uriNodeValue " + documentUri + " is not configured for offline work"};
      throw new ResourceResolverException(
          "generic.EmptyMessage", exArgs, documentUri, baseUriString);
    }
  }