Search in sources :

Example 1 with XMLCanonicalizationAlgorithm

use of permafrost.tundra.xml.XMLCanonicalizationAlgorithm in project Tundra by Permafrost.

the class xml method canonicalize.

// ---( server methods )---
public static final void canonicalize(IData pipeline) throws ServiceException {
    // --- <<IS-START(canonicalize)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] object:0:optional $content
    // [i] field:0:optional $encoding
    // [i] field:0:optional $algorithm {"Canonical XML Version 1.0","Canonical XML Version 1.0 With Comments","Canonical XML Version 1.1","Canonical XML Version 1.1 With Comments","Exclusive Canonical XML Version 1.0","Exclusive Canonical XML Version 1.0 With Comments"}
    // [i] field:0:optional $mode {"stream","bytes","string"}
    // [o] object:0:optional $content.canonical
    IDataCursor cursor = pipeline.getCursor();
    try {
        Object content = IDataHelper.get(cursor, "$content");
        Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
        XMLCanonicalizationAlgorithm algorithm = XMLCanonicalizationAlgorithm.normalize(IDataHelper.get(cursor, "$algorithm", String.class));
        ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
        if (content != null)
            IDataHelper.put(cursor, "$content.canonical", ObjectHelper.convert(XMLCanonicalizationHelper.canonicalize(BytesHelper.normalize(content, charset), charset, algorithm), charset, mode));
    } catch (IOException ex) {
        ExceptionHelper.raise(ex);
    } finally {
        cursor.destroy();
    }
// --- <<IS-END>> ---
}
Also used : XMLCanonicalizationAlgorithm(permafrost.tundra.xml.XMLCanonicalizationAlgorithm) ObjectConvertMode(permafrost.tundra.lang.ObjectConvertMode) Charset(java.nio.charset.Charset) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Charset (java.nio.charset.Charset)1 ObjectConvertMode (permafrost.tundra.lang.ObjectConvertMode)1 XMLCanonicalizationAlgorithm (permafrost.tundra.xml.XMLCanonicalizationAlgorithm)1