use of org.netbeans.lib.cvsclient.util.LoggedDataInputStream in project maven-scm by apache.
the class ExtConnection method open.
/**
* {@inheritDoc}
*/
public void open() throws AuthenticationException, CommandAbortedException {
connection = new Connection(host, port);
try {
// TODO: connection timeout?
connection.connect();
} catch (IOException e) {
String message = "Cannot connect. Reason: " + e.getMessage();
throw new AuthenticationException(message, e, message);
}
File privateKey = getPrivateKey();
try {
boolean authenticated;
if (privateKey != null && privateKey.exists()) {
authenticated = connection.authenticateWithPublicKey(userName, privateKey, getPassphrase());
} else {
authenticated = connection.authenticateWithPassword(userName, password);
}
if (!authenticated) {
String message = "Authentication failed.";
throw new AuthenticationException(message, message);
}
} catch (IOException e) {
closeConnection();
String message = "Cannot authenticate. Reason: " + e.getMessage();
throw new AuthenticationException(message, e, message);
}
try {
session = connection.openSession();
} catch (IOException e) {
String message = "Cannot open session. Reason: " + e.getMessage();
throw new CommandAbortedException(message, message);
}
String command = "cvs server";
try {
session.execCommand(command);
} catch (IOException e) {
String message = "Cannot execute remote command: " + command;
throw new CommandAbortedException(message, message);
}
InputStream stdout = new StreamGobbler(session.getStdout());
InputStream stderr = new StreamGobbler(session.getStderr());
stderrReader = new BufferedReader(new InputStreamReader(stderr));
setInputStream(new LoggedDataInputStream(stdout));
setOutputStream(new LoggedDataOutputStream(session.getStdin()));
}
Aggregations