Search in sources :

Example 1 with BouncyCastleGeneratorHostKeyProvider

use of org.apache.sshd.common.util.security.bouncycastle.BouncyCastleGeneratorHostKeyProvider in project tomee by apache.

the class SSHServer method start.

@Override
public void start() throws ServiceException {
    sshServer = SshServer.setUpDefaultServer();
    sshServer.setPort(port);
    sshServer.setHost(bind);
    final String basePath = SystemInstance.get().getBase().getDirectory().getAbsolutePath();
    if (SecurityUtils.isBouncyCastleRegistered()) {
        sshServer.setKeyPairProvider(new BouncyCastleGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".pem").toPath()));
    } else {
        sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".ser").toPath()));
    }
    final OpenEJBShellFactory sf = new OpenEJBShellFactory(bind, port);
    sshServer.setShellFactory(sf);
    final JaasPasswordAuthenticator authenticator = new OpenEJBJaasPasswordAuthenticator();
    authenticator.setDomain(domain);
    sshServer.setPasswordAuthenticator(authenticator);
    try {
        sshServer.start();
    } catch (IOException e) {
    // no-op
    }
}
Also used : SimpleGeneratorHostKeyProvider(org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider) JaasPasswordAuthenticator(org.apache.sshd.server.jaas.JaasPasswordAuthenticator) IOException(java.io.IOException) File(java.io.File) BouncyCastleGeneratorHostKeyProvider(org.apache.sshd.common.util.security.bouncycastle.BouncyCastleGeneratorHostKeyProvider)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 BouncyCastleGeneratorHostKeyProvider (org.apache.sshd.common.util.security.bouncycastle.BouncyCastleGeneratorHostKeyProvider)1 JaasPasswordAuthenticator (org.apache.sshd.server.jaas.JaasPasswordAuthenticator)1 SimpleGeneratorHostKeyProvider (org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider)1