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) |
logpublic 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 SimplifiedLogpublic boolean isEnabled(Level level)
isEnabled in interface SimplifiedLogprotected void resolveServerKeys(SshClient client, String host, Map<String,List<KeyPair>> pairsMap, Map<String,List<NamedFactory<Signature>>> sigFactories) throws IOException
IOExceptionprotected void resolveServerKeys(SshClient client, String host, String kt, List<KeyPair> ids) throws Exception
Exceptionpublic void sessionCreated(Session session)
SessionListenersessionCreated in interface SessionListenersession - The created Sessionpublic void sessionEvent(Session session, SessionListener.Event event)
SessionListenersessionEvent in interface SessionListenersession - The referenced Sessionevent - The generated SessionListener.Eventpublic void sessionClosed(Session session)
SessionListenersessionClosed in interface SessionListenersession - The closed Sessionpublic boolean verifyServerKey(ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey)
ServerKeyVerifierverifyServerKey in interface ServerKeyVerifiersshClientSession - 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
Exceptionprotected List<NamedFactory<Signature>> resolveSignatureFactories(String keyType) throws GeneralSecurityException
GeneralSecurityExceptionprotected Map<String,List<KeyPair>> createKeyPairs(Collection<String> typeNames) throws GeneralSecurityException
GeneralSecurityExceptionprotected List<KeyPair> createKeyPairs(String keyType) throws GeneralSecurityException
GeneralSecurityExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOExceptionpublic static List<String> parseCommandLineArguments(SshKeyScan scanner, String... args) throws IOException
IOExceptionpublic static <S extends SshKeyScan> S setInputStream(S scanner, Collection<String> hosts) throws IOException
IOExceptionpublic static <S extends SshKeyScan> S initializeScanner(S scanner, Collection<String> hosts) throws IOException
IOExceptionCopyright © 2008–2015 The Apache Software Foundation. All rights reserved.