public class SshKeyScan extends AbstractSimplifiedLog implements Channel, Callable<Void>, ServerKeyVerifier, SessionListener
SessionListener.Event
Modifier and Type | Field and Description |
---|---|
static List<String> |
DEFAULT_KEY_TYPES
Default key types if not overridden from the command line
|
static Level |
DEFAULT_LEVEL |
static long |
DEFAULT_TIMEOUT |
EMPTY
Constructor and Description |
---|
SshKeyScan() |
Modifier and Type | Method and Description |
---|---|
Void |
call() |
void |
close() |
protected Map<String,List<KeyPair>> |
createKeyPairs(Collection<String> typeNames) |
protected List<KeyPair> |
createKeyPairs(String keyType) |
InputStream |
getInputStream() |
List<String> |
getKeyTypes() |
Level |
getLogLevel() |
int |
getPort() |
long |
getTimeout() |
static <S extends SshKeyScan> |
initializeScanner(S scanner,
Collection<String> hosts) |
boolean |
isEnabled(Level level) |
boolean |
isOpen() |
void |
log(Level level,
Object message,
Throwable t) |
protected void |
logSessionEvent(Session session,
Object event) |
static void |
main(String[] args) |
static List<String> |
parseCommandLineArguments(SshKeyScan scanner,
String... args) |
protected void |
resolveServerKeys(SshClient client,
String host,
Map<String,List<KeyPair>> pairsMap,
Map<String,List<NamedFactory<Signature>>> sigFactories) |
protected void |
resolveServerKeys(SshClient client,
String host,
String kt,
List<KeyPair> ids) |
protected List<NamedFactory<Signature>> |
resolveSignatureFactories(String keyType) |
void |
sessionClosed(Session session)
A session has been closed
|
void |
sessionCreated(Session session)
A new session just been created
|
void |
sessionEvent(Session session,
SessionListener.Event event)
An event has been triggered
|
void |
setInputStream(InputStream input) |
static <S extends SshKeyScan> |
setInputStream(S scanner,
Collection<String> hosts) |
void |
setKeyTypes(List<String> keyTypes) |
void |
setLogLevel(Level level) |
void |
setPort(int port) |
void |
setTimeout(long timeout) |
boolean |
verifyServerKey(ClientSession sshClientSession,
SocketAddress remoteAddress,
PublicKey serverKey)
Verify that the server key provided is really the one of the host.
|
protected void |
writeServerKey(String remoteLocation,
String keyType,
PublicKey serverKey) |
log
public static final List<String> DEFAULT_KEY_TYPES
public static final long DEFAULT_TIMEOUT
public static final Level DEFAULT_LEVEL
public int getPort()
public void setPort(int port)
public InputStream getInputStream()
public void setInputStream(InputStream input)
public long getTimeout()
public void setTimeout(long timeout)
public Level getLogLevel()
public void setLogLevel(Level level)
public void log(Level level, Object message, Throwable t)
log
in interface SimplifiedLog
public boolean isEnabled(Level level)
isEnabled
in interface SimplifiedLog
protected void resolveServerKeys(SshClient client, String host, Map<String,List<KeyPair>> pairsMap, Map<String,List<NamedFactory<Signature>>> sigFactories) throws IOException
IOException
protected void resolveServerKeys(SshClient client, String host, String kt, List<KeyPair> ids) throws Exception
Exception
public void sessionCreated(Session session)
SessionListener
sessionCreated
in interface SessionListener
session
- The created Session
public void sessionEvent(Session session, SessionListener.Event event)
SessionListener
sessionEvent
in interface SessionListener
session
- The referenced Session
event
- The generated SessionListener.Event
public void sessionClosed(Session session)
SessionListener
sessionClosed
in interface SessionListener
session
- The closed Session
public boolean verifyServerKey(ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey)
ServerKeyVerifier
verifyServerKey
in interface ServerKeyVerifier
sshClientSession
- the current sessionremoteAddress
- the hostserverKey
- the presented keytrue
if the key is accepted for the hostprotected void writeServerKey(String remoteLocation, String keyType, PublicKey serverKey) throws Exception
Exception
protected List<NamedFactory<Signature>> resolveSignatureFactories(String keyType) throws GeneralSecurityException
GeneralSecurityException
protected Map<String,List<KeyPair>> createKeyPairs(Collection<String> typeNames) throws GeneralSecurityException
GeneralSecurityException
protected List<KeyPair> createKeyPairs(String keyType) throws GeneralSecurityException
GeneralSecurityException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
IOException
public static List<String> parseCommandLineArguments(SshKeyScan scanner, String... args) throws IOException
IOException
public static <S extends SshKeyScan> S setInputStream(S scanner, Collection<String> hosts) throws IOException
IOException
public static <S extends SshKeyScan> S initializeScanner(S scanner, Collection<String> hosts) throws IOException
IOException
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.