public final class Ssh2Context extends Object implements SshContext
This class implements SshContextto provide SSH2 connection configuration through the SshConnector class.
To configure an authentication banner for SSH2 connections see BannerDisplay.
The preferred message authentication algorithm for each data stream can be set using:
Once further cipher, public key and compression algorithms have been implemented the same process will apply.SshConnector con = SshConnector.getInstance(); Ssh2Context context = (Ssh2Context) con.getContext(SshConnector.SSH2); context.setPreferredMacCS(Ssh2Context.HMAC_MD5); // Client->Server data stream context.setPreferredMacSC(Ssh2Context.HMAC_MD5); // Server->Client data stream
Modifier and Type | Field and Description |
---|---|
static String |
CIPHER_AES128_CBC |
static String |
CIPHER_AES128_CTR |
static String |
CIPHER_AES192_CBC |
static String |
CIPHER_AES192_CTR |
static String |
CIPHER_AES256_CBC |
static String |
CIPHER_AES256_CTR |
static String |
CIPHER_ARCFOUR |
static String |
CIPHER_ARCFOUR_128 |
static String |
CIPHER_ARCFOUR_256 |
static String |
CIPHER_BLOWFISH_CBC |
static String |
CIPHER_TRIPLEDES_CBC |
static String |
CIPHER_TRIPLEDES_CTR |
static String |
COMPRESSION_NONE
Compression off
|
static String |
COMPRESSION_ZLIB
Optional zlib compression (requires sshtools-zlib.jar in classpath)
|
static String |
HMAC_MD5
MD5 message authentication
|
static String |
HMAC_MD5_96
MD5 96 bit message authentication
|
static String |
HMAC_SHA1
SHA1 message authentication
|
static String |
HMAC_SHA1_96
SHA1 96 bit message authentication
|
static String |
HMAC_SHA256 |
static String |
KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA1
Optional key exchange mechanism in which the server maintains a list of
acceptable generators and primes
|
static String |
KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256 |
static String |
KEX_DIFFIE_HELLMAN_GROUP1_SHA1
The required key exchange method
|
static String |
KEX_DIFFIE_HELLMAN_GROUP14_SHA1 |
static String |
PUBLIC_KEY_SSHDSS
SSH2 DSA Public Key
|
static String |
PUBLIC_KEY_SSHRSA
SSH2 RSA Public Key
|
Constructor and Description |
---|
Ssh2Context()
Contructs a default context
|
Modifier and Type | Method and Description |
---|---|
void |
disableCompression() |
void |
enableCompression() |
void |
enableFIPSMode()
Enables FIPS compatible algorithms and disables any other non-compatible
algorithms.
|
BannerDisplay |
getBannerDisplay()
Get the contexts banner display
|
int |
getChannelLimit()
Get the maximum number of channels that are allowed open at any one time.
|
String |
getCiphersCS()
Get the ciphers for the Client->Server stream.
|
String |
getCiphersSC()
Get the ciphers for the Server->Client stream.
|
int |
getDHGroupExchangeKeySize() |
MaverickCallbackHandler |
getGssCallback() |
HostKeyVerification |
getHostKeyVerification()
Get the host key verification implementation
|
int |
getIdleConnectionTimeoutSeconds() |
int |
getKeepAliveMaxDataLength() |
String |
getKeyExchanges()
Get the ciphers for the Server->Client stream.
|
String |
getMacsCS()
Get the ciphers for the Client->Server stream.
|
String |
getMacsSC()
Get the ciphers for the Server->Client stream.
|
int |
getMaximumPacketLength()
Get the maximim packet size supported by the transport layer.
|
int |
getPartialMessageTimeout() |
String |
getPreferredCipherCS()
Get the currently preferred cipher for the Client->Server stream.
|
String |
getPreferredCipherSC()
Get the currently preferred cipher for the Server->Client stream.
|
String |
getPreferredCompressionCS()
Get the currently preferred compression for the Client->Server stream.
|
String |
getPreferredCompressionSC()
Get the currently preferred compression for the Server->Client stream.
|
String |
getPreferredKeyExchange()
Get the currently preferred key exchange method.
|
String |
getPreferredMacCS()
Get the currently preferred mac for the Client->Server stream.
|
String |
getPreferredMacSC()
Get the currently supported mac for the Server-Client stream.
|
String |
getPreferredPublicKey()
Get the currently preferred public key algorithm.
|
String |
getPublicKeys()
Get the ciphers for the Server->Client stream.
|
String |
getSFTPProvider()
Get the path to the SFTP provider.
|
int |
getSocketTimeout() |
byte[] |
getX11AuthenticationCookie()
Get a fake random cookie for X11 authentication
|
String |
getX11Display()
Get the currently configured XDisplay setting which will be null if no
display is currently set.
|
byte[] |
getX11RealCookie()
Get the real X11 authentication cookie, if not cookie has been set the
fake cookie will be returned.
|
ForwardingRequestListener |
getX11RequestListener()
Get the X11 forwarding request listener.
|
boolean |
isDHGroupExchangeBackwardsCompatible() |
boolean |
isKeyReExchangeDisabled() |
boolean |
isSendIgnorePacketOnIdle() |
void |
setBannerDisplay(BannerDisplay bannerdisplay)
Set a banner display for callback of authentication banners
|
void |
setChannelLimit(int maxChannels)
Set the maximum number of channels that are allowed open at any one time.
|
void |
setCipherPreferredPositionCS(String name,
int position) |
void |
setCipherPreferredPositionSC(String name,
int position) |
void |
setDHGroupExchangeBackwardsCompatible(boolean dhGroupExchangeBackwardCompatible) |
void |
setDHGroupExchangeKeySize(int dhGroupExchangeKeySize) |
void |
setGssCallback(MaverickCallbackHandler gsscall) |
void |
setHostKeyVerification(HostKeyVerification verify)
Set the host key verification implementation
|
void |
setIdleConnectionTimeoutSeconds(int idleConnectionTimeoutSeconds) |
void |
setKeepAliveMaxDataLength(int keepAliveMaxDataLength) |
void |
setKeyExchangePreferredPosition(String name,
int position) |
void |
setKeyReExchangeDisabled(boolean keyReExchangeDisabled) |
void |
setMacPreferredPositionCS(String name,
int position) |
void |
setMacPreferredPositionSC(String name,
int position) |
void |
setMaximumPacketLength(int maxPacketLength)
Set the maximum packet size supported by the transport layer.
|
void |
setPartialMessageTimeout(int partialMessageTimeout) |
void |
setPreferredCipherCS(int[] order)
Set the preferred SC cipher order
|
void |
setPreferredCipherCS(String name)
Set the preferred cipher for the Client->Server stream.
|
void |
setPreferredCipherSC(int[] order)
Set the preferred SC cipher order
|
void |
setPreferredCipherSC(String name)
Set the preferred cipher for the Server->Client stream.
|
void |
setPreferredCompressionCS(String name)
Set the preferred compression for the Client->Server stream.
|
void |
setPreferredCompressionSC(String name)
Set the preferred compression for the Server->Client stream.
|
void |
setPreferredKeyExchange(String name)
Set the preferred key exchange method.
|
void |
setPreferredMacCS(int[] order)
Set the preferred CS Mac order
|
void |
setPreferredMacCS(String name)
Set the preferred mac for the Client->Server stream.
|
void |
setPreferredMacSC(int[] order)
Set the preferred SC Mac order
|
void |
setPreferredMacSC(String name)
Set the preferred mac for the Server->Client stream.
|
void |
setPreferredPublicKey(String name)
Set the preferred public key algorithm.
|
void |
setPublicKeyPreferredPosition(String name,
int position) |
void |
setSendIgnorePacketOnIdle(boolean sendIgnorePacketOnIdle) |
void |
setSFTPProvider(String sftpProvider)
Set the path to the SFTP provider.
|
void |
setSocketTimeout(int socketTimeout) |
void |
setX11AuthenticationCookie(byte[] x11FakeCookie)
Set the fake cookie used for X11 authentication
|
void |
setX11Display(String xDisplay)
Set the DISPLAY variable for the SSH connection.
|
void |
setX11RealCookie(byte[] x11RealCookie)
Sets the real X11 authentication cookie which can be obtained from the
users $HOME/.Xauthority file.
|
void |
setX11RequestListener(ForwardingRequestListener x11Listener)
Set the listener to which X11 forwarding requests will be processed.
|
ComponentFactory |
supportedCiphersCS() |
ComponentFactory |
supportedCiphersSC()
Returns this context's supported cipher algorithms.
|
ComponentFactory |
supportedCompressionsCS()
Get this context's supported CS compression algorithms.
|
ComponentFactory |
supportedCompressionsSC()
Get this context's supported SC compression algorithms.
|
ComponentFactory |
supportedKeyExchanges()
Get this context's supported key exchange methods.
|
ComponentFactory |
supportedMacsCS()
Get this context's supported message authentication algorithms CS.
|
ComponentFactory |
supportedMacsSC()
Get this context's supported message authentication algorithms SC.
|
ComponentFactory |
supportedPublicKeys()
Get this context's supported public keys.
|
public static final String CIPHER_TRIPLEDES_CBC
public static final String CIPHER_TRIPLEDES_CTR
public static final String CIPHER_BLOWFISH_CBC
public static final String CIPHER_AES128_CBC
public static final String CIPHER_AES192_CBC
public static final String CIPHER_AES256_CBC
public static final String CIPHER_AES128_CTR
public static final String CIPHER_AES192_CTR
public static final String CIPHER_AES256_CTR
public static final String CIPHER_ARCFOUR
public static final String CIPHER_ARCFOUR_128
public static final String CIPHER_ARCFOUR_256
public static final String HMAC_SHA1
public static final String HMAC_SHA1_96
public static final String HMAC_MD5
public static final String HMAC_MD5_96
public static final String HMAC_SHA256
public static final String COMPRESSION_NONE
public static final String COMPRESSION_ZLIB
public static final String KEX_DIFFIE_HELLMAN_GROUP1_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP14_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256
public static final String PUBLIC_KEY_SSHDSS
public static final String PUBLIC_KEY_SSHRSA
public Ssh2Context() throws SshException
SshException
public int getMaximumPacketLength()
public void setGssCallback(MaverickCallbackHandler gsscall)
public MaverickCallbackHandler getGssCallback()
public void setMaximumPacketLength(int maxPacketLength)
maxPacketLength
- intpublic void setChannelLimit(int maxChannels)
SshContext
setChannelLimit
in interface SshContext
public int getChannelLimit()
SshContext
getChannelLimit
in interface SshContext
public void setX11Display(String xDisplay)
SshContext
setX11Display
in interface SshContext
xDisplay
- the display in the form localhost:1public String getX11Display()
SshContext
getX11Display
in interface SshContext
public byte[] getX11AuthenticationCookie() throws SshException
SshContext
getX11AuthenticationCookie
in interface SshContext
SshException
public void setX11AuthenticationCookie(byte[] x11FakeCookie)
SshContext
setX11AuthenticationCookie
in interface SshContext
public void setX11RealCookie(byte[] x11RealCookie)
SshContext
setX11RealCookie
in interface SshContext
public byte[] getX11RealCookie() throws SshException
SshContext
getX11RealCookie
in interface SshContext
SshException
public void setX11RequestListener(ForwardingRequestListener x11Listener)
SshContext
setX11RequestListener
in interface SshContext
public ForwardingRequestListener getX11RequestListener()
SshContext
getX11RequestListener
in interface SshContext
public BannerDisplay getBannerDisplay()
public void setBannerDisplay(BannerDisplay bannerdisplay)
bannerdisplay
- the banner display, may be nullpublic ComponentFactory supportedCiphersSC()
public ComponentFactory supportedCiphersCS()
public String getPreferredCipherCS()
public void setPreferredCipherCS(String name) throws SshException
name
- SshException
public String getPreferredCipherSC()
public String getCiphersCS()
public String getCiphersSC()
public String getMacsCS()
public String getMacsSC()
public String getPublicKeys()
public String getKeyExchanges()
public void setPreferredCipherSC(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredCipherCS(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setCipherPreferredPositionCS(String name, int position) throws SshException
SshException
public void setCipherPreferredPositionSC(String name, int position) throws SshException
SshException
public void setMacPreferredPositionSC(String name, int position) throws SshException
SshException
public void setMacPreferredPositionCS(String name, int position) throws SshException
SshException
public void setPreferredMacSC(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredMacCS(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredCipherSC(String name) throws SshException
name
- SshException
public ComponentFactory supportedMacsSC()
public ComponentFactory supportedMacsCS()
public String getPreferredMacCS()
public void setPreferredMacCS(String name) throws SshException
name
- SshException
public String getPreferredMacSC()
public void setPreferredMacSC(String name) throws SshException
name
- SshException
public ComponentFactory supportedCompressionsSC()
public ComponentFactory supportedCompressionsCS()
public String getPreferredCompressionCS()
public void setPreferredCompressionCS(String name) throws SshException
name
- SshException
public String getPreferredCompressionSC()
public void setPreferredCompressionSC(String name) throws SshException
name
- SshException
public void enableCompression() throws SshException
SshException
public void disableCompression() throws SshException
SshException
public ComponentFactory supportedKeyExchanges()
public String getPreferredKeyExchange()
public void setPreferredKeyExchange(String name) throws SshException
name
- SshException
public ComponentFactory supportedPublicKeys()
public String getPreferredPublicKey()
public void setPreferredPublicKey(String name) throws SshException
name
- SshException
public void setHostKeyVerification(HostKeyVerification verify)
setHostKeyVerification
in interface SshContext
verify
- public HostKeyVerification getHostKeyVerification()
getHostKeyVerification
in interface SshContext
public void setSFTPProvider(String sftpProvider)
SshContext
setSFTPProvider
in interface SshContext
public String getSFTPProvider()
SshContext
getSFTPProvider
in interface SshContext
public void setPartialMessageTimeout(int partialMessageTimeout)
public int getPartialMessageTimeout()
public boolean isKeyReExchangeDisabled()
public void setKeyReExchangeDisabled(boolean keyReExchangeDisabled)
public void setPublicKeyPreferredPosition(String name, int position) throws SshException
SshException
public void setKeyExchangePreferredPosition(String name, int position) throws SshException
SshException
public int getIdleConnectionTimeoutSeconds()
public void setIdleConnectionTimeoutSeconds(int idleConnectionTimeoutSeconds)
public boolean isDHGroupExchangeBackwardsCompatible()
public int getDHGroupExchangeKeySize()
public void setDHGroupExchangeKeySize(int dhGroupExchangeKeySize)
public void setDHGroupExchangeBackwardsCompatible(boolean dhGroupExchangeBackwardCompatible)
public boolean isSendIgnorePacketOnIdle()
public void setSendIgnorePacketOnIdle(boolean sendIgnorePacketOnIdle)
public int getKeepAliveMaxDataLength()
public void setKeepAliveMaxDataLength(int keepAliveMaxDataLength)
public int getSocketTimeout()
public void setSocketTimeout(int socketTimeout)
public void enableFIPSMode() throws SshException
SshContext
enableFIPSMode
in interface SshContext
SshException
Copyright © 2014. All rights reserved.