xml - Soap Signing in Clojure -
i working api requires soap calls signed. have looked documentation java on how sign soap calls using programming java xml digital signature api.
i consistently running following error java.lang.illegalargumentexception: no matching method found: newcanonicalizationmethod class org.jcp.xml.dsig.internal.dom.domxmlsignaturefactory.
i know issue sending parameters newcanonocalizationmethod. following flow per java, still running issue.
here code.
(let [fac (xmlsignaturefactory/getinstance "dom") dm (doto (.. fac (newdigestmethod (digestmethod/sha1) nil))) bk "" ref (.. fac (newreference bk dm)) cm (canonicalizationmethod/inclusive) c14 c14nmethodparameterspec in (.. fac (newcanonicalizationmethod cm c14))]) here full function code: have started process of creating signature section per site: http://www.oracle.com/technetwork/articles/javase/dig-signature-api-140772.html
(defn create-signature [] (let [fac (xmlsignaturefactory/getinstance "dom") dm (doto (.. fac (newdigestmethod (digestmethod/sha1) nil))) bk "" ref (.. fac (newreference bk dm)) cm canonicalizationmethod/inclusive c14 c14nmethodparameterspec si (.. fac (newsignedinfo (.. fac (newcanonicalizationmethod cm c14nmethodparameterspec)) (.. fac (newsignaturemethod (signaturemethod/rsa_sha1) nil)) (.. java.util.collections (singletonlist ref)))) ] )) if run reflect on factory, response:
{:name newcanonicalizationmethod, :return-type javax.xml.crypto.dsig.canonicalizationmethod, :declaring-class org.jcp.xml.dsig.internal.dom.domxmlsignaturefactory, :parameter-types [java.lang.string javax.xml.crypto.dsig.spec.c14nmethodparameterspec], :exception-types [java.security.nosuchalgorithmexception java.security.invalidalgorithmparameterexception], :flags #{:public}}
the solution issue generate of java methods in custom java class. issue java method looking type of parameter. code says generate using (java type)null, doesn't compile in clojure.
i using website generate xml signing link.
after creating custom class, compiled , imported clojure project.
lesson learned: when working java classes, best use pure java instead of java interop.
Comments
Post a Comment