Class InteractivePasswordIdentityProvider
- java.lang.Object
-
- org.apache.sshd.contrib.client.auth.password.InteractivePasswordIdentityProvider
-
- All Implemented Interfaces:
java.util.Iterator<java.lang.String>,org.apache.sshd.client.session.ClientSessionHolder,org.apache.sshd.common.session.SessionContextHolder,org.apache.sshd.common.session.SessionHolder<org.apache.sshd.client.session.ClientSession>
public class InteractivePasswordIdentityProvider extends java.lang.Object implements java.util.Iterator<java.lang.String>, org.apache.sshd.common.session.SessionHolder<org.apache.sshd.client.session.ClientSession>, org.apache.sshd.client.session.ClientSessionHolderHelps implement a
PasswordIdentityProviderby delegating calls toUserInteraction.getUpdatedPassword(ClientSession, String, String). The way to use it would be as follows:
Note:try (ClientSession session = client.connect(login, host, port).await().getSession()) { session.setUserInteraction(...); // this can also be set at the client level PasswordIdentityProvider passwordIdentityProvider = InteractivePasswordIdentityProvider.providerOf(session, "My prompt"); session.setPasswordIdentityProvider(passwordIdentityProvider); session.auth.verify(...timeout...); } or UserInteraction ui = ....; try (ClientSession session = client.connect(login, host, port).await().getSession()) { PasswordIdentityProvider passwordIdentityProvider = InteractivePasswordIdentityProvider.providerOf(session, ui, "My prompt"); session.setPasswordIdentityProvider(passwordIdentityProvider); session.auth.verify(...timeout...); }UserInteraction.isInteractionAllowed(ClientSession)is consulted prior to invokinggetUpdatedPassword- if returnsfalsethen password retrieval method is not invoked, and it is assumed that no more passwords are available
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.sshd.client.session.ClientSessionclientSessionprotected static java.lang.StringEOFSpecial marker to indicate that we exhausted all attemptsprivate java.util.concurrent.atomic.AtomicReference<java.lang.String>nextPasswordprivate java.lang.Stringpromptprivate org.apache.sshd.client.auth.keyboard.UserInteractionuserInteraction
-
Constructor Summary
Constructors Constructor Description InteractivePasswordIdentityProvider(org.apache.sshd.client.session.ClientSession clientSession, org.apache.sshd.client.auth.keyboard.UserInteraction userInteraction, java.lang.String prompt)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.sshd.client.session.ClientSessiongetClientSession()java.lang.StringgetPrompt()org.apache.sshd.client.session.ClientSessiongetSession()org.apache.sshd.client.auth.keyboard.UserInteractiongetUserInteraction()booleanhasNext()java.lang.Stringnext()static org.apache.sshd.client.auth.password.PasswordIdentityProviderproviderOf(org.apache.sshd.client.session.ClientSession clientSession, java.lang.String prompt)static org.apache.sshd.client.auth.password.PasswordIdentityProviderproviderOf(org.apache.sshd.client.session.ClientSession clientSession, org.apache.sshd.client.auth.keyboard.UserInteraction userInteraction, java.lang.String prompt)protected java.lang.StringresolveNextPassword()
-
-
-
Field Detail
-
EOF
protected static final java.lang.String EOF
Special marker to indicate that we exhausted all attempts- See Also:
- Constant Field Values
-
clientSession
private org.apache.sshd.client.session.ClientSession clientSession
-
userInteraction
private org.apache.sshd.client.auth.keyboard.UserInteraction userInteraction
-
prompt
private java.lang.String prompt
-
nextPassword
private java.util.concurrent.atomic.AtomicReference<java.lang.String> nextPassword
-
-
Method Detail
-
getClientSession
public org.apache.sshd.client.session.ClientSession getClientSession()
- Specified by:
getClientSessionin interfaceorg.apache.sshd.client.session.ClientSessionHolder
-
getSession
public org.apache.sshd.client.session.ClientSession getSession()
- Specified by:
getSessionin interfaceorg.apache.sshd.common.session.SessionHolder<org.apache.sshd.client.session.ClientSession>
-
getUserInteraction
public org.apache.sshd.client.auth.keyboard.UserInteraction getUserInteraction()
-
getPrompt
public java.lang.String getPrompt()
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<java.lang.String>
-
next
public java.lang.String next()
- Specified by:
nextin interfacejava.util.Iterator<java.lang.String>
-
resolveNextPassword
protected java.lang.String resolveNextPassword()
-
providerOf
public static org.apache.sshd.client.auth.password.PasswordIdentityProvider providerOf(org.apache.sshd.client.session.ClientSession clientSession, java.lang.String prompt)
-
providerOf
public static org.apache.sshd.client.auth.password.PasswordIdentityProvider providerOf(org.apache.sshd.client.session.ClientSession clientSession, org.apache.sshd.client.auth.keyboard.UserInteraction userInteraction, java.lang.String prompt)
-
-