agave-systems/systems-core/src/main/java/org/iplantc/service/transfer/sftp/SftpRelay.java
/**
     * Looks through the supported auth returned from the server and overrides the
     * password auth type if the server only lists keyboard-interactive. This acts
     * as a frontline check to override the default behavior and use our
     * {@link MultiFactorKBIRequestHandler}.
     *
     * @param authenticationMethods
     * @return a {@link SshAuthentication} based on the ordering and existence of auth methods returned from the server.
     */
Looks through the supported auth returned from the server and overrides the
password auth type if the server only lists keyboard-interactive. This acts
as a frontline check to override the default behavior and use our
MultiFactorKBIRequestHandler.

@param authenticationMethods
@return a  SshAuthentication based on the ordering and existence of auth methods returned from the server.
Looks through the supported auth returned from the server and overrides the password auth type if the server only lists keyboard - interactive . This acts as a frontline check to override the default behavior and use our MultiFactorKBIRequestHandler . @param authenticationMethods @return a SshAuthentication based on the ordering and existence of auth methods returned from the server .
private static SshAuthentication checkForPasswordOverKBI(SshAuthentication existingAuth, String[] authenticationMethods, String username,
                                                             String password, String host, int port) {
        SshAuthentication retAuth = existingAuth;
        boolean kbiAuthenticationPossible = false;
        for (String authMethod : authenticationMethods) {
            if (authMethod.equals("password")) {
                return retAuth;
            }
            if (authMethod.equals("keyboard-interactive")) {
                kbiAuthenticationPossible = true;
            }
        }
        if (kbiAuthenticationPossible) {
            KBIAuthentication kbi = new KBIAuthentication();
            kbi.setUsername(username);
            kbi.setKBIRequestHandler(new MultiFactorKBIRequestHandler(password, null, username, host, port));
            String msg = String.format("MultiFactorKBIRequestHandler created for user: %s host: %s port: %d", username, host, port);
            log.info(msg);
            return kbi;
        }
        return retAuth;
    }
private static SshAuthentication checkForPasswordOverKBI ( SshAuthentication existingAuth , String [ ] authenticationMethods , String username , String password , String host , int port ) { SshAuthentication retAuth = existingAuth ; boolean kbiAuthenticationPossible = false ; for ( String authMethod : authenticationMethods ) { if ( authMethod . equals ( "password" ) ) { return retAuth ; } if ( authMethod . equals ( "keyboard-interactive" ) ) { kbiAuthenticationPossible = true ; } } if ( kbiAuthenticationPossible ) { KBIAuthentication kbi = new KBIAuthentication ( ) ; kbi . setUsername ( username ) ; kbi . setKBIRequestHandler ( new MultiFactorKBIRequestHandler ( password , null , username , host , port ) ) ; String msg = String . format ( "MultiFactorKBIRequestHandler created for user: %s host: %s port: %d" , username , host , port ) ; log . info ( msg ) ; return kbi ; } return retAuth ; }
Looks through the supported auth returned from the server and overrides the
 password auth type if the server only lists keyboard-interactive.
Looks through the supported auth returned from the server and overrides the password auth type if the server only lists keyboard - interactive .
// MultiFactorKBIRequestHandler created for user: {0} host: {1} port: {2}