com.mindbright.ssh2
public final class SSH2UserAuth extends java.lang.Object
SSH2Transport
and uses a SSH2Authenticator
which
contains the user's name and a list of one or more authentication methods
(each coupled to a SSH2AuthModule
instance) to try to
authenticate the user.
To create a SSH2UserAuth
instance a connected
SSH2Transport
and a SSH2Authenticator
must be
created first to be passed to the constructor. The constructor is passive in
that it doesn't start any communication. To start the authentication process
the method authenticateUser
must be called. This method blocks
(the authentication process is run in the calling thread) until either the
user is authenticated or authentication fails.
While the authentication process runs events are reported through callbacks
to the SSH2Authenticator
. Each SSH2AuthModule
instance (one active at a time) handles the actual processing and formatting
of the packets specific to the authentication method it represents.
SSH2Transport
,
SSH2Authenticator
,
SSH2AuthModule
Constructor and Description |
---|
SSH2UserAuth(SSH2Transport transport,
SSH2Authenticator authenticator)
This is the constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
authenticateUser(java.lang.String service)
Authenticates the user represented by the authenticator to run the given
service (currently "ssh-connection" is the only defined service).
|
boolean |
authenticateUser(java.lang.String service,
long timeout) |
SSH2TransportPDU |
createUserAuthRequest(java.lang.String method)
Creates a packet of type USERAUTH_REQUEST (as defined in the userauth
protocol spec.).
|
SSH2Authenticator |
getAuthenticator()
Gets our authenticator.
|
SSH2Transport |
getTransport()
Gets our transport layer.
|
boolean |
isAuthenticated()
Checks if the user represented by the
SSH2Authenticator we
process has been authenticated yet. |
boolean |
isCanceled()
Checks if the user represented by the
SSH2Authenticator we
process has been canceling the authentication process. |
void |
terminate()
Terminates the authentication process.
|
public SSH2UserAuth(SSH2Transport transport, SSH2Authenticator authenticator)
SSH2Authenticator
which contains the user to authenticate
and provides a list of the authentication methods to try. It is also used
to report authentication events.transport
- the transport layerauthenticator
- the authenticator containing authentication info for
the user it represents.public SSH2Transport getTransport()
public SSH2Authenticator getAuthenticator()
public boolean authenticateUser(java.lang.String service)
service
- the service to requestpublic boolean authenticateUser(java.lang.String service, long timeout)
public SSH2TransportPDU createUserAuthRequest(java.lang.String method)
SSH2AuthModule
implementors to create the
packet to return from the method startAuthentication
.method
- the name of the authentication methodpublic void terminate()
public boolean isAuthenticated()
SSH2Authenticator
we
process has been authenticated yet.public boolean isCanceled()
SSH2Authenticator
we
process has been canceling the authentication process.