Yes, you have not registered an XMLSignatureFactory provider implementation.

The easiest workaround is to just instantiate and specify the service provider implementation (bundled with Apache XMLSec) as a parameter as follows:

XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM", new org.jcp.xml.dsig.internal.dom.XMLDSigRI());

Alternatively, you can register the provider in the java.security file, or use the java.security.Provider API. See http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#ProviderInstalling
"Registering a Provider" for more details.

--Sean

Nayan Hajratwala wrote:
I'm trying to validate a signature using xmlsec 1.4.1 and am getting the following error:

javax.xml.crypto.NoSuchMechanismException: Mechanism type DOM not available
at javax.xml.crypto.dsig.XMLDSigSecurity.getEngineClassName(Unknown Source)
    at javax.xml.crypto.dsig.XMLDSigSecurity.getImpl(Unknown Source)
    at javax.xml.crypto.dsig.XMLDSigSecurity.getImpl(Unknown Source)
    at javax.xml.crypto.dsig.XMLSignatureFactory.findInstance

...

The code is:

NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
            if (nl.getLength() == 0) {
              throw new Exception("Cannot find Signature element");
            }
DOMValidateContext valContext = new DOMValidateContext(pk, nl.item(0)); XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");

...

Any ideas?


---
Nayan Hajratwala
http://agileshrugged.com
http://chikli.com
734.658.6032





Reply via email to