Search in sources :

Example 1 with InputStreamWrapper

use of com.intellij.cvsSupport2.javacvsImpl.io.InputStreamWrapper in project intellij-community by JetBrains.

the class ExtConnection method check.

@SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed" })
private void check(ICvsCommandStopper stopper, String expectedResult) throws IOException, AuthenticationException {
    InputStreamWrapper streamWrapper = new InputStreamWrapper(myInputStream, stopper, new ReadWriteStatistics());
    try {
        StringBuilder buffer = new StringBuilder();
        while (true) {
            int i = streamWrapper.read();
            if (i == -1 || i == '\n' || i == ' ' || i == '\r')
                break;
            buffer.append((char) i);
        }
        String read = buffer.toString().trim();
        if (!expectedResult.equals(read)) {
            if (StringUtil.startsWithConcatenation(read, myUserName, "@", myHost)) {
                throw new AuthenticationException(CvsBundle.message("exception.text.ext.server.rejected.access"), null);
            } else {
                if (myErrorText.length() > 0) {
                    throw new AuthenticationException(myErrorText.toString(), null);
                } else {
                    throw new AuthenticationException(CvsBundle.message("exception.text.ext.cannot.establish.external.connection"), null);
                }
            }
        }
    } finally {
        streamWrapper.close();
    }
}
Also used : InputStreamWrapper(com.intellij.cvsSupport2.javacvsImpl.io.InputStreamWrapper) AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) ReadWriteStatistics(com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics)

Aggregations

InputStreamWrapper (com.intellij.cvsSupport2.javacvsImpl.io.InputStreamWrapper)1 ReadWriteStatistics (com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics)1 AuthenticationException (org.netbeans.lib.cvsclient.connection.AuthenticationException)1