Package com.sonymobile.tools.gerrit.gerritevents.ssh

Examples of com.sonymobile.tools.gerrit.gerritevents.ssh.SshConnection


                password = gerritAuthKeyFilePassword;
            }
            if (SshUtil.checkPassPhrase(file, password)) {
                if (file.exists() && file.isFile()) {
                    try {
                        final SshConnection sshConnection = SshConnectionFactory.getConnection(
                                gerritHostName,
                                gerritSshPort,
                                gerritProxy,
                                new Authentication(file, gerritUserName, password));
                        ExecutorService service = Executors.newFixedThreadPool(THREADS_FOR_TEST_CONNECTION);
                        Future<Integer> future = service.submit(new Callable<Integer>() {
                            @Override
                            public Integer call() throws Exception {
                                return sshConnection.executeCommandReader(GerritConnection.CMD_STREAM_EVENTS).read();
                            }
                        });
                        int readChar;
                        try {
                            readChar = future.get(TIMEOUT_FOR_TEST_CONNECTION, TimeUnit.SECONDS);
                        } catch (TimeoutException ex) {
                            readChar = 0;
                        } finally {
                            sshConnection.disconnect();
                        }
                        if (readChar < 0) {
                            return FormValidation.error(Messages.StreamEventsCapabilityException(gerritUserName));
                        } else {
                            return FormValidation.ok(Messages.Success());
View Full Code Here


    public void run() {
        while (!shutdown) {
            try {
                if (isConnected()) {
                    IGerritHudsonTriggerConfig activeConfig = getConfig();
                    SshConnection sshConnection = SshConnectionFactory.getConnection(
                            activeConfig.getGerritHostName(),
                            activeConfig.getGerritSshPort(),
                            activeConfig.getGerritProxy(),
                            activeConfig.getGerritAuthentication()
                    );
                    setGerritProjects(readProjects(sshConnection.executeCommandReader(GERRIT_LS_PROJECTS)));
                    sshConnection.disconnect();
                }
            } catch (SshException ex) {
                 logger.warn("Could not connect to Gerrit server when updating Gerrit project list: ", ex);
            } catch (IOException ex) {
                logger.error("Could not read stream with Gerrit projects: ", ex);
View Full Code Here

TOP

Related Classes of com.sonymobile.tools.gerrit.gerritevents.ssh.SshConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.