@Override
public SSHMessage interact(SSHMessage lastMessage) throws SSHException
{
if (lastMessage == null) {
UserAuthRequestMessage msg = initUserAuthRequestMessage();
PublicKeyMethodData md = new PublicKeyMethodData(key.getName(), key.encode());
msg.setAuthenticationData(md);
return msg;
} else if (lastMessage.getID() == UserAuthPublicKeyOk.ID) {
UserAuthRequestMessage msg = initUserAuthRequestMessage();
PublicKeyMethodData md = new PublicKeyMethodData(key.getName(), key.encode());
md.prepareTBS();
msg.setAuthenticationData(md);
byte[] sig = null;
try {
signer.update(Utils.encodeBytes(transport.getSessionId()));
signer.update(msg.getEncoding());
sig = signer.sign();
} catch (SignatureException e) {
throw new SSHException("Signature failed", e);
}
md = new PublicKeyMethodData(key.getName(), key.encode());
md.setSignature(sig);
msg.setAuthenticationData(md);
return msg;
}
throw new UnsupportedOperationException("Not supported yet.");
}