0

I'm trying to do the canonicalization part of XML. However, I don't know how to connect to Apache.

I have download the package: http://www.apache.org/dyn/closer.lua/santuario/java-library/2_0_8/xmlsec-2.0.8-source-release.zip But adding it to the project doesn't work. How do I do that?

This is not working:

public byte[] canonicalize(byte[] data) throws Exception {
    byte[] result = null;
    try {
        org.apache.xml.security.Init.init();
        Canonicalizer c14n = Canonicalizer.getInstance("http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
        result = c14n.canonicalize(data);
    } catch (Exception e) {
        System.out.println("False");
    }
    return result;
}

My Settings:

my settings

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Mafika
  • 21
  • 1
  • 7
  • 1
    Can you explain what 'This is not working' means? Do you get a compile error? A runtime Exception? Please post any messages/stack trace you are receiving. – bradimus Feb 03 '17 at 14:09
  • Just eclipse doesn't see "org.apache.xml.security.Init.init()" and "Canonicalizer" class. I don't know where i have to add package apache. – Mafika Feb 03 '17 at 14:25

1 Answers1

0

The library is only available as a "source" release, which means you will have to build it yourself.

If you check its contents, you will notice a pom.xml file, which means its build process is handled by Maven. Install the tool if you don't already have it, and build the project with the command mvn install from inside the library directory.

Once you've done that, you will be able either to use the .jar file produced in the process, or reference the library as a maven dependency.

Panda
  • 6,955
  • 6
  • 40
  • 55
Aaron
  • 24,009
  • 2
  • 33
  • 57
  • Sorry, I wrote a bad link. I have library to Java. – Mafika Feb 03 '17 at 13:58
  • I've never done maven's project. Is it possible to do canonicalization in a different way? – Mafika Feb 03 '17 at 14:22
  • @Mafika looks like you could use [XOM](http://www.xom.nu/) instead of Apache Santuario. It does have a binary release. – Aaron Feb 03 '17 at 14:35
  • @Mafika also, I see you're using Eclipse. Using the eclipse-mvn plugin can make the experience of a maven build much less painful (install the plugin, left-clic the source project, maven->mvn install) – Aaron Feb 03 '17 at 15:02
  • Yes, I used Eclipse, but now I will use IntelliJ. – Mafika Feb 03 '17 at 16:03