Search in sources :

Example 6 with NamedFactory

use of org.apache.sshd.common.NamedFactory in project gerrit by GerritCodeReview.

the class SshDaemon method initCiphers.

@SuppressWarnings("unchecked")
private void initCiphers(final Config cfg) {
    final List<NamedFactory<Cipher>> a = BaseBuilder.setUpDefaultCiphers(true);
    for (Iterator<NamedFactory<Cipher>> i = a.iterator(); i.hasNext(); ) {
        final NamedFactory<Cipher> f = i.next();
        try {
            final Cipher c = f.create();
            final byte[] key = new byte[c.getBlockSize()];
            final byte[] iv = new byte[c.getIVSize()];
            c.init(Cipher.Mode.Encrypt, key, iv);
        } catch (InvalidKeyException e) {
            sshDaemonLog.warn("Disabling cipher " + f.getName() + ": " + e.getMessage() + "; try installing unlimited cryptography extension");
            i.remove();
        } catch (Exception e) {
            sshDaemonLog.warn("Disabling cipher " + f.getName() + ": " + e.getMessage());
            i.remove();
        }
    }
    a.add(null);
    setCipherFactories(filter(cfg, "cipher", (NamedFactory<Cipher>[]) a.toArray(new NamedFactory<?>[a.size()])));
}
Also used : NamedFactory(org.apache.sshd.common.NamedFactory) Cipher(org.apache.sshd.common.cipher.Cipher) InvalidKeyException(java.security.InvalidKeyException) InvalidKeyException(java.security.InvalidKeyException) JSchException(com.jcraft.jsch.JSchException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

NamedFactory (org.apache.sshd.common.NamedFactory)6 Command (org.apache.sshd.server.Command)4 ScpCommandFactory (org.apache.sshd.server.command.ScpCommandFactory)4 ServerSession (org.apache.sshd.server.session.ServerSession)4 IOException (java.io.IOException)3 PublicKey (java.security.PublicKey)2 FileKeyPairProvider (org.apache.sshd.common.keyprovider.FileKeyPairProvider)2 PasswordAuthenticator (org.apache.sshd.server.PasswordAuthenticator)2 PublickeyAuthenticator (org.apache.sshd.server.PublickeyAuthenticator)2 SimpleGeneratorHostKeyProvider (org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider)2 ChannelSftp (com.jcraft.jsch.ChannelSftp)1 JSch (com.jcraft.jsch.JSch)1 JSchException (com.jcraft.jsch.JSchException)1 Session (com.jcraft.jsch.Session)1 File (java.io.File)1 UnknownHostException (java.net.UnknownHostException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 FtpServerFactory (org.apache.ftpserver.FtpServerFactory)1