public class SshKeyScan extends Object implements Channel, Callable<Void>, ServerKeyVerifier, SessionListener, SimplifiedLog
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 |
logNegotiationProposal(String type,
Map<KexProposalOption,String> proposal) |
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 |
sessionException(Session session,
Throwable t)
An exception was caught and the session will be closed
(if not already so).
|
void |
sessionNegotiationEnd(Session session,
Map<KexProposalOption,String> clientProposal,
Map<KexProposalOption,String> serverProposal,
Map<KexProposalOption,String> negotiatedOptions,
Throwable reason)
Signals the end of the negotiation options handling
|
void |
sessionNegotiationStart(Session session,
Map<KexProposalOption,String> clientProposal,
Map<KexProposalOption,String> serverProposal)
Signals the start of the negotiation options handling
|
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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvalidateListenervalidateListenerlogpublic 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 sessionException(Session session, Throwable t)
SessionListenerSessionListener.sessionClosed(Session) will be called
or perhaps has already been calledsessionException in interface SessionListenersession - The referenced Sessiont - The caught exceptionpublic void sessionClosed(Session session)
SessionListenersessionClosed in interface SessionListenersession - The closed Sessionpublic void sessionNegotiationStart(Session session, Map<KexProposalOption,String> clientProposal, Map<KexProposalOption,String> serverProposal)
SessionListenersessionNegotiationStart in interface SessionListenersession - The referenced SessionclientProposal - The client proposal options (un-modifiable)serverProposal - The server proposal options (un-modifiable)protected void logNegotiationProposal(String type, Map<KexProposalOption,String> proposal)
public void sessionNegotiationEnd(Session session, Map<KexProposalOption,String> clientProposal, Map<KexProposalOption,String> serverProposal, Map<KexProposalOption,String> negotiatedOptions, Throwable reason)
SessionListenersessionNegotiationEnd in interface SessionListenersession - The referenced SessionclientProposal - The client proposal options (un-modifiable)serverProposal - The server proposal options (un-modifiable)negotiatedOptions - The successfully negotiated options so far
- even if exception occurred (un-modifiable)reason - Negotiation end reason - null if successfulpublic boolean verifyServerKey(ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey)
ServerKeyVerifierverifyServerKey in interface ServerKeyVerifiersshClientSession - the current ClientSessionremoteAddress - the host's SocketAddressserverKey - the presented server PublicKeytrue 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–2017 The Apache Software Foundation. All rights reserved.