@Test
public void testStreamSignatureVerification() throws Exception
{

    ByteArrayInputStream bais = new ByteArrayInputStream(text);
    Signer signer = factory.getInstance(true, privateKey);
    InputStream input = signer.getInputStream(bais);
    byte[] buf = new byte[text.length];
    assertThat(readAll(input, buf), equalTo(text.length));
    assertThat(buf, equalTo(text));
    byte[] signature = signer.generate();
    Signer verifier = factory.getInstance(false, publicKey);
    OutputStream output = verifier.getOutputStream();
    output.write(text);
    assertTrue(verifier.verify(signature));
}