Search in sources :

Example 1 with InvalidTransformException

use of org.apache.xml.security.transforms.InvalidTransformException in project santuario-java by apache.

the class Reference method getHTMLRepresentation.

/**
 * Method getHTMLRepresentation
 * @return The HTML of the transformation
 * @throws XMLSignatureException
 */
public String getHTMLRepresentation() throws XMLSignatureException {
    try {
        XMLSignatureInput nodes = this.getNodesetBeforeFirstCanonicalization();
        Transforms transforms = this.getTransforms();
        Transform c14nTransform = null;
        if (transforms != null) {
            for (int i = 0; i < transforms.getLength(); i++) {
                Transform t = transforms.item(i);
                String uri = t.getURI();
                if (uri.equals(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS) || uri.equals(Transforms.TRANSFORM_C14N_EXCL_WITH_COMMENTS)) {
                    c14nTransform = t;
                    break;
                }
            }
        }
        Set<String> inclusiveNamespaces = new HashSet<>();
        if (c14nTransform != null && c14nTransform.length(InclusiveNamespaces.ExclusiveCanonicalizationNamespace, InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES) == 1) {
            // there is one InclusiveNamespaces element
            InclusiveNamespaces in = new InclusiveNamespaces(XMLUtils.selectNode(c14nTransform.getElement().getFirstChild(), InclusiveNamespaces.ExclusiveCanonicalizationNamespace, InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES, 0), this.getBaseURI());
            inclusiveNamespaces = InclusiveNamespaces.prefixStr2Set(in.getInclusiveNamespaces());
        }
        return nodes.getHTMLRepresentation(inclusiveNamespaces);
    } catch (TransformationException ex) {
        throw new XMLSignatureException(ex);
    } catch (InvalidTransformException ex) {
        throw new XMLSignatureException(ex);
    } catch (XMLSecurityException ex) {
        throw new XMLSignatureException(ex);
    }
}
Also used : InvalidTransformException(org.apache.xml.security.transforms.InvalidTransformException) TransformationException(org.apache.xml.security.transforms.TransformationException) Transforms(org.apache.xml.security.transforms.Transforms) InclusiveNamespaces(org.apache.xml.security.transforms.params.InclusiveNamespaces) Transform(org.apache.xml.security.transforms.Transform) XMLSecurityException(org.apache.xml.security.exceptions.XMLSecurityException) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 XMLSecurityException (org.apache.xml.security.exceptions.XMLSecurityException)1 InvalidTransformException (org.apache.xml.security.transforms.InvalidTransformException)1 Transform (org.apache.xml.security.transforms.Transform)1 TransformationException (org.apache.xml.security.transforms.TransformationException)1 Transforms (org.apache.xml.security.transforms.Transforms)1 InclusiveNamespaces (org.apache.xml.security.transforms.params.InclusiveNamespaces)1