Top Description Inners Methods
org.eclipse.jgit.transport.sshd.agent

public Interface ConnectorFactory

Imports
java.io.File, .IOException, java.util.Collection, org.eclipse.jgit.annotations.NonNull, org.eclipse.jgit.internal.transport.sshd.agent.ConnectorFactoryProvider

A factory for creating Connectors. This is a service provider interface; implementations are discovered via the java.util.ServiceLoader, or can be set explicitly on a org.eclipse.jgit.transport.sshd.SshdSessionFactory.
Since
6.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Method Summary

Modifier and TypeMethod and Description
public Connector

Returns:

a new Connector
create
(String
identifies the wanted agent connection; if null, the factory is free to provide a Connector to a default agent. The value will typically come from the IdentityAgent setting in ~/.ssh/config.
identityAgent
,
File
the current local user's home directory as configured in the org.eclipse.jgit.transport.sshd.SshdSessionFactory
homeDir
)

Creates a new Connector.

public static ConnectorFactory

Returns:

the current default factory; may be null if none is set and the java.util.ServiceLoader cannot find any suitable implementation
getDefault
()

Retrieves the currently set default ConnectorFactory.

public ConnectorFactory.ConnectorDescriptor

Returns:

a ConnectorDescriptor for the default connector
getDefaultConnector
()

Tells what kind of Connector this ConnectorFactory creates if ConnectorFactory#create(String, File) is called with identityAgent == null.

public String

Returns:

the name
getName
()

Retrieves a name for this factory.

public Collection<ConnectorFactory.ConnectorDescriptor>

Returns:

an immutable collection of ConnectorDescriptors, including getDefaultConnector() and not including a descriptor for internal name "none"
getSupportedConnectors
()

Tells which kinds of SSH agents this ConnectorFactory supports.

public boolean

Returns:

true if the factory can be used, false otherwise
isSupported
()

Tells whether this ConnectorFactory is applicable on the currently running platform.

public static void
setDefault(ConnectorFactory
ConnectorFactory to set, or null to revert to the default behavior of using the java.util.ServiceLoader.
factory
)

Sets a default ConnectorFactory.

Method Detail

createback to summary
public Connector create(String identityAgent, File homeDir) throws IOException

Creates a new Connector.

Parameters
identityAgent:String

identifies the wanted agent connection; if null, the factory is free to provide a Connector to a default agent. The value will typically come from the IdentityAgent setting in ~/.ssh/config.

homeDir:File

the current local user's home directory as configured in the org.eclipse.jgit.transport.sshd.SshdSessionFactory

Returns:Connector

a new Connector

Annotations
@NonNull
Exceptions
IOException:
if no connector can be created
getDefaultback to summary
public static ConnectorFactory getDefault()

Retrieves the currently set default ConnectorFactory. This is the factory that is used unless overridden by the org.eclipse.jgit.transport.sshd.SshdSessionFactory.

Returns:ConnectorFactory

the current default factory; may be null if none is set and the java.util.ServiceLoader cannot find any suitable implementation

getDefaultConnectorback to summary
public ConnectorFactory.ConnectorDescriptor getDefaultConnector()

Tells what kind of Connector this ConnectorFactory creates if ConnectorFactory#create(String, File) is called with identityAgent == null.

Returns:ConnectorFactory.ConnectorDescriptor

a ConnectorDescriptor for the default connector

getNameback to summary
public String getName()

Retrieves a name for this factory.

Returns:String

the name

getSupportedConnectorsback to summary
public Collection<ConnectorFactory.ConnectorDescriptor> getSupportedConnectors()

Tells which kinds of SSH agents this ConnectorFactory supports.

An implementation of this method should document the possible values it returns.

Returns:Collection<ConnectorFactory.ConnectorDescriptor>

an immutable collection of ConnectorDescriptors, including getDefaultConnector() and not including a descriptor for internal name "none"

Annotations
@NonNull
isSupportedback to summary
public boolean isSupported()

Tells whether this ConnectorFactory is applicable on the currently running platform.

Returns:boolean

true if the factory can be used, false otherwise

setDefaultback to summary
public static void setDefault(ConnectorFactory factory)

Sets a default ConnectorFactory. This is the factory that is used unless overridden by the org.eclipse.jgit.transport.sshd.SshdSessionFactory.

If no default factory is set programmatically, an implementation is discovered via the java.util.ServiceLoader.

Parameters
factory:ConnectorFactory

ConnectorFactory to set, or null to revert to the default behavior of using the java.util.ServiceLoader.

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

public Interface ConnectorFactory.ConnectorDescriptor


ConnectorDescriptors describe available Connectors a ConnectorFactory may provide.

A ConnectorFactory may support connecting to different SSH agents. Agents are identified by name; a user can choose a specific agent for instance via the IdentityAgent setting in ~/.ssh/config.

OpenSSH knows two built-in names: "none" for not using any agent, and "SSH_AUTH_SOCK" for using an agent that communicates over a Unix domain socket given by the value of environment variable SSH_AUTH_SOCK. Other agents can be specified in OpenSSH by specifying the socket file directly. (The "standard" OpenBSD OpenSSH knows only this communication mechanism.) "SSH_AUTH_SOCK" is also the default in OpenBSD OpenSSH if nothing is configured.

A particular ConnectorFactory may support more communication mechanisms or different agents. For instance, a factory on Windows might support Pageant, Win32-OpenSSH, or even git bash ssh-agent, and might accept internal names like "pageant", "openssh", "SSH_AUTH_SOCK" in ConnectorFactory#create(String, File) to choose among them.

The ConnectorDescriptor interface and the ConnectorFactory#getSupportedConnectors() and ConnectorFactory#getDefaultConnector() methods provide a way for code using a ConnectorFactory to learn what the factory supports and thus implement some way by which a user can influence the default behavior if IdentityAgent is not set or ConnectorFactory#create(String, File) is called with identityAgent == null.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the display name; properly localized and not empty
getDisplayName
()

Retrieves a display name for a Connector, suitable for showing in a UI.

public String

Returns:

the internal name; not empty
getIdentityAgent
()

Retrieves the internal name of a supported Connector.

Method Detail

getDisplayNameback to summary
public String getDisplayName()

Retrieves a display name for a Connector, suitable for showing in a UI.

Returns:String

the display name; properly localized and not empty

Annotations
@NonNull
getIdentityAgentback to summary
public String getIdentityAgent()

Retrieves the internal name of a supported Connector. The internal name is the one a user can specify for instance in the IdentityAgent setting in ~/.ssh/config to select the connector.

Returns:String

the internal name; not empty

Annotations
@NonNull