authentication = authManager.getNextAuthentication(ISVNAuthenticationManager.SSH, realm);
if (e.getMessage() != null && e.getMessage().toLowerCase().indexOf("Auth") >= 0) { authentication = authManager.getNextAuthentication(ISVNAuthenticationManager.SSH, realm); if (authentication == null) { throw new SVNCancelException(); } } else { throw e; }
    public void open(SVNRepositoryImpl repository) throws SVNException {        ISVNAuthenticationManager authManager = repository.getAuthenticationManager();        String realm = repository.getLocation().getProtocol() + "://" + repository.getLocation().getHost() + ":" + repository.getLocation().getPort();        SVNAuthentication authentication = authManager.getFirstAuthentication(ISVNAuthenticationManager.SSH, realm);        if (authentication == null) {            throw new SVNAuthenticationException();        }        SVNAuthenticationException lastException = null;        Session session = null;                while (authentication != null) {            try {            	session = SVNJSchSession.getSession(repository.getLocation(), authentication);            	if (session != null && !session.isConnected()) {            		session = null;            		continue;            	}                lastException = null;                if (authentication.isStorageAllowed()) {                    authManager.addAuthentication(realm, authentication, authManager.isAuthStorageEnabled());                }                repository.setExternalUserName(authentication.getUserName());                break;            } catch (SVNAuthenticationException e) {                if (session != null && session.isConnected()) {            		DebugLog.log("DISCONNECTING: " + session);            		session.disconnect();            		session = null;            	}                lastException = e;                authentication = authManager.getNextAuthentication(ISVNAuthenticationManager.SSH, realm);            }        }        if (lastException != null || session == null) {            if (lastException != null) {                throw lastException;            }            throw new SVNAuthenticationException("Can't establish SSH connection without credentials");        }        try {            int retry = 1;            while(true) {	            myChannel = (ChannelExec) session.openChannel(CHANNEL_TYPE);	            String command = SVNSERVE_COMMAND;	            myChannel.setCommand(command);	            	            myOutputStream = myChannel.getOutputStream();	            myInputStream = myChannel.getInputStream();		            DebugLog.log("JSCH command: " + command);            	try {		            myChannel.connect();            	} catch (JSchException e) {            		retry--;            		if (retry < 0) {            			throw new SVNException(e);            		}            		if (session.isConnected()) {            			session.disconnect();            		}            		continue;            	}	            break;            }        } catch (Throwable e) {        	close();        	if (session.isConnected()) {        		session.disconnect();        	}            throw new SVNException("Failed to open SSH session: " + e.getMessage());        }        		myInputStream = new FilterInputStream(myInputStream) {			public void close() {            }		};		myOutputStream = new FilterOutputStream(myOutputStream) {			public void close() {            }		};    }