Search in sources :

Example 1 with JaasPasswordAuthenticator

use of org.apache.sshd.server.jaas.JaasPasswordAuthenticator 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
    }
}
Also used : SimpleGeneratorHostKeyProvider(org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider) JaasPasswordAuthenticator(org.apache.sshd.server.jaas.JaasPasswordAuthenticator) IOException(java.io.IOException) File(java.io.File) PEMGeneratorHostKeyProvider(org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 JaasPasswordAuthenticator (org.apache.sshd.server.jaas.JaasPasswordAuthenticator)1 PEMGeneratorHostKeyProvider (org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider)1 SimpleGeneratorHostKeyProvider (org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider)1