Example usage for javax.xml.crypto URIReferenceException URIReferenceException

List of usage examples for javax.xml.crypto URIReferenceException URIReferenceException

Introduction

In this page you can find the example usage for javax.xml.crypto URIReferenceException URIReferenceException.

Prototype

public URIReferenceException(String message, Throwable cause) 

Source Link

Document

Constructs a new URIReferenceException with the specified detail message and cause.

Usage

From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLURIDereferencer.java

public Data dereference(URIReference uriReference, XMLCryptoContext context) throws URIReferenceException {
    if (null == uriReference) {
        throw new NullPointerException("URIReference cannot be null");
    }//from   www. j a  va  2s .  c  o  m
    if (null == context) {
        throw new NullPointerException("XMLCrytoContext cannot be null");
    }

    String uri = uriReference.getURI();
    try {
        uri = URLDecoder.decode(uri, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        LOG.warn("could not URL decode the uri: " + uri);
    }
    LOG.debug("dereference: " + uri);
    try {
        InputStream dataInputStream = findDataInputStream(uri);
        if (null == dataInputStream) {
            LOG.debug("cannot resolve, delegating to base DOM URI dereferencer: " + uri);
            return this.baseUriDereferencer.dereference(uriReference, context);
        }
        return new OctetStreamData(dataInputStream, uri, null);
    } catch (IOException e) {
        throw new URIReferenceException("I/O error: " + e.getMessage(), e);
    }
}

From source file:be.fedict.eid.applet.service.signer.odf.ODFURIDereferencer.java

public Data dereference(URIReference uriReference, XMLCryptoContext context) throws URIReferenceException {
    if (null == uriReference) {
        throw new NullPointerException("URIReference cannot be null");
    }/*from   www.j a  v  a  2  s.c  o  m*/
    if (null == context) {
        throw new NullPointerException("XMLCrytoContext cannot be null");
    }

    String uri = uriReference.getURI();
    try {
        uri = URLDecoder.decode(uri, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        LOG.warn("could not URL decode the uri: " + uri);
    }
    LOG.debug("dereference: " + uri);
    try {
        InputStream dataInputStream = findDataInputStream(uri);
        if (null == dataInputStream) {
            LOG.debug("cannot resolve, delegating to base DOM URI dereferener: " + uri);
            return this.baseUriDereferener.dereference(uriReference, context);
        }
        if (uri.endsWith(".xml")) {
            /*
             * We parse the XML ourselves as we might need to resolve MathML
             * DTD.
             */
            byte[] data = IOUtils.toByteArray(dataInputStream);
            if (0 == data.length) {
                return new OctetStreamData(dataInputStream, uri, null);
            }
            Document document = documentBuilder.parse(new ByteArrayInputStream(data));
            XMLSignatureInput xmlSignatureInput = new XMLSignatureInput(document);
            ApacheNodeSetData apacheNodeSetData = new ApacheNodeSetData(xmlSignatureInput);
            return apacheNodeSetData;
        }
        return new OctetStreamData(dataInputStream, uri, null);
    } catch (IOException e) {
        throw new URIReferenceException("I/O error: " + e.getMessage(), e);
    } catch (SAXException e) {
        throw new URIReferenceException("SAX error: " + e.getMessage(), e);
    }
}