You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Andrew Cagney <ca...@fixmo.com> on 2012/12/20 18:53:18 UTC

How can a server service know auth completed

Hi,

I'm trying to use MINA/SSH to set up a channel between two services; for
the moment I'm focused on service running on the ssh-server end.

Looking at the code, I can't find any sort of mechanism to notify my code
that the session's been authenticated and things can proceed.  Yes, I could
wait until the client side sent a message but I don't want to :-)

As a hack I implemented my own ServerSession and then poked around in the
message buffer thus:

public class ServiceServerSession extends ServerSession {

@Override
    public WriteFuture writePacket(Buffer buffer) throws IOException {
        byte[] bytes = buffer.array();
        boolean sshMsgUserAuthSuccess = bytes.length > 5 && bytes[5] ==
SshConstants.Message.SSH_MSG_USERAUTH_SUCCESS.toByte();
        WriteFuture writeFuture = super.writePacket(buffer);
        if (sshMsgUserAuthSuccess) {
            log.debug("Hey dude just saw the auth-success packet, can start
up some extra services!"); // TODO:
        }
        return writeFuture;
    }
which suggests a way forward (although I'm sure this isn't legit :-).

(As an aside, I noticed that the ServerSession doesn't have hooks for
anything other than ssh-session).