Class ClientUserAuthService
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.util.closeable.IoBaseCloseable
-
- org.apache.sshd.common.util.closeable.AbstractCloseable
-
- org.apache.sshd.client.session.ClientUserAuthService
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,ClientSessionHolder,Closeable,PropertyResolver,Service,SessionContextHolder,SessionHolder<Session>
public class ClientUserAuthService extends AbstractCloseable implements Service, ClientSessionHolder
Client sidessh-authservice.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
AbstractCloseable.State
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<UserAuthFactory>authFactoriesprotected java.util.concurrent.atomic.AtomicReference<AuthFuture>authFutureHolderThe AuthFuture that is being used by the current auth request.protected java.util.List<java.lang.String>clientMethodsprotected ClientSessionImplclientSessionprivate intcurrentMethodprivate UserAuthcurrentUserAuthprivate java.lang.RunnableinitialRequestSenderprivate java.lang.ObjectinitLockprivate java.util.Map<java.lang.String,java.lang.Object>propertiesprivate UserAuthpubkeyAuthprotected java.util.List<java.lang.String>serverMethodsprivate java.lang.Stringserviceprivate booleanstarted-
Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, state
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTY
-
-
Constructor Summary
Constructors Constructor Description ClientUserAuthService(Session s)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthFutureauth(java.lang.String service)private voidclearUserAuth()protected AuthFuturecreateAuthFuture(ClientSession session, java.lang.String service)private voiddestroyPubkeyAuth()private voiddestroyUserAuth()ClientSessiongetClientSession()java.lang.StringgetCurrentServiceName()java.util.Map<java.lang.String,java.lang.Object>getProperties()A map of properties that can be used to configure the SSH server or client.ClientSessiongetSession()protected voidpreClose()preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately.voidprocess(int cmd, Buffer buffer)Service the request.protected voidprocessUserAuth(int cmd, Buffer buffer, AuthFuture authFuture)Execute one step in user authentication.protected IoWriteFuturesendInitialAuthRequest(ClientSession session, java.lang.String service)voidstart()protected voidtryNext(int cmd, AuthFuture authFuture)protected AuthFutureupdateCurrentAuthFuture(ClientSession session, java.lang.String service)-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, doCloseGracefully, doCloseImmediately, getFutureLock, isClosed, isClosing, removeCloseFutureListener
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
Methods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getString, getStringProperty, isEmpty
-
Methods inherited from interface org.apache.sshd.common.Service
getParentPropertyResolver
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
-
-
-
Field Detail
-
authFutureHolder
protected final java.util.concurrent.atomic.AtomicReference<AuthFuture> authFutureHolder
The AuthFuture that is being used by the current auth request. It is set while an authentication is ongoing.
-
clientSession
protected final ClientSessionImpl clientSession
-
authFactories
protected final java.util.List<UserAuthFactory> authFactories
-
clientMethods
protected final java.util.List<java.lang.String> clientMethods
-
serverMethods
protected java.util.List<java.lang.String> serverMethods
-
properties
private final java.util.Map<java.lang.String,java.lang.Object> properties
-
service
private java.lang.String service
-
currentUserAuth
private UserAuth currentUserAuth
-
currentMethod
private int currentMethod
-
pubkeyAuth
private UserAuth pubkeyAuth
-
initLock
private final java.lang.Object initLock
-
started
private boolean started
-
initialRequestSender
private java.lang.Runnable initialRequestSender
-
-
Constructor Detail
-
ClientUserAuthService
public ClientUserAuthService(Session s)
-
-
Method Detail
-
getSession
public ClientSession getSession()
- Specified by:
getSessionin interfaceSessionHolder<Session>
-
getClientSession
public ClientSession getClientSession()
- Specified by:
getClientSessionin interfaceClientSessionHolder- Returns:
- The underlying
ClientSessionused
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Description copied from interface:PropertyResolverA map of properties that can be used to configure the SSH server or client. This map will never be changed by either the server or client and is not supposed to be changed at runtime (changes are not bound to have any effect on a running client or server), though it may affect the creation of sessions later as these values are usually not cached.
Note: the type of the mapped property should match the expected configuration value type -
Long, Integer, Boolean, String, etc.... If it doesn't, thetoString()result of the mapped value is used to convert it to the required type. E.g., if the mapped value is the string "1234" and the expected value is alongthen it will be parsed into one. Also, if the mapped value is anIntegerbut alongis expected, then it will be converted into one.- Specified by:
getPropertiesin interfacePropertyResolver- Returns:
- a valid
Mapcontaining configuration values, nevernull. Note: may be immutable.
-
getCurrentServiceName
public java.lang.String getCurrentServiceName()
-
auth
public AuthFuture auth(java.lang.String service) throws java.io.IOException
- Throws:
java.io.IOException
-
updateCurrentAuthFuture
protected AuthFuture updateCurrentAuthFuture(ClientSession session, java.lang.String service) throws java.io.IOException
- Throws:
java.io.IOException
-
createAuthFuture
protected AuthFuture createAuthFuture(ClientSession session, java.lang.String service) throws java.io.IOException
- Throws:
java.io.IOException
-
sendInitialAuthRequest
protected IoWriteFuture sendInitialAuthRequest(ClientSession session, java.lang.String service) throws java.io.IOException
- Throws:
java.io.IOException
-
process
public void process(int cmd, Buffer buffer) throws java.lang.ExceptionDescription copied from interface:ServiceService the request.
-
processUserAuth
protected void processUserAuth(int cmd, Buffer buffer, AuthFuture authFuture) throws java.lang.ExceptionExecute one step in user authentication.- Parameters:
cmd- the commandbuffer- the inputBuffer, with the reading position after the command byteauthFuture- theAuthFuture- Throws:
java.lang.Exception- If failed to process
-
tryNext
protected void tryNext(int cmd, AuthFuture authFuture) throws java.lang.Exception- Throws:
java.lang.Exception
-
clearUserAuth
private void clearUserAuth()
-
destroyUserAuth
private void destroyUserAuth()
-
destroyPubkeyAuth
private void destroyPubkeyAuth()
-
preClose
protected void preClose()
Description copied from class:AbstractCloseablepreClose is guaranteed to be called before doCloseGracefully or doCloseImmediately. When preClose() is called, isClosing() == true- Overrides:
preClosein classAbstractCloseable
-
-