Package org.apache.sshd.server.auth
Class AbstractUserAuth
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.server.auth.AbstractUserAuth
-
- All Implemented Interfaces:
UserAuthInstance<ServerSession>,UsernameHolder,NamedResource,UserAuth,ServerSessionHolder
- Direct Known Subclasses:
UserAuthGSS,UserAuthHostBased,UserAuthKeyboardInteractive,UserAuthNone,UserAuthPassword,UserAuthPublicKey
public abstract class AbstractUserAuth extends AbstractLoggingBean implements UserAuth
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringnameprivate java.lang.Stringserviceprivate ServerSessionsessionprivate java.lang.Stringusername-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractUserAuth(java.lang.String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Booleanauth(ServerSession session, java.lang.String username, java.lang.String service, Buffer buffer)Try to authenticate the user.voiddestroy()Free any system resources used by the module.protected abstract java.lang.BooleandoAuth(Buffer buffer, boolean init)java.lang.StringgetName()ServerSessiongetServerSession()java.lang.StringgetService()ServerSessiongetSession()java.lang.StringgetUsername()java.lang.Booleannext(Buffer buffer)Handle another step in the authentication process.java.lang.StringtoString()
-
-
-
Field Detail
-
name
private final java.lang.String name
-
session
private ServerSession session
-
service
private java.lang.String service
-
username
private java.lang.String username
-
-
Method Detail
-
getName
public final java.lang.String getName()
- Specified by:
getNamein interfaceNamedResource- Returns:
- The resource name
-
getUsername
public java.lang.String getUsername()
- Specified by:
getUsernamein interfaceUsernameHolder- Returns:
- The attached username - may be
null/empty if holder not yet initialized
-
getService
public java.lang.String getService()
-
getServerSession
public ServerSession getServerSession()
- Specified by:
getServerSessionin interfaceServerSessionHolder- Returns:
- The underlying
ServerSessionused
-
getSession
public ServerSession getSession()
- Specified by:
getSessionin interfaceUserAuthInstance<ServerSession>- Returns:
- The current session for which the authentication is being tracked. Note: may be
nullif the instance has not been initialized yet
-
auth
public java.lang.Boolean auth(ServerSession session, java.lang.String username, java.lang.String service, Buffer buffer) throws java.lang.Exception
Description copied from interface:UserAuthTry to authenticate the user. This methods should return a nonnullvalue indicating if the authentication succeeded. If the authentication is still ongoing, anullvalue should be returned.- Specified by:
authin interfaceUserAuth- Parameters:
session- the currentServerSessionsessionusername- the user trying to log inservice- the requested service namebuffer- the request buffer containing parameters specific to this request- Returns:
trueif the authentication succeeded,falseif the authentication failed andnullif not finished yet- Throws:
AsyncAuthException- if the service is willing to perform an asynchronous authenticationjava.lang.Exception- if the authentication fails
-
next
public java.lang.Boolean next(Buffer buffer) throws java.lang.Exception
Description copied from interface:UserAuthHandle another step in the authentication process.- Specified by:
nextin interfaceUserAuth- Parameters:
buffer- the request buffer containing parameters specific to this request- Returns:
trueif the authentication succeeded,falseif the authentication failed andnullif not finished yet- Throws:
AsyncAuthException- if the service is willing to perform an asynchronous authenticationjava.lang.Exception- if the authentication fails
-
destroy
public void destroy()
Description copied from interface:UserAuthFree any system resources used by the module.
-
doAuth
protected abstract java.lang.Boolean doAuth(Buffer buffer, boolean init) throws java.lang.Exception
- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-