com.maverick.sshd
Class SshContextFactory

java.lang.Object
  extended by com.maverick.sshd.SshContextFactory
All Implemented Interfaces:
ProtocolContextFactory<SshContext>

public abstract class SshContextFactory
extends Object
implements ProtocolContextFactory<SshContext>


Constructor Summary
SshContextFactory()
           
SshContextFactory(ServerComponentManager componentManager, com.maverick.ssh.components.SshKeyPair... keys)
           
SshContextFactory(com.maverick.ssh.components.SshKeyPair... keys)
           
 
Method Summary
 void configureAcceptorCodec(org.apache.mina.core.service.IoAcceptor acceptor, DaemonContext<SshContext> daemonContext)
           
 void configureAcceptorHandler(org.apache.mina.core.service.IoAcceptor acceptor, DaemonContext<SshContext> daemonContext)
           
 void configureAcceptorPreCodec(org.apache.mina.core.service.IoAcceptor acceptor, DaemonContext<SshContext> daemonContext)
           
 void configureAcceptorPreHandler(org.apache.mina.core.service.IoAcceptor acceptor, DaemonContext<SshContext> daemonContext)
           
abstract  SshContext createContext(SocketAddress remoteAddress, SocketAddress localAddress)
           
protected  SshContext createDefaultContext()
           
static com.maverick.ssh.components.SshKeyPair GenerateKeyFiles(File keyFilename, String type, int bitlength, int privateKeyFormat, int publicKeyFormat)
          Generate a public and private key pair, save them to keyFilename and keyFilename.pub, return the key pair
 void loadHostKey(InputStream in, String type, int bitlength)
           
 void loadHostKey(InputStream in, String type, int bitlength, int privateKeyFormat, int publicKeyFormat, String passPhrase)
           
 void loadHostKey(InputStream in, String type, int bitlength, String passPhrase)
           
 com.maverick.ssh.components.SshKeyPair loadKey(File key, String passphrase)
           
 com.maverick.ssh.components.SshKeyPair loadKey(InputStream in, String passphrase)
           
 void loadOrGenerateHostKey(File key, String type, int bitlength)
          Load a host key from file, if the file does not exist then generate the key.
 void loadOrGenerateHostKey(File key, String type, int bitlength, int privateKeyFormat, int publicKeyFormat, String passPhrase)
          Load a host key from file, if the file does not exist then generate the key.
 void loadOrGenerateHostKey(File key, String type, int bitlength, String passPhrase)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SshContextFactory

public SshContextFactory()
                  throws IOException,
                         com.maverick.ssh.SshException
Throws:
IOException
com.maverick.ssh.SshException

SshContextFactory

public SshContextFactory(com.maverick.ssh.components.SshKeyPair... keys)
                  throws IOException,
                         com.maverick.ssh.SshException
Throws:
IOException
com.maverick.ssh.SshException

SshContextFactory

public SshContextFactory(ServerComponentManager componentManager,
                         com.maverick.ssh.components.SshKeyPair... keys)
                  throws IOException,
                         com.maverick.ssh.SshException
Throws:
IOException
com.maverick.ssh.SshException
Method Detail

configureAcceptorPreCodec

public void configureAcceptorPreCodec(org.apache.mina.core.service.IoAcceptor acceptor,
                                      DaemonContext<SshContext> daemonContext)
Specified by:
configureAcceptorPreCodec in interface ProtocolContextFactory<SshContext>

configureAcceptorCodec

public final void configureAcceptorCodec(org.apache.mina.core.service.IoAcceptor acceptor,
                                         DaemonContext<SshContext> daemonContext)
Specified by:
configureAcceptorCodec in interface ProtocolContextFactory<SshContext>

configureAcceptorPreHandler

public void configureAcceptorPreHandler(org.apache.mina.core.service.IoAcceptor acceptor,
                                        DaemonContext<SshContext> daemonContext)
Specified by:
configureAcceptorPreHandler in interface ProtocolContextFactory<SshContext>

configureAcceptorHandler

public final void configureAcceptorHandler(org.apache.mina.core.service.IoAcceptor acceptor,
                                           DaemonContext<SshContext> daemonContext)
Specified by:
configureAcceptorHandler in interface ProtocolContextFactory<SshContext>

createContext

public abstract SshContext createContext(SocketAddress remoteAddress,
                                         SocketAddress localAddress)
                                  throws IOException
Specified by:
createContext in interface ProtocolContextFactory<SshContext>
Throws:
IOException

createDefaultContext

protected SshContext createDefaultContext()
                                   throws IOException
Throws:
IOException

loadOrGenerateHostKey

public void loadOrGenerateHostKey(File key,
                                  String type,
                                  int bitlength)
                           throws IOException,
                                  com.sshtools.publickey.InvalidPassphraseException,
                                  com.maverick.ssh.SshException
Load a host key from file, if the file does not exist then generate the key.

Parameters:
key - the key file
type - the type of key; acceptable values are SshKeyPairGenerator.SSH2_RSA or SshKeyPairGenerator.SSH2_DSA
bitlength - the bit length of the key
Throws:
IOException
com.maverick.ssh.SshException
com.sshtools.publickey.InvalidPassphraseException

loadOrGenerateHostKey

public void loadOrGenerateHostKey(File key,
                                  String type,
                                  int bitlength,
                                  String passPhrase)
                           throws IOException,
                                  com.sshtools.publickey.InvalidPassphraseException,
                                  com.maverick.ssh.SshException
Throws:
IOException
com.sshtools.publickey.InvalidPassphraseException
com.maverick.ssh.SshException

loadHostKey

public void loadHostKey(InputStream in,
                        String type,
                        int bitlength)
                 throws IOException,
                        com.sshtools.publickey.InvalidPassphraseException,
                        com.maverick.ssh.SshException
Throws:
IOException
com.sshtools.publickey.InvalidPassphraseException
com.maverick.ssh.SshException

loadHostKey

public void loadHostKey(InputStream in,
                        String type,
                        int bitlength,
                        String passPhrase)
                 throws IOException,
                        com.sshtools.publickey.InvalidPassphraseException,
                        com.maverick.ssh.SshException
Throws:
IOException
com.sshtools.publickey.InvalidPassphraseException
com.maverick.ssh.SshException

loadOrGenerateHostKey

public void loadOrGenerateHostKey(File key,
                                  String type,
                                  int bitlength,
                                  int privateKeyFormat,
                                  int publicKeyFormat,
                                  String passPhrase)
                           throws IOException,
                                  com.sshtools.publickey.InvalidPassphraseException,
                                  com.maverick.ssh.SshException
Load a host key from file, if the file does not exist then generate the key.

Parameters:
key - the key file
type - the type of key; acceptable values are SshKeyPairGenerator.SSH2_RSA or SshKeyPairGenerator.SSH2_DSA
bitlength - the bit length of the key
privateKeyFormat - the format of the private key, SshPrivateKeyFileFactory
publicKeyFormat - the format of the public key, {see com.sshtools.publickey.SshPublicKeyFileFactory}
passPhrase - the passPhrase of an existing host key
Throws:
IOException
com.maverick.ssh.SshException
com.sshtools.publickey.InvalidPassphraseException

loadHostKey

public void loadHostKey(InputStream in,
                        String type,
                        int bitlength,
                        int privateKeyFormat,
                        int publicKeyFormat,
                        String passPhrase)
                 throws IOException,
                        com.sshtools.publickey.InvalidPassphraseException,
                        com.maverick.ssh.SshException
Throws:
IOException
com.sshtools.publickey.InvalidPassphraseException
com.maverick.ssh.SshException

loadKey

public com.maverick.ssh.components.SshKeyPair loadKey(File key,
                                                      String passphrase)
                                               throws IOException,
                                                      com.sshtools.publickey.InvalidPassphraseException
Throws:
IOException
com.sshtools.publickey.InvalidPassphraseException

loadKey

public com.maverick.ssh.components.SshKeyPair loadKey(InputStream in,
                                                      String passphrase)
                                               throws IOException,
                                                      com.sshtools.publickey.InvalidPassphraseException
Throws:
IOException
com.sshtools.publickey.InvalidPassphraseException

GenerateKeyFiles

public static com.maverick.ssh.components.SshKeyPair GenerateKeyFiles(File keyFilename,
                                                                      String type,
                                                                      int bitlength,
                                                                      int privateKeyFormat,
                                                                      int publicKeyFormat)
                                                               throws IOException,
                                                                      com.maverick.ssh.SshException
Generate a public and private key pair, save them to keyFilename and keyFilename.pub, return the key pair

Parameters:
keyFilename -
type -
bitlength -
privateKeyFormat -
publicKeyFormat -
Returns:
SshKeyPair generated.
Throws:
IOException
com.maverick.ssh.SshException


Copyright © 2012. All Rights Reserved.