public boolean matches(Object arg)
{
UserAuthRequestMessage msg = (UserAuthRequestMessage)arg;
assertTrue(msg.getAuthenticationData() instanceof PublicKeyMethodData);
assertEquals("publickey", msg.getMethod());
PublicKeyMethodData md = (PublicKeyMethodData)msg.getAuthenticationData();
assertEquals("ssh-rsa", md.getAlgorithm());
assertArrayEquals(pkey.encode(), md.getPubkey());
assertNotNull(md.getSignature());
try {
Signature verify = Signature.getInstance("SHA1withRSA");
verify.initVerify(publickey);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Utils.encodeBytes(out, new byte[20]);
out.write((byte)50);
Utils.encodeString(out, "user");
Utils.encodeString(out, "ssh-connection");
Utils.encodeString(out, "publickey");
Utils.encodeBoolean(out, true);
Utils.encodeString(out, "ssh-rsa");
Utils.encodeBytes(out, pkey.encode());
verify.update(out.toByteArray());
assertTrue("Signature should be verified", verify.verify(md.getSignature()));
} catch (InvalidKeyException ike) {
fail(ike.getMessage());
} catch (NoSuchAlgorithmException nsae) {
fail(nsae.getMessage());
} catch (IOException ioe) {