Package org.apache.sshd.client.future
Class DefaultAuthFuture
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.future.AbstractSshFuture<T>
-
- org.apache.sshd.common.future.DefaultSshFuture<T>
-
- org.apache.sshd.common.future.DefaultVerifiableSshFuture<T>
-
- org.apache.sshd.common.future.DefaultCancellableSshFuture<AuthFuture>
-
- org.apache.sshd.client.future.DefaultAuthFuture
-
- All Implemented Interfaces:
AuthFuture
,Cancellable
,SshFuture<AuthFuture>
,VerifiableFuture<AuthFuture>
,WaitableFuture
,WithException
public class DefaultAuthFuture extends DefaultCancellableSshFuture<AuthFuture> implements AuthFuture
A default implementation ofAuthFuture
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBoolean
cancellable
private CancelFuture
cancellation
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthFuture(java.lang.Object id, java.lang.Object lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CancelFuture
cancel()
Attempts to cancel the operation.CancelFuture
getCancellation()
Retrieves theCancelFuture
, ifCancellable.cancel()
had been called.boolean
isFailure()
boolean
isSuccess()
void
setAuthed(boolean authed)
Notifies that the session has been authenticated.void
setCancellable(boolean cancellable)
Enables or disables cancellation of thisAuthFuture
.AuthFuture
verify(long timeoutMillis, CancelOption... options)
Wait and verify that the operation was successfulboolean
wasCanceled()
Tells whetherCancellable.cancel()
was called on thisAuthFuture
.-
Methods inherited from class org.apache.sshd.common.future.DefaultCancellableSshFuture
createCancellation, getException, isCanceled, setException
-
Methods inherited from class org.apache.sshd.common.future.DefaultSshFuture
addListener, await0, getNumRegisteredListeners, getValue, isDone, notifyListeners, onValueSet, removeListener, setValue, toString
-
Methods inherited from class org.apache.sshd.common.future.AbstractSshFuture
asListener, asT, await, awaitUninterruptibly, formatExceptionMessage, getId, notifyListener, verifyResult
-
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, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.future.Cancellable
isCanceled
-
Methods inherited from interface org.apache.sshd.common.future.SshFuture
addListener, removeListener
-
Methods inherited from interface org.apache.sshd.common.future.VerifiableFuture
verify, verify, verify
-
Methods inherited from interface org.apache.sshd.common.future.WaitableFuture
await, await, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, getId, isDone
-
Methods inherited from interface org.apache.sshd.common.future.WithException
getException, setException
-
-
-
-
Field Detail
-
cancellation
private final CancelFuture cancellation
-
cancellable
private java.util.concurrent.atomic.AtomicBoolean cancellable
-
-
Method Detail
-
verify
public AuthFuture verify(long timeoutMillis, CancelOption... options) throws java.io.IOException
Description copied from interface:VerifiableFuture
Wait and verify that the operation was successful- Specified by:
verify
in interfaceVerifiableFuture<AuthFuture>
- Parameters:
timeoutMillis
- Wait timeout in millisecondsoptions
- OptionalCancelOption
s defining the behavior on time-out or interrupt; ignored if the future is notCancellable
.- Returns:
- The (same) future instance
- Throws:
java.io.IOException
- If failed to verify successfully on time
-
isSuccess
public boolean isSuccess()
- Specified by:
isSuccess
in interfaceAuthFuture
- Returns:
true
if the authentication operation is finished successfully. Note: calling this method while the operation is in progress returnsfalse
. Should checkWaitableFuture.isDone()
in order to ensure that the result is valid.
-
isFailure
public boolean isFailure()
- Specified by:
isFailure
in interfaceAuthFuture
- Returns:
false
if the authentication operation failed. Note: the operation is considered failed if an exception is received instead of a success/fail response code or the operation is in progress. Should checkWaitableFuture.isDone()
in order to ensure that the result is valid.
-
setAuthed
public void setAuthed(boolean authed)
Description copied from interface:AuthFuture
Notifies that the session has been authenticated. This method is invoked by SSHD internally. Please do not call this method directly.- Specified by:
setAuthed
in interfaceAuthFuture
- Parameters:
authed
- Authentication success state
-
cancel
public CancelFuture cancel()
Attempts to cancel the operation. Note that returnedCancelFuture
may also be fulfilled unsuccessfully (i.e., (DefaultSshFuture.isDone()
&& !
DefaultCancellableSshFuture.isCanceled()
) == true
.- Specified by:
cancel
in interfaceCancellable
- Overrides:
cancel
in classDefaultCancellableSshFuture<AuthFuture>
- Returns:
- A
CancelFuture
that can be used to wait until the cancellation has been effected or theAuthFuture
has been fulfilled; nevernull
.
-
getCancellation
public CancelFuture getCancellation()
Description copied from interface:Cancellable
Retrieves theCancelFuture
, ifCancellable.cancel()
had been called.- Specified by:
getCancellation
in interfaceCancellable
- Overrides:
getCancellation
in classDefaultCancellableSshFuture<AuthFuture>
- Returns:
- The
CancelFuture
if theCancellable
has already been canceled, ornull
otherwise
-
wasCanceled
public boolean wasCanceled()
Description copied from interface:AuthFuture
Tells whetherCancellable.cancel()
was called on thisAuthFuture
.This is different from
Cancellable.isCanceled()
. Cancelling an on-going authentication may not be possible;Cancellable.cancel()
is only a request to cancel the authentication. That request may not be honored and theCancelFuture
may actually beisCanceled()
== false
.AuthFuture
.Cancellable.isCanceled()
is thenfalse
, too.- Specified by:
wasCanceled
in interfaceAuthFuture
- Returns:
true
ifCancellable.cancel()
was called,false
otherwise
-
setCancellable
public void setCancellable(boolean cancellable)
Description copied from interface:AuthFuture
Enables or disables cancellation of thisAuthFuture
.This is a framework method; do not call directly.
- Specified by:
setCancellable
in interfaceAuthFuture
- Parameters:
cancellable
- whether this future is currently cancellable
-
-