Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.transport.sshd

public Class JGitUserInteraction

extends Object
implements UserInteraction
Class Inheritance
All Implemented Interfaces
org.apache.sshd.client.auth.keyboard.UserInteraction
Imports
java.net.InetSocketAddress, java.util.ArrayList, .List, .Map, java.util.concurrent.ConcurrentHashMap, org.apache.sshd.client.auth.keyboard.UserInteraction, org.apache.sshd.client.session.ClientSession, org.apache.sshd.common.session.Session, .SessionListener, org.eclipse.jgit.transport.CredentialItem, .CredentialsProvider, .SshConstants, .URIish

A UserInteraction callback implementation based on a CredentialsProvider.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
JGitUserInteraction.SessionAuthMarker

A SessionListener that removes itself from the session when authentication is done or the session is closed.

Field Summary

Modifier and TypeField and Description
private final Map<Session, SessionListener>
ongoing

We need to reset the JGit credentials provider if we have repeated attempts.

private final CredentialsProvider

Constructor Summary

AccessConstructor and Description
public
JGitUserInteraction(CredentialsProvider
to use
provider
)

Creates a new JGitUserInteraction for interactive password input based on the given CredentialsProvider.

Method Summary

Modifier and TypeMethod and Description
public String
getUpdatedPassword(ClientSession
The ClientSession through which the request was received
session
,
String
The server's prompt (may be empty)
prompt
,
String
The prompt's language (may be empty)
lang
)

Implements org.apache.sshd.client.auth.keyboard.UserInteraction.getUpdatedPassword.

Invoked when the server returns an SSH_MSG_USERAUTH_PASSWD_CHANGEREQ response indicating that the password should be changed - e.g., expired or not strong enough (as per the server's policy).

public String[]
interactive(ClientSession
The ClientSession through which the request was received
session
,
String
The interaction name (may be empty)
name
,
String
The instruction (may be empty)
instruction
,
String
The language for the data (may be empty)
lang
,
String[]
The prompts to be displayed (may be empty)
prompt
,
boolean[]
For each prompt whether to echo the user's response
echo
)

Implements org.apache.sshd.client.auth.keyboard.UserInteraction.interactive.

Invoked when "keyboard-interactive" authentication mechanism is used in order to provide responses for the server's challenges (a.k.a. prompts)

public boolean
public String
resolveAuthPasswordAttempt(ClientSession
The ClientSession through which the request was received
session
)

Overrides default org.apache.sshd.client.auth.keyboard.UserInteraction.resolveAuthPasswordAttempt.

Invoked during password authentication when no more pre-registered passwords are available

public static URIish

Returns:

the uri, with SshConstants#SSH_SCHEME as scheme
toURI
(String
for the uri
userName
,
InetSocketAddress
address of the remote host
remote
)

Creates a URIish from the given remote address and user name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ongoingback to summary
private final Map<Session, SessionListener> ongoing

We need to reset the JGit credentials provider if we have repeated attempts.

providerback to summary
private final CredentialsProvider provider

Constructor Detail

JGitUserInteractionback to summary
public JGitUserInteraction(CredentialsProvider provider)

Creates a new JGitUserInteraction for interactive password input based on the given CredentialsProvider.

Parameters
provider:CredentialsProvider

to use

Method Detail

getUpdatedPasswordback to summary
public String getUpdatedPassword(ClientSession session, String prompt, String lang)

Implements org.apache.sshd.client.auth.keyboard.UserInteraction.getUpdatedPassword.

Doc from org.apache.sshd.client.auth.keyboard.UserInteraction.getUpdatedPassword.

Invoked when the server returns an SSH_MSG_USERAUTH_PASSWD_CHANGEREQ response indicating that the password should be changed - e.g., expired or not strong enough (as per the server's policy).

Parameters
session:ClientSession

The ClientSession through which the request was received

prompt:String

The server's prompt (may be empty)

lang:String

The prompt's language (may be empty)

Returns:String

The password to use - if null/empty then no updated password was provided - thus failing the authentication via passwords

Note

authentication might still succeed via some other means - be it other passwords, public keys, etc...

Annotations
@Override
interactiveback to summary
public String[] interactive(ClientSession session, String name, String instruction, String lang, String[] prompt, boolean[] echo)

Implements org.apache.sshd.client.auth.keyboard.UserInteraction.interactive.

Doc from org.apache.sshd.client.auth.keyboard.UserInteraction.interactive.

Invoked when "keyboard-interactive" authentication mechanism is used in order to provide responses for the server's challenges (a.k.a. prompts)

Parameters
session:ClientSession

The ClientSession through which the request was received

name:String

The interaction name (may be empty)

instruction:String

The instruction (may be empty)

lang:String

The language for the data (may be empty)

prompt:String[]

The prompts to be displayed (may be empty)

echo:boolean[]

For each prompt whether to echo the user's response

Returns:String[]

The replies - Note: the protocol states that the number of replies should be exactly the same as the number of prompts, however we do not enforce it since it is defined as the server's job to check and manage this violation.

Annotations
@Override
isInteractionAllowedback to summary
public boolean isInteractionAllowed(ClientSession session)

Overrides default org.apache.sshd.client.auth.keyboard.UserInteraction.isInteractionAllowed.

Parameters
session:ClientSession

Doc from org.apache.sshd.client.auth.keyboard.UserInteraction.isInteractionAllowed.

The ClientSession

Returns:boolean

Doc from org.apache.sshd.client.auth.keyboard.UserInteraction.isInteractionAllowed.

true if user interaction allowed for this session (default)

Annotations
@Override
resolveAuthPasswordAttemptback to summary
public String resolveAuthPasswordAttempt(ClientSession session) throws Exception

Overrides default org.apache.sshd.client.auth.keyboard.UserInteraction.resolveAuthPasswordAttempt.

Doc from org.apache.sshd.client.auth.keyboard.UserInteraction.resolveAuthPasswordAttempt.

Invoked during password authentication when no more pre-registered passwords are available

Parameters
session:ClientSession

The ClientSession through which the request was received

Returns:String

The password to use - null signals no more passwords available

Annotations
@Override
Exceptions
Exception:
if failed to handle the request - Note: may cause session termination
toURIback to summary
public static URIish toURI(String userName, InetSocketAddress remote)

Creates a URIish from the given remote address and user name.

Parameters
userName:String

for the uri

remote:InetSocketAddress

address of the remote host

Returns:URIish

the uri, with SshConstants#SSH_SCHEME as scheme

org.eclipse.jgit.internal.transport.sshd back to summary

private Class JGitUserInteraction.SessionAuthMarker

extends Object
implements SessionListener
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.internal.transport.sshd.JGitUserInteraction.SessionAuthMarker
All Implemented Interfaces
org.apache.sshd.common.session.SessionListener, org.apache.sshd.common.util.SshdEventListener, java.util.EventListener

A SessionListener that removes itself from the session when authentication is done or the session is closed.

Field Summary

Modifier and TypeField and Description
private final Map<Session, SessionListener>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
sessionClosed(Session
The closed Session
session
)

Overrides default org.apache.sshd.common.session.SessionListener.sessionClosed.

A session has been closed

public void
sessionEvent(Session
The referenced Session
session
,
SessionListener.Event
The generated Event
event
)

Overrides default org.apache.sshd.common.session.SessionListener.sessionEvent.

An event has been triggered

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

registeredback to summary
private final Map<Session, SessionListener> registered

Constructor Detail

SessionAuthMarkerback to summary
public SessionAuthMarker(Map<Session, SessionListener> registered)

Method Detail

sessionClosedback to summary
public void sessionClosed(Session session)

Overrides default org.apache.sshd.common.session.SessionListener.sessionClosed.

Doc from org.apache.sshd.common.session.SessionListener.sessionClosed.

A session has been closed

Parameters
session:Session

The closed Session

Annotations
@Override
sessionEventback to summary
public void sessionEvent(Session session, SessionListener.Event event)

Overrides default org.apache.sshd.common.session.SessionListener.sessionEvent.

Doc from org.apache.sshd.common.session.SessionListener.sessionEvent.

An event has been triggered

Parameters
session:Session

The referenced Session

event:SessionListener.Event

The generated Event

Annotations
@Override