if (isMSCapi(sslClientCert)) {
String alias = null;
if (sslClientCert.lastIndexOf(';') > 0) {
alias = sslClientCert.substring(sslClientCert.lastIndexOf(';') + 1);
}
return new SVNSSLAuthentication(SVNSSLAuthentication.MSCAPI, alias, authMayBeStored, url, false);
}
String sslClientCertPassword = (String) properties.get("ssl-client-cert-password");
File clientCertFile = sslClientCert != null ? new Resource(sslClientCert) : null;
return new SVNSSLAuthentication(clientCertFile, sslClientCertPassword, authMayBeStored, url, false);
}
//try looking in svn.ssl.client-passphrase directory cache
}
File dir = new Resource(myDirectory, kind);
if (!dir.isDirectory()) {
return null;
}
String fileName = SVNFileUtil.computeChecksum(realm);
File authFile = new Resource(dir, fileName);
if (authFile.exists()) {
SVNWCProperties props = new SVNWCProperties(authFile, "");
try {
SVNProperties values = props.asMap();
String storedRealm = values.getStringValue("svn:realmstring");
String cipherType = SVNPropertyValue.getPropertyAsString(values.getSVNPropertyValue("passtype"));
if (cipherType != null && !SVNPasswordCipher.hasCipher(cipherType)) {
return null;
}
SVNPasswordCipher cipher = SVNPasswordCipher.getInstance(cipherType);
if (storedRealm == null || !storedRealm.equals(realm)) {
return null;
}
String userName = SVNPropertyValue.getPropertyAsString(values.getSVNPropertyValue("username"));
if (!ISVNAuthenticationManager.SSL.equals(kind)) {
if (userName == null || "".equals(userName.trim())) {
return null;
}
if (myUserName != null && !myUserName.equals(userName)) {
return null;
}
}
String password = SVNPropertyValue.getPropertyAsString(values.getSVNPropertyValue("password"));
password = cipher.decrypt(password);
String path = SVNPropertyValue.getPropertyAsString(values.getSVNPropertyValue("key"));
String passphrase = SVNPropertyValue.getPropertyAsString(values.getSVNPropertyValue("passphrase"));
passphrase = cipher.decrypt(passphrase);
String port = SVNPropertyValue.getPropertyAsString(values.getSVNPropertyValue("port"));
port = port == null ? ("" + getDefaultSSHPortNumber()) : port;
String sslKind = SVNPropertyValue.getPropertyAsString(values.getSVNPropertyValue("ssl-kind"));
if (ISVNAuthenticationManager.PASSWORD.equals(kind)) {
if (password == null) {
return new SVNPasswordAuthentication(userName, password, authMayBeStored, null, true);
}
return new SVNPasswordAuthentication(userName, password, authMayBeStored, url, false);
} else if (ISVNAuthenticationManager.SSH.equals(kind)) {
// get port from config file or system property?
int portNumber;
try {
portNumber = Integer.parseInt(port);
} catch (NumberFormatException nfe) {
portNumber = getDefaultSSHPortNumber();
}
if (path != null) {
return new SVNSSHAuthentication(userName, new Resource(path), passphrase, portNumber, authMayBeStored, url, false);
} else if (password != null) {
return new SVNSSHAuthentication(userName, password, portNumber, authMayBeStored, url, false);
}
} else if (ISVNAuthenticationManager.USERNAME.equals(kind)) {
return new SVNUserNameAuthentication(userName, authMayBeStored, url, false);
} else if (ISVNAuthenticationManager.SSL.equals(kind)) {
if (isMSCapi(sslKind)) {
String alias = SVNPropertyValue.getPropertyAsString(values.getSVNPropertyValue("alias"));
return new SVNSSLAuthentication(SVNSSLAuthentication.MSCAPI, alias, authMayBeStored, url, false);
}
return new SVNSSLAuthentication(new Resource(path), passphrase, authMayBeStored, url, false);
}
} catch (SVNException e) {
//
}
}