Package net.schmizz.sshj.userauth.method
Class AbstractAuthMethod
- java.lang.Object
-
- net.schmizz.sshj.userauth.method.AbstractAuthMethod
-
- All Implemented Interfaces:
SSHPacketHandler
,AuthMethod
- Direct Known Subclasses:
AuthGssApiWithMic
,AuthKeyboardInteractive
,AuthNone
,AuthPassword
,KeyedAuthMethod
public abstract class AbstractAuthMethod extends java.lang.Object implements AuthMethod
This abstract class forAuthMethod
implements common or default functionality.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
log
Loggerprotected AuthParams
params
AuthParams
useful for building request.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractAuthMethod(java.lang.String name)
-
Method Summary
Modifier and Type Method Description protected SSHPacket
buildReq()
Builds aSSHPacket
containing the fields common to all authentication method.java.lang.String
getName()
void
handle(Message msg, SSHPacket buf)
Delegate handling of some SSH packet to this object.void
init(AuthParams params)
This method must be called before requesting authentication with this method.protected AccountResource
makeAccountResource()
void
request()
void
setLoggerFactory(LoggerFactory loggerFactory)
boolean
shouldRetry()
-
-
-
Field Detail
-
log
protected org.slf4j.Logger log
Logger
-
params
protected AuthParams params
AuthParams
useful for building request.
-
-
Method Detail
-
setLoggerFactory
public void setLoggerFactory(LoggerFactory loggerFactory)
- Specified by:
setLoggerFactory
in interfaceAuthMethod
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceAuthMethod
- Returns:
- assigned name of this authentication method
-
handle
public void handle(Message msg, SSHPacket buf) throws UserAuthException, TransportException
Description copied from interface:SSHPacketHandler
Delegate handling of some SSH packet to this object.- Specified by:
handle
in interfaceSSHPacketHandler
- Parameters:
msg
- the SSHmessage identifier
buf
-SSHPacket
containing rest of the request- Throws:
UserAuthException
TransportException
-
init
public void init(AuthParams params)
Description copied from interface:AuthMethod
This method must be called before requesting authentication with this method.- Specified by:
init
in interfaceAuthMethod
- Parameters:
params
- parameters needed for authentication
-
request
public void request() throws UserAuthException, TransportException
- Specified by:
request
in interfaceAuthMethod
- Throws:
UserAuthException
- if there is an error with the requestTransportException
- if there is a transport-related error
-
shouldRetry
public boolean shouldRetry()
- Specified by:
shouldRetry
in interfaceAuthMethod
- Returns:
- whether authentication should be reattempted if it failed.
-
buildReq
protected SSHPacket buildReq() throws UserAuthException
Builds aSSHPacket
containing the fields common to all authentication method. Method-specific fields can further be put into this buffer.- Throws:
UserAuthException
-
makeAccountResource
protected AccountResource makeAccountResource()
-
-