DSL API
The encryption and signature standards proposed by W3C specifying the format for encrypted XML documents are important advances towards XML security. Related works include the proposal of a specification language that allows a programmer to describe the security details of XML documents. Despite the success of these works, we consider them to be insufficient from the viewpoint of software engineering. In this paper, we employ some real examples to demonstrate that it is necessary to design an appropriate API for the securing system of subtree encryption for XML documents. The goal is to increase productivity and reduce the cost of maintaining this kind of software, for which we propose a document security language (DSL) API. We describe the implementation of the DSL API, and use experimental results to demonstrate its practicality. Click for DSL API document.

Encrypting XML with DSL and encrypting XML using DSL API

Using a securing application implemented in the DSL API to encrypt multiple XML documents that have the same structure produced by the same key

Using a securing application implemented in the DSL API to encrypt an XML document with different keys
Example:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import iclab.ntnu.dsl.*; public class DSLSample1{ public static void main(String[] args) { DSLTransform df = new DSLTransform(); df.turnOnMessage(); try{ boolean b1 =df.securingDOC("exl.xml", "ex1.dsl", "ex1-encrypted.xml", "ex1-decrypt.dsl"); if (b1 == false) System.out.println(df.getErrorCode()+":"+df.getErrorCause()); } catch(Exception e){ e.printStackTrace(); } } } |
Loading XML and DSL files, then encrypting the XML file
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import iclab.ntnu.dsl.*; public class DSLSample2{ public static void main(String[] args) { DSLTransform df = new DSLTransform(); df.turnOnMessage(); df.loadDsl(“example.dsl”); try{ for (int i=0;i<10;i++){ String xml_file = "trans_ex_"+Integer.toString(i)+".xml"; String enc_xml_file = "trans_ex_"+Integer.toString(i)+"_encrypted.xml"; boolean b1 =df.securingDOC(xml_file,enc_xml_file); if (b1 == false) System.out.println(df.getErrorCode()+":"+df.getErrorCause()); } } catch(Exception e){ e.printStackTrace(); } } } |
Encrypting multiple XML files with a single DSL document
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import iclab.ntnu.dsl.*; public class DSLSample3{ public static void main(String[] args) { DSLTransform df = new DSLTransform(); df.turnOnMessage(); df.loadDsl(“example.dsl”); String xml_file = "trans_ex_1"; try{ for (int i=0;i<10;i++){ String enc_xml_file= = "trans_ex_"+Integer.toString(i)+"_encrypted.xml"; String keyName="tkchang_"+Integer.toString(i)+ ".pub"; df.removeKey(“tkchang”); df.addKey("tkchang",keyName,"RSA","E:\\DSLT\\keymanager"); boolean b1 =df.securingDOC(xml_file,enc_xml_file); if (b1 == false) System.out.println(df.getErrorCode()+":"+df.getErrorCause()); } } catch(Exception e){ e.printStackTrace(); } } } |
Using one DSL document to encrypt multiple XML documents with different keys
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import iclab.ntnu.dsl.*; import org.w3c.dom.Node; public class DSLSample4{ public static void main(String[] args) { XMLCreater oXML = new XMLCreater("E:\DSLT\salary.xml"); Node resultXML = oXML.computSalary(); DSLTransform df = new DSLTransform(); df.turnOnMessage(); df.loadDsl(“example.dsl”); try{ Node encryptNode =df.securingDOC(resultXML); } catch(Exception e){ e.printStackTrace(); } } } |
Encrypting an XML node and returning an XML node
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import iclab.ntnu.dsl.*; public class DSLSample5{ public static void main(String[] args) { DSLTransform df = new DSLTransform(); df.turnOnMessage(); df.loadDsl("example.dsl"); try{ boolean b1 =df.securingDOC("example.xml","example-encrypted.xml"); if (b1 == false) System.out.println(df.getErrorCode()+":"+df.getErrorCause()); Vector ve1 = df.getErrorVector(); System.out.println("ve1="+ve1.size()); for (int i=0; i < ve1.size(); i++) { DSLError dslerr = (DSLError)ve1.elementAt(i); System.out.println("dslerr="+dslerr.getErrorCode()+" "+dslerr.getErrorCause()+" "+dslerr.getErrorMessage()); } } catch(Exception e){ e.printStackTrace(); } } } |
Coping with error messages