How to build, install and test the XML Security component in OpenOffice

System requirement

Following C package should be installed in your system
1) iconv-1.8
2) libxml2-2.5.7
3) libxslt-1.0.30
4) nspr-4.3
5) nss-3.8
6) xmlsec (for nss)

Following java packages should be installed in your system
1) junit3.7.jar
2) xercesImpl.jar
3) xmldsig.jar
4) commons-logging-api.jar
5) log4j-1.2.5.jar
6) xml-apis.jar
7) xmlsec.jar
8) commons-logging.jar
9) xalan.jar
10) xmlParserAPIs.jar


Before building

1) Copy some jsr related packages into the /external/common directory, these package will be used when building the xmlsecurity project. These packages include:

        xalan.jar
        xmldsig.jar
        xmlsec.jar
        
it is all right for the package name to be different from above, such as a name along with version number, because environment variable setting in the next step can point out the correct file names.

2) Following environment variables need to be configured, including:

	ICONVINC       -- the header file directory for iconv library
	LIBXML2INC     -- the header file directory for libxml2 library
	LIBXSLTINC     -- the header file directory for libxslt library
	XMLSECINC      -- the header file directory for xmlsec(for nss) library
	NSPRINC        -- the header file directory for nspr library
	NSSINC         -- the header file directory for nss library
	
	LIBXML2LIB     -- the static library file for libxml2 library
	LIBXSLTLIB     -- the static library file for libxslt library
	LIBEXSLTLIB    -- the static library file for libexslt library
	XMLSECLIB      -- the static library file for xmlsec(for nss) library
	XMLSECCRYLIB   -- the static library file for xmlsec crypto library
	NSPRLIB        -- the static library file for nspr library
	NSSLIB         -- the static library file for nss library
	
	XALAN_JAR      -- the file name for xalan java library
	XMLDSIG_JAR    -- the file name for xmldsig java library
	XMLSEC_JAR     -- the file name for xmlsec java library

Here is an batch example under Windows which setup all above environment variables

	set ICONVINC=D:\Libs\iconv-1.8\include
	set LIBXML2INC=D:\Libs\libxml2-2.5.7\include
	set LIBXSLTINC=D:\Libs\libxslt-1.0.30\include
	set XMLSECINC=D:\Libs\xmlsec-nss\include
	set NSPRINC=D:\Libs\nspr-4.3\include
	set NSSINC=D:\Libs\nss-3.8\include
	
	set LIBXML2LIB=D:\Libs\libxml2-2.5.7\lib\libxml2.lib
	set LIBXSLTLIB=D:\Libs\libxslt-1.0.30\lib\libxslt.lib
	set LIBEXSLTLIB=D:\Libs\libxslt-1.0.30\lib\libexslt.lib
	set XMLSECLIB=D:\Libs\xmlsec-nss\lib\libxmlsec.lib
	set XMLSECCRYLIB=D:\Libs\xmlsec-nss\lib\libxmlsec-nss.lib
	set NSPRLIB=D:\Libs\nspr-4.3\lib\nspr4.lib
	set NSSLIB=D:\Libs\nss-3.8\lib\nss3.lib
	
	set XALAN_JAR=xalan.jar
	set XMLDSIG_JAR=xmldsig.jar
	set XMLSEC_JAR=xmlsec.jar


Now you can begin to build you workspace.

...

Before installation

1) You need to make sure that dynamic libraries of all those C packages are included in the system path, otherwise, the installation process will prompt error when registering the xmlsec bridge component.

Now you can install your OpenOffice from the instsetoo project.

After installation

1) You need to modify the java.ini file after installation, add all jave packages into the SystemClasspath variable.

2) You need to copy both Java and C crypto token files to the <OpenOffice>/program folder, they are xmlsecurity/tools/cryptoken/jks and xmlsecurity/tools/cryptoken/nss. Both files are used as key material.

Now you can load and save writer document with signature stream.

...

Running OpenOffice

1) When you save a writer document, a dialog shows up. This dialog includes three catagories.
   1. component selection: you can select JSR105-based component(Java) or xml security library based componenent(C++) to do the signing job.
   2. create signature on: you can select whether or not to create signature on the whole document, all text section element, and each text section element respectively.
   3. xml security framework options: you can choose whether the xml security framework is dynamically chained in/off the SAX chain. To use this dynamic feature, uncheck the "stick the SAXEventKeeper to the SAX chain" option; otherwise, the SAXEventKeeper will keep on the SAX chain during the saving process. (When you use Java component, you can see a big time difference between using this feature or not.)
   
2) When you load a writer document, a dialog similar with the above one show up. The catagory 2 is disabled, other catagories have the same functions.