use of org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider 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 PEMGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".pem").getPath()));
} else {
sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File(basePath, KEY_NAME + ".ser").getPath()));
}
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
}
}
Aggregations