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 forAuthMethodimplements common or default functionality.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.LoggerlogLoggerprotected AuthParamsparamsAuthParamsuseful for building request.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAuthMethod(java.lang.String name)
-
Method Summary
Modifier and Type Method Description protected SSHPacketbuildReq()Builds aSSHPacketcontaining the fields common to all authentication method.java.lang.StringgetName()voidhandle(Message msg, SSHPacket buf)Delegate handling of some SSH packet to this object.voidinit(AuthParams params)This method must be called before requesting authentication with this method.protected AccountResourcemakeAccountResource()voidrequest()voidsetLoggerFactory(LoggerFactory loggerFactory)booleanshouldRetry()
-
-
-
Field Detail
-
log
protected org.slf4j.Logger log
Logger
-
params
protected AuthParams params
AuthParamsuseful for building request.
-
-
Method Detail
-
setLoggerFactory
public void setLoggerFactory(LoggerFactory loggerFactory)
- Specified by:
setLoggerFactoryin interfaceAuthMethod
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceAuthMethod- Returns:
- assigned name of this authentication method
-
handle
public void handle(Message msg, SSHPacket buf) throws UserAuthException, TransportException
Description copied from interface:SSHPacketHandlerDelegate handling of some SSH packet to this object.- Specified by:
handlein interfaceSSHPacketHandler- Parameters:
msg- the SSHmessage identifierbuf-SSHPacketcontaining rest of the request- Throws:
UserAuthExceptionTransportException
-
init
public void init(AuthParams params)
Description copied from interface:AuthMethodThis method must be called before requesting authentication with this method.- Specified by:
initin interfaceAuthMethod- Parameters:
params- parameters needed for authentication
-
request
public void request() throws UserAuthException, TransportException- Specified by:
requestin interfaceAuthMethod- Throws:
UserAuthException- if there is an error with the requestTransportException- if there is a transport-related error
-
shouldRetry
public boolean shouldRetry()
- Specified by:
shouldRetryin interfaceAuthMethod- Returns:
- whether authentication should be reattempted if it failed.
-
buildReq
protected SSHPacket buildReq() throws UserAuthException
Builds aSSHPacketcontaining the fields common to all authentication method. Method-specific fields can further be put into this buffer.- Throws:
UserAuthException
-
makeAccountResource
protected AccountResource makeAccountResource()
-
-