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.String
name
private java.lang.String
service
private ServerSession
session
private java.lang.String
username
-
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 protected
AbstractUserAuth(java.lang.String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Boolean
auth(ServerSession session, java.lang.String username, java.lang.String service, Buffer buffer)
Try to authenticate the user.void
destroy()
Free any system resources used by the module.protected abstract java.lang.Boolean
doAuth(Buffer buffer, boolean init)
java.lang.String
getName()
ServerSession
getServerSession()
java.lang.String
getService()
ServerSession
getSession()
java.lang.String
getUsername()
java.lang.Boolean
next(Buffer buffer)
Handle another step in the authentication process.java.lang.String
toString()
-
-
-
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:
getName
in interfaceNamedResource
- Returns:
- The resource name
-
getUsername
public java.lang.String getUsername()
- Specified by:
getUsername
in 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:
getServerSession
in interfaceServerSessionHolder
- Returns:
- The underlying
ServerSession
used
-
getSession
public ServerSession getSession()
- Specified by:
getSession
in interfaceUserAuthInstance<ServerSession>
- Returns:
- The current session for which the authentication is being tracked. Note: may be
null
if 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:UserAuth
Try to authenticate the user. This methods should return a nonnull
value indicating if the authentication succeeded. If the authentication is still ongoing, anull
value should be returned.- Specified by:
auth
in interfaceUserAuth
- Parameters:
session
- the currentServerSession
sessionusername
- the user trying to log inservice
- the requested service namebuffer
- the request buffer containing parameters specific to this request- Returns:
true
if the authentication succeeded,false
if the authentication failed andnull
if 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:UserAuth
Handle another step in the authentication process.- Specified by:
next
in interfaceUserAuth
- Parameters:
buffer
- the request buffer containing parameters specific to this request- Returns:
true
if the authentication succeeded,false
if the authentication failed andnull
if 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:UserAuth
Free 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:
toString
in classjava.lang.Object
-
-