agave-systems/systems-core/src/main/java/org/iplantc/service/transfer/sftp/SftpRelay.java
/**
     * Create a Maverick SSH connector.
     *
     * @throws Exception
     */
Create a Maverick SSH connector.
@throws Exception
Create a Maverick SSH connector . @throws Exception
public static SshConnector createSshConnector(String msgPrefix)
            throws Exception {
        SshConnector retCon;
        try {
            retCon = SshConnector.createInstance();
        } catch (Exception e) {
            String msg = String.format("Unable to create SSH connector for %s : %s", msgPrefix, e.getMessage());
            log.error(msg);
            throw e;
        }
        JCEComponentManager cm;
        try {
            cm = (JCEComponentManager) ComponentManager.getInstance();
        } catch (Exception e) {
            String msg = String.format("Unable to create a component manager for %s : %s", msgPrefix, e.getMessage());
            log.error(msg);
            throw e;
        }
        cm.installArcFourCiphers(cm.supportedSsh2CiphersCS());
        cm.installArcFourCiphers(cm.supportedSsh2CiphersSC());
        try {
            Ssh2Context context = retCon.getContext();
            context.setPreferredKeyExchange(Ssh2Context.KEX_DIFFIE_HELLMAN_GROUP14_SHA1);
            context.setPreferredPublicKey(Ssh2Context.PUBLIC_KEY_SSHDSS);
            context.setPublicKeyPreferredPosition(Ssh2Context.PUBLIC_KEY_ECDSA_521, 1);
            context.setPreferredCipherCS(Ssh2Context.CIPHER_ARCFOUR_256);
            context.setCipherPreferredPositionCS(Ssh2Context.CIPHER_ARCFOUR, 1);
            context.setCipherPreferredPositionCS(Ssh2Context.CIPHER_AES128_CTR, 1);
            context.setPreferredCipherSC(Ssh2Context.CIPHER_ARCFOUR_256);
            context.setCipherPreferredPositionSC(Ssh2Context.CIPHER_ARCFOUR, 1);
            context.setCipherPreferredPositionCS(Ssh2Context.CIPHER_AES128_CTR, 1);
            context.setPreferredMacCS(Ssh2Context.HMAC_SHA256);
            context.setMacPreferredPositionCS(Ssh2Context.HMAC_SHA1, 1);
            context.setMacPreferredPositionCS(Ssh2Context.HMAC_MD5, 2);
            context.setPreferredMacSC(Ssh2Context.HMAC_SHA256);
            context.setMacPreferredPositionSC(Ssh2Context.HMAC_SHA1, 1);
            context.setMacPreferredPositionSC(Ssh2Context.HMAC_MD5, 2);
        } catch (Exception e) {
            String msg = String.format("Failure setting a cipher preference for %s : %s", msgPrefix, e.getMessage());
            log.error(msg);
            throw e;
        }
        return retCon;
    }
public static SshConnector createSshConnector ( String msgPrefix ) throws Exception { SshConnector retCon ; try { retCon = SshConnector . createInstance ( ) ; } catch ( Exception e ) { String msg = String . format ( "Unable to create SSH connector for %s : %s" , msgPrefix , e . getMessage ( ) ) ; log . error ( msg ) ; throw e ; } JCEComponentManager cm ; try { cm = ( JCEComponentManager ) ComponentManager . getInstance ( ) ; } catch ( Exception e ) { String msg = String . format ( "Unable to create a component manager for %s : %s" , msgPrefix , e . getMessage ( ) ) ; log . error ( msg ) ; throw e ; } cm . installArcFourCiphers ( cm . supportedSsh2CiphersCS ( ) ) ; cm . installArcFourCiphers ( cm . supportedSsh2CiphersSC ( ) ) ; try { Ssh2Context context = retCon . getContext ( ) ; context . setPreferredKeyExchange ( Ssh2Context . KEX_DIFFIE_HELLMAN_GROUP14_SHA1 ) ; context . setPreferredPublicKey ( Ssh2Context . PUBLIC_KEY_SSHDSS ) ; context . setPublicKeyPreferredPosition ( Ssh2Context . PUBLIC_KEY_ECDSA_521 , 1 ) ; context . setPreferredCipherCS ( Ssh2Context . CIPHER_ARCFOUR_256 ) ; context . setCipherPreferredPositionCS ( Ssh2Context . CIPHER_ARCFOUR , 1 ) ; context . setCipherPreferredPositionCS ( Ssh2Context . CIPHER_AES128_CTR , 1 ) ; context . setPreferredCipherSC ( Ssh2Context . CIPHER_ARCFOUR_256 ) ; context . setCipherPreferredPositionSC ( Ssh2Context . CIPHER_ARCFOUR , 1 ) ; context . setCipherPreferredPositionCS ( Ssh2Context . CIPHER_AES128_CTR , 1 ) ; context . setPreferredMacCS ( Ssh2Context . HMAC_SHA256 ) ; context . setMacPreferredPositionCS ( Ssh2Context . HMAC_SHA1 , 1 ) ; context . setMacPreferredPositionCS ( Ssh2Context . HMAC_MD5 , 2 ) ; context . setPreferredMacSC ( Ssh2Context . HMAC_SHA256 ) ; context . setMacPreferredPositionSC ( Ssh2Context . HMAC_SHA1 , 1 ) ; context . setMacPreferredPositionSC ( Ssh2Context . HMAC_MD5 , 2 ) ; } catch ( Exception e ) { String msg = String . format ( "Failure setting a cipher preference for %s : %s" , msgPrefix , e . getMessage ( ) ) ; log . error ( msg ) ; throw e ; } return retCon ; }
Create a Maverick SSH connector.
Create a Maverick SSH connector .
// Get a component manager. //Install some ciphers. // Set preferences