2 * Copyright 2000-2018 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.jetbrains.git4idea.ssh;
19 import org.jetbrains.annotations.NonNls;
20 import org.jetbrains.annotations.Nullable;
22 import java.util.Vector;
25 * An interface for GIT SSH handler
27 public interface GitSSHHandler {
29 * The prefix of the ssh script name
31 @NonNls String GIT_SSH_PREFIX = "git-ssh-";
33 * Name of environment variable for SSH handler number
35 @NonNls String SSH_HANDLER_ENV = "GIT4IDEA_SSH_HANDLER";
37 * Name of environment variable for SSH handler number
39 @NonNls String SSH_IGNORE_KNOWN_HOSTS_ENV = "GIT4IDEA_SSH_IGNORE_KNOWN_HOSTS";
41 * Name of environment variable for SSH handler
43 @NonNls String SSH_PORT_ENV = "GIT4IDEA_SSH_PORT";
45 * Name of environment variable for SSH executable
47 @NonNls String GIT_SSH_ENV = "GIT_SSH";
51 @NonNls String HANDLER_NAME = "Git4ideaSSHHandler";
53 String TEAMCITY_PRIVATE_KEY_PATH = "TEAMCITY_PRIVATE_KEY";
54 String TEAMCITY_PASSPHRASE = "TEAMCITY_PASSPHRASE";
55 String TEAMCITY_DEBUG_SSH = "TEAMCITY_DEBUG_SSH";
56 String TEAMCITY_SSH_MAC_TYPE = "TEAMCITY_SSH_MAC_TYPE";
57 String TEAMCITY_SSH_PREFERRED_AUTH_METHODS = "TEAMCITY_SSH_PREFERRED_AUTH_METHODS";
58 String TEAMCITY_VERSION = "TEAMCITY_VERSION";
61 * Verify server host key
63 * @param handler a handler identifier
64 * @param hostName a host name
65 * @param port a port number
66 * @param serverHostKeyAlgorithm an algorithm
67 * @param serverHostKeyFingerprint a key fingerprint
68 * @param isNew true if the key is a new, false if the key was changed
69 * @return true the host is verified, false otherwise
71 boolean verifyServerHostKey(int handler,
74 String serverHostKeyAlgorithm,
75 String serverHostKeyFingerprint,
79 * Ask passphrase for the key
81 * @param handler a handler identifier
82 * @param userName a name of user
83 * @param keyPath a path for the key
84 * @param resetPassword a reset password if one was stored in password database
85 * @param lastError a last error (or empty string)
86 * @return the passphrase entered by the user
89 String askPassphrase(final int handler, final String userName, final String keyPath, boolean resetPassword, final String lastError);
92 * Reply to challenge for keyboard-interactive method. Also used for
94 * @param handlerNo a handler identifier
95 * @param userName a user name (includes host and port)
96 * @param name name of challenge
97 * @param instruction instruction
98 * @param numPrompts amount of prompts
99 * @param prompt prompts
100 * @param echo whether the reply should be echoed (boolean values represented as string due to XML RPC limitation)
101 * @param lastError the last error from the challenge
102 * @return a list or replies to challenges (the size should be equal to the number of prompts)
104 @SuppressWarnings({"UseOfObsoleteCollectionType"})
106 Vector<String> replyToChallenge(final int handlerNo,
107 final String userName,
109 final String instruction,
110 final int numPrompts,
111 final Vector<String> prompt,
112 final Vector<Boolean> echo,
113 final String lastError);
116 * Ask password for the specified user name
118 * @param handlerNo a handler identifier
119 * @param userName a name of user to ask password for
120 * @param resetPassword a reset password if one was stored in password database
121 * @param lastError a last error
122 * @return the password or null if authentication failed.
125 String askPassword(final int handlerNo, final String userName, boolean resetPassword, final String lastError);