Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove the ambiguous function call

Please help me to solve the ambiguous call in this code.

fac.newtransform() and fac.new signedinfo() is giving error saying:

reference to newTransform is ambiguous, both method newTransform(String,TransformParameterSpec) in XMLSignatureFactory and method newTransform(String,XMLStructure) in XMLSignatureFactory match

How can I call the actual function in XMLSignatureFactory?

   XMLSignatureFactory fac =XMLSignatureFactory.getInstance("DOM",
                (Provider) Class.forName(providerName).newInstance());

   Reference ref =fac.newReference("",fac.newDigestMethod(DigestMethod.SHA1, null),
    Collections.singletonList(fac.newTransform(Transform.ENVELOPED, null)),null, null);


   SignedInfo si = fac.newSignedInfo
       (fac.newCanonicalizationMethod
         (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS, 
             null), 
        fac.newSignatureMethod(SignatureMethod.DSA_SHA1, 
            null),
        Collections.singletonList(ref));
like image 625
thejus_r Avatar asked Jun 08 '26 11:06

thejus_r


1 Answers

You must cast the second argument:

newTransform("foo", (XMLStructure) null)

You are getting the ambiguous warning because null is a valid argument to both methods. You need to add the (XMLStructure) cast to tell the compiler the type of the object you are setting to null..

like image 107
Duncan Jones Avatar answered Jun 10 '26 09:06

Duncan Jones