@@ -0,0 +1,2119 @@
+package org.apache.xml.security.test.signature;%0D%0A%0D%0Aimport java.io.FileInputStream;%0D%0Aimport java.security.KeyStore;%0D%0Aimport java.security.PublicKey;%0D%0A%0D%0Aimport javax.xml.parsers.DocumentBuilderFactory;%0D%0A%0D%0Aimport org.apache.xml.security.Init;%0D%0Aimport org.apache.xml.security.signature.XMLSignature;%0D%0Aimport org.w3c.dom.Document;%0D%0Aimport org.w3c.dom.Element;%0D%0Aimport org.w3c.dom.NodeList;%0D%0A%0D%0Aimport junit.framework.TestCase;%0D%0A%0D%0A/**%0D%0A * Test case contributed by Matthias Germann for testing that bug 43239 is%0D%0A * fixed: %22No installed provider supports this key%22 when checking a RSA %0D%0A * signature against a DSA key before RSA key.%0D%0A */%0D%0Apublic class InvalidKeyTest extends TestCase %7B%0D%0A%0D%0A    static %7B%0D%0A%09Init.init();%0D%0A    %7D%0D%0A%0D%0A    private static final String BASEDIR = System.getProperty(%22basedir%22);%0D%0A    private static final String SEP = System.getProperty(%22file.separator%22);%0D%0A%0D%0A    public void test() throws Exception %7B%0D%0A%09FileInputStream input = new FileInputStream(BASEDIR + SEP + %0D%0A%09    %22data/org/apache/xml/security/samples/input/truststore.jks%22);%0D%0A        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());%0D%0A        trustStore.load(input, %22testpw%22.toCharArray());%0D%0A        %0D%0A%09try %7B%0D%0A            validate(trustStore.getCertificate(%22bedag-test%22).getPublicKey());%0D%0A%09%7D catch (Exception e) %7B%0D%0A%09    e.printStackTrace();%0D%0A%09%7D%0D%0A        validate(trustStore.getCertificate(%22a70-garaio-frontend-u%22).getPublicKey());%0D%0A    %7D%0D%0A    %0D%0A    public void validate(PublicKey pk) throws Exception %7B%0D%0A        FileInputStream is = new FileInputStream(BASEDIR + SEP +%0D%0A%09    %22data/org/apache/xml/security/samples/input/test-assertion.xml%22);%0D%0A            %0D%0A        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();%0D%0A        dbf.setNamespaceAware(true);%0D%0A        Document e = dbf.newDocumentBuilder().parse(is);%0D%0A            %0D%0A        NodeList nl = e.getFirstChild().getChildNodes();%0D%0A        Element n = (Element)nl.item(nl.getLength()-1);%0D%0A            %0D%0A        XMLSignature si = new XMLSignature((Element)n,%22%22);%0D%0A        si.checkSignatureValue(pk);%0D%0A%0D%0A       %09System.out.println(%22VALIDATION OK%22 );%0D%0A    %7D%0D%0A%7D%0D%0A

Test case for bug 43239: "No installed provider supports this key" when checking a RSA signature against a DSA key before RSA key.