Interface ConnectorFactory
-
- All Known Implementing Classes:
Factory
public interface ConnectorFactory
A factory for creatingConnector
s. This is a service provider interface; implementations are discovered via theServiceLoader
, or can be set explicitly on aSshdSessionFactory
.- Since:
- 6.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ConnectorFactory.ConnectorDescriptor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Connector
create(String identityAgent, File homeDir)
Creates a newConnector
.static ConnectorFactory
getDefault()
Retrieves the currently set defaultConnectorFactory
.ConnectorFactory.ConnectorDescriptor
getDefaultConnector()
Tells what kind ofConnector
thisConnectorFactory
creates ifcreate(String, File)
is called withidentityAgent == null
.String
getName()
Retrieves a name for this factory.Collection<ConnectorFactory.ConnectorDescriptor>
getSupportedConnectors()
Tells which kinds of SSH agents thisConnectorFactory
supports.boolean
isSupported()
Tells whether thisConnectorFactory
is applicable on the currently running platform.static void
setDefault(ConnectorFactory factory)
Sets a defaultConnectorFactory
.
-
-
-
Method Detail
-
getDefault
static ConnectorFactory getDefault()
Retrieves the currently set defaultConnectorFactory
. This is the factory that is used unless overridden by theSshdSessionFactory
.- Returns:
- the current default factory; may be
null
if none is set and theServiceLoader
cannot find any suitable implementation
-
setDefault
static void setDefault(ConnectorFactory factory)
Sets a defaultConnectorFactory
. This is the factory that is used unless overridden by theSshdSessionFactory
.If no default factory is set programmatically, an implementation is discovered via the
ServiceLoader
.- Parameters:
factory
-ConnectorFactory
to set, ornull
to revert to the default behavior of using theServiceLoader
.
-
create
@NonNull Connector create(String identityAgent, File homeDir) throws IOException
Creates a newConnector
.- Parameters:
identityAgent
- identifies the wanted agent connection; ifnull
, the factory is free to provide aConnector
to a default agent. The value will typically come from theIdentityAgent
setting in~/.ssh/config
.homeDir
- the current local user's home directory as configured in theSshdSessionFactory
- Returns:
- a new
Connector
- Throws:
IOException
- if no connector can be created
-
isSupported
boolean isSupported()
Tells whether thisConnectorFactory
is applicable on the currently running platform.- Returns:
true
if the factory can be used,false
otherwise
-
getName
String getName()
Retrieves a name for this factory.- Returns:
- the name
-
getSupportedConnectors
@NonNull Collection<ConnectorFactory.ConnectorDescriptor> getSupportedConnectors()
Tells which kinds of SSH agents thisConnectorFactory
supports.An implementation of this method should document the possible values it returns.
- Returns:
- an immutable collection of
ConnectorFactory.ConnectorDescriptor
s, includinggetDefaultConnector()
and not including a descriptor for internal name "none"
-
getDefaultConnector
ConnectorFactory.ConnectorDescriptor getDefaultConnector()
Tells what kind ofConnector
thisConnectorFactory
creates ifcreate(String, File)
is called withidentityAgent == null
.- Returns:
- a
ConnectorFactory.ConnectorDescriptor
for the default connector
-
-