| | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.List; |
| | | |
| | | import com.gitblit.transport.ssh.IKeyManager; |
| | | import com.gitblit.transport.ssh.CachingPublicKeyAuthenticator; |
| | | import com.gitblit.transport.ssh.IPublicKeyManager; |
| | | import com.gitblit.transport.ssh.SshKey; |
| | | import com.gitblit.transport.ssh.commands.SshCommand; |
| | | import com.google.common.base.Charsets; |
| | | |
| | |
| | | protected List<String> readKeys(List<String> sshKeys) |
| | | throws UnsupportedEncodingException, IOException { |
| | | int idx = -1; |
| | | if (sshKeys.isEmpty() || ((idx = sshKeys.indexOf("-")) >= 0)) { |
| | | if ((idx = sshKeys.indexOf("-")) >= 0) { |
| | | String sshKey = ""; |
| | | BufferedReader br = new BufferedReader(new InputStreamReader( |
| | | in, Charsets.UTF_8)); |
| | |
| | | return sshKeys; |
| | | } |
| | | |
| | | protected CachingPublicKeyAuthenticator authenticator; |
| | | public void setAuthenticator(CachingPublicKeyAuthenticator authenticator) { |
| | | this.authenticator = authenticator; |
| | | protected IPublicKeyManager getKeyManager() { |
| | | return getContext().getGitblit().getPublicKeyManager(); |
| | | } |
| | | |
| | | protected IKeyManager getKeyManager() { |
| | | return authenticator.getKeyManager(); |
| | | |
| | | protected SshKey parseKey(String rawData) throws UnloggedFailure { |
| | | if (rawData.contains("PRIVATE")) { |
| | | throw new UnloggedFailure(1, "Please provide a PUBLIC key, not a PRIVATE key!"); |
| | | } |
| | | SshKey key = new SshKey(rawData); |
| | | return key; |
| | | } |
| | | } |