if (port < 0) {
port = 22;
}
boolean save = prompt4.userAllowedSave();
if (keyPath != null && !"".equals(keyPath)) {
return new SVNSSHAuthentication(userName, new File(keyPath), passphrase, port, save);
} else if (password != null){
return new SVNSSHAuthentication(userName, password, port, save);
}
}
return null;
} else if (ISVNAuthenticationManager.SSL.equals(kind) && myPrompt instanceof PromptUserPasswordSSL) {
PromptUserPasswordSSL prompt4 = (PromptUserPasswordSSL) myPrompt;
if (prompt4.promptSSL(realm, authMayBeStored)) {
String cert = prompt4.getSSLClientCertPath();
String password = prompt4.getSSLClientCertPassword();
if (cert != null) {
if ("".equals(password)) {
password = null;
}
boolean save = prompt4.userAllowedSave();
return new SVNSSLAuthentication(new File(cert), password, save);
}
}
return null;
}
if (ISVNAuthenticationManager.SSH.equals(kind) && previousAuth == null) {
// use configuration file here? but it was already used once...
String keyPath = System.getProperty("svnkit.ssh2.key", System.getProperty("javasvn.ssh2.key"));
String userName = getUserName(System.getProperty("svnkit.ssh2.username", System.getProperty("javasvn.ssh2.username")), url);
String passPhrase = System.getProperty("svnkit.ssh2.passphrase", System.getProperty("javasvn.ssh2.passphrase"));
if (userName == null) {
return null;
}
if (keyPath != null && previousAuth == null) {
// use port number from configuration file?
return new SVNSSHAuthentication(userName, new File(keyPath), passPhrase, -1, true);
}
// try to get password for ssh from the user.
} else if(ISVNAuthenticationManager.USERNAME.equals(kind)) {
String userName = previousAuth != null && previousAuth.getUserName() != null ? previousAuth.getUserName() : getUserName(null, url);
if (myPrompt instanceof PromptUserPasswordUser) {
PromptUserPasswordUser prompt3 = (PromptUserPasswordUser) myPrompt;
if (prompt3.promptUser(realm, userName, authMayBeStored)) {
return new SVNUserNameAuthentication(prompt3.getUsername(), prompt3.userAllowedSave());
}
return getDefaultUserNameCredentials(userName);
} else if (myPrompt instanceof PromptUserPassword3) {
PromptUserPassword3 prompt3 = (PromptUserPassword3) myPrompt;
if (prompt3.prompt(realm, userName, authMayBeStored)) {
return new SVNUserNameAuthentication(prompt3.getUsername(), prompt3.userAllowedSave());
}
return getDefaultUserNameCredentials(userName);
}
if (myPrompt.prompt(realm, userName)) {
return new SVNUserNameAuthentication(myPrompt.getUsername(), false);
}
return getDefaultUserNameCredentials(userName);
} else if(!ISVNAuthenticationManager.PASSWORD.equals(kind)){
return null;
}
String userName = previousAuth != null && previousAuth.getUserName() != null ? previousAuth.getUserName() : getUserName(null, url);
if (myPrompt instanceof PromptUserPassword3) {
PromptUserPassword3 prompt3 = (PromptUserPassword3) myPrompt;
if(prompt3.prompt(realm, userName, authMayBeStored)){
if (ISVNAuthenticationManager.SSH.equals(kind)) {
// use default port number from configuration file (should be in previous auth).
int portNumber = (previousAuth instanceof SVNSSHAuthentication) ? ((SVNSSHAuthentication) previousAuth).getPortNumber() : -1;
return new SVNSSHAuthentication(prompt3.getUsername(), prompt3.getPassword(), portNumber, prompt3.userAllowedSave());
}
return new SVNPasswordAuthentication(prompt3.getUsername(), prompt3.getPassword(), prompt3.userAllowedSave());
}
}else{
if(myPrompt.prompt(realm, userName)){
if (ISVNAuthenticationManager.SSH.equals(kind)) {
return new SVNSSHAuthentication(userName, myPrompt.getPassword(), -1, true);
}
return new SVNPasswordAuthentication(myPrompt.getUsername(), myPrompt.getPassword(), true);
}
}
return null;