@Override public synchronized Locations getLocations(String application, String profile, String label) { if (label == null) { label = this.defaultLabel; } SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); if (hasText(getUsername())) { svnOperationFactory .setAuthenticationManager(new DefaultSVNAuthenticationManager(null, false, getUsername(), getPassword())); } try { String version; if (new File(getWorkingDirectory(), ".svn").exists()) { version = update(svnOperationFactory, label); } else { version = checkout(svnOperationFactory); } return new Locations(application, profile, label, version, getPaths(application, profile, label)); } catch (SVNException e) { throw new IllegalStateException("Cannot checkout repository", e); } finally { svnOperationFactory.dispose(); } }
public boolean isSSLPassphrasePromtSupported() { if (getAuthenticationProvider() == null) { return true; } else if (getAuthenticationProvider() instanceof ISVNSSLPasspharsePromptSupport) { return ((ISVNSSLPasspharsePromptSupport) getAuthenticationProvider()).isSSLPassphrasePromtSupported(); } return false; }
@Override public void acknowledgeAuthentication(boolean accepted, String kind, String realm, SVNErrorMessage errorMessage, SVNAuthentication authentication) throws SVNException { realms[0] = realm; super.acknowledgeAuthentication(accepted, kind, realm, errorMessage, authentication); } });
public DefaultSVNAuthenticationManager(File configDirectory, boolean storeAuth, String userName, String password, File privateKey, String passphrase) { password = password == null ? "" : password; myIsStoreAuth = storeAuth; myConfigDirectory = configDirectory; if (myConfigDirectory == null) { myConfigDirectory = SVNWCUtil.getDefaultConfigurationDirectory(); } myProviders = new ISVNAuthenticationProvider[4]; myProviders[0] = createDefaultAuthenticationProvider(userName, password, privateKey, passphrase, myIsStoreAuth); myProviders[1] = createRuntimeAuthenticationProvider(); myProviders[2] = createCacheAuthenticationProvider(new File(myConfigDirectory, "auth")); }
public void checkServerTrusted(X509Certificate[] certs, String algorithm) throws CertificateException { if (certs != null && certs.length > 0 && certs[0] != null) { String data = SVNBase64.byteArrayToBase64(certs[0].getEncoded()); String stored = (String) myAuthManager.getRuntimeAuthStorage().getData("svn.ssl.server", myRealm); if (data.equals(stored)) { return; return; ISVNAuthenticationProvider authProvider = myAuthManager.getAuthenticationProvider(); int failures = getServerCertificateFailures(certs[0]); boolean store = myAuthManager.isAuthStorageEnabled(); int result = authProvider.acceptServerAuthentication(myURL, myRealm, certs[0], store); if (result == ISVNAuthenticationProvider.ACCEPTED && store) { myAuthManager.getRuntimeAuthStorage().putData("svn.ssl.server", myRealm, data); return;
public void verifyHostKey(String hostName, int port, String keyAlgorithm, byte[] hostKey) throws SVNException { String realm = hostName + ":" + port + " <" + keyAlgorithm + ">"; byte[] existingFingerprints = (byte[]) getRuntimeAuthStorage().getData("svn.ssh.server", realm); if (existingFingerprints == null && myProviders[2] instanceof IPersistentAuthenticationProvider) { existingFingerprints = ((IPersistentAuthenticationProvider) myProviders[2]).loadFingerprints(realm); } if (existingFingerprints == null || !equals(existingFingerprints, hostKey)) { SVNURL url = SVNURL.create("svn+ssh", null, hostName, port, "", true); boolean storageEnabled = isAuthStorageEnabled(url); if (getAuthenticationProvider() != null) { int accepted = getAuthenticationProvider().acceptServerAuthentication(url, realm, hostKey, isAuthStorageEnabled(url)); if (accepted == ISVNAuthenticationProvider.ACCEPTED && isAuthStorageEnabled(url)) { if (storageEnabled && hostKey != null && myProviders[2] instanceof IPersistentAuthenticationProvider) { ((IPersistentAuthenticationProvider) myProviders[2]).saveFingerprints(realm, hostKey); } } else if (accepted == ISVNAuthenticationProvider.REJECTED) { throw new SVNAuthenticationException(SVNErrorMessage.create(SVNErrorCode.AUTHN_CREDS_NOT_SAVED, "Host key ('" + realm + "') can not be verified.")); } if (hostKey != null) { getRuntimeAuthStorage().putData("svn.ssh.server", realm, hostKey); } } } }
public void verifyHostKey(String hostName, int port, String keyAlgorithm, byte[] hostKey) throws SVNException { String realm = hostName + ":" + port + " <" + keyAlgorithm + ">"; byte[] existingFingerprints = (byte[]) getRuntimeAuthStorage().getData("svn.ssh.server", realm); if (existingFingerprints == null && myProviders[2] instanceof ISVNPersistentAuthenticationProvider) { existingFingerprints = ((ISVNPersistentAuthenticationProvider) myProviders[2]).loadFingerprints(realm); } if (existingFingerprints == null || !equals(existingFingerprints, hostKey)) { SVNURL url = SVNURL.create("svn+ssh", null, hostName, port, "", true); final ISVNHostOptions hostOptions = getHostOptionsProvider().getHostOptions(url); boolean storageEnabled = hostOptions.isAuthStorageEnabled(); if (getAuthenticationProvider() != null) { int accepted = getAuthenticationProvider().acceptServerAuthentication(url, realm, hostKey, storageEnabled); if (accepted == ISVNAuthenticationProvider.ACCEPTED && storageEnabled) { if (storageEnabled && hostKey != null && myProviders[2] instanceof ISVNPersistentAuthenticationProvider) { ((ISVNPersistentAuthenticationProvider) myProviders[2]).saveFingerprints(realm, hostKey); } } else if (accepted == ISVNAuthenticationProvider.REJECTED) { throw new SVNAuthenticationException(SVNErrorMessage.create(SVNErrorCode.AUTHN_CREDS_NOT_SAVED, "Host key ('" + realm + "') can not be verified.")); } if (hostKey != null) { getRuntimeAuthStorage().putData("svn.ssh.server", realm, hostKey); } } } }
protected SVNSSHAuthentication getDefaultSSHAuthentication() { Map tunnels = getConfigFile().getProperties("tunnels"); if (tunnels == null || !tunnels.containsKey("ssh")) { tunnels = new HashMap(); String userName = getOptionValue(sshProgram, "-l"); String password = getOptionValue(sshProgram, "-pw"); String keyFile = getOptionValue(sshProgram, "-i"); String port = getOptionValue(sshProgram, sshProgram != null && sshProgram.toLowerCase().trim().startsWith("plink") ? "-P" : "-p"); String passphrase = null; return new SVNSSHAuthentication(userName, password, portNumber, isAuthStorageEnabled()); } else if (userName != null && keyFile != null) { return new SVNSSHAuthentication(userName, new File(keyFile), passphrase, portNumber, isAuthStorageEnabled());
public void checkServerTrusted(X509Certificate[] certs, String algorithm) throws CertificateException { if (certs != null && certs.length > 0 && certs[0] != null) { String data = SVNBase64.byteArrayToBase64(certs[0].getEncoded()); String stored = (String) myAuthManager.getRuntimeAuthStorage().getData("svn.ssl.server", myRealm); if (data.equals(stored)) { return; return; ISVNAuthenticationProvider authProvider = myAuthManager.getAuthenticationProvider(); int failures = SVNSSLUtil.getServerCertificateFailures(certs[0], myURL.getHost()); boolean store = myAuthManager.getHostOptionsProvider().getHostOptions(myURL).isAuthStorageEnabled(); final CertificateException exception = checkServerTrustedByDefault(certs, algorithm); if (exception != null && exception.getMessage().indexOf("Certificates does not conform to algorithm constraints") >= 0) { myAuthManager.getRuntimeAuthStorage().putData("svn.ssl.server", myRealm, data); return;
public SVNAuthentication requestClientAuthentication(String kind, SVNURL url, String realm, SVNErrorMessage errorMessage, SVNAuthentication previousAuth, boolean authMayBeStored) { return (SVNAuthentication) getRuntimeAuthStorage().getData(kind, realm); }
protected int getDefaultSSHPortNumber() { Map tunnels = getConfigFile().getProperties("tunnels"); if (tunnels == null || !tunnels.containsKey("ssh")) { return -1; } String sshProgram = (String) tunnels.get("ssh"); if (sshProgram == null) { return -1; } String port = getOptionValue(sshProgram, sshProgram.toLowerCase().trim().startsWith("plink") ? "-p" : "-P"); port = port == null ? System.getProperty("svnkit.ssh2.port", System.getProperty("javasvn.ssh2.port")) : port; if (port != null) { return Integer.parseInt(port); } return -1; }
protected boolean isStorePasswords(SVNURL url) { boolean store = true; String value = getConfigFile().getPropertyValue("auth", "store-passwords"); if (value != null) { store = "yes".equalsIgnoreCase(value) || "on".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value); } String host = url != null ? url.getHost() : null; Map properties = getHostProperties(host); String storePasswords = (String) properties.get("store-passwords"); if (storePasswords == null) { return store; } return "yes".equalsIgnoreCase(storePasswords) || "on".equalsIgnoreCase(storePasswords) || "true".equalsIgnoreCase(storePasswords); }
if (previousAuth == null) { if (ISVNAuthenticationManager.SSH.equals(kind)) { SVNSSHAuthentication sshAuth = getDefaultSSHAuthentication(); if (myUserName == null || "".equals(myUserName.trim())) { return sshAuth; } else if (ISVNAuthenticationManager.PASSWORD.equals(kind)) { if (myUserName == null || "".equals(myUserName.trim())) { String defaultUserName = getUserName(url); defaultUserName = defaultUserName == null ? System.getProperty("user.name") : defaultUserName; if (defaultUserName != null) {
if (previousAuth == null) { if (ISVNAuthenticationManager.SSH.equals(kind)) { SVNSSHAuthentication sshAuth = getDefaultSSHAuthentication(url); if (myUserName == null || "".equals(myUserName.trim())) { return sshAuth; } else if (ISVNAuthenticationManager.PASSWORD.equals(kind)) { if (myUserName == null || "".equals(myUserName.trim())) { String defaultUserName = getHostOptionsProvider().getHostOptions(url).getUserName(); defaultUserName = defaultUserName == null ? System.getProperty("user.name") : defaultUserName; if (defaultUserName != null) {
if (authManager != null && authManager instanceof DefaultSVNAuthenticationManager) { DefaultSVNAuthenticationManager defaultAuthManager = (DefaultSVNAuthenticationManager) authManager; authTypes = defaultAuthManager.getAuthTypes(myRepository.getLocation()); if (authManager != null && authManager instanceof DefaultSVNAuthenticationManager) { DefaultSVNAuthenticationManager defaultAuthManager = (DefaultSVNAuthenticationManager) authManager; authTypes = defaultAuthManager.getAuthTypes(myRepository.getLocation());
public SVNAuthentication requestClientAuthentication(String kind, SVNURL url, String realm, SVNErrorMessage errorMessage, SVNAuthentication previousAuth, boolean authMayBeStored) { if (previousAuth == null) { if (ISVNAuthenticationManager.SSH.equals(kind)) { SVNSSHAuthentication sshAuth = getDefaultSSHAuthentication(); if (myUserName == null || "".equals(myUserName.trim())) { return sshAuth; } if (myPrivateKey != null) { return new SVNSSHAuthentication(myUserName, myPrivateKey, myPassphrase, sshAuth != null ? sshAuth.getPortNumber() : -1, myIsStore); } return new SVNSSHAuthentication(myUserName, myPassword, sshAuth != null ? sshAuth.getPortNumber() : -1, myIsStore); } else if (ISVNAuthenticationManager.PASSWORD.equals(kind)) { if (myUserName == null || "".equals(myUserName.trim())) { return null; } return new SVNPasswordAuthentication(myUserName, myPassword, myIsStore); } else if (ISVNAuthenticationManager.USERNAME.equals(kind)) { if (myUserName == null || "".equals(myUserName)) { return null; } return new SVNUserNameAuthentication(myUserName, myIsStore); } } return null; } public int acceptServerAuthentication(SVNURL url, String r, Object serverAuth, boolean resultMayBeStored) {
public DefaultSVNAuthenticationManager(File configDirectory, boolean storeAuth, String userName, String password, File privateKey, String passphrase) { //password = password == null ? "" : password; myIsStoreAuth = storeAuth; myConfigDirectory = configDirectory; if (myConfigDirectory == null) { myConfigDirectory = SVNWCUtil.getDefaultConfigurationDirectory(); } myProviders = new ISVNAuthenticationProvider[4]; myProviders[0] = createDefaultAuthenticationProvider(userName, password, privateKey, passphrase, myIsStoreAuth); myProviders[1] = createRuntimeAuthenticationProvider(); myProviders[2] = createCacheAuthenticationProvider(new File(myConfigDirectory, "auth"), userName); }
public void checkServerTrusted(X509Certificate[] certs, String algorithm) throws CertificateException { if (certs != null && certs.length > 0 && certs[0] != null) { String data = SVNBase64.byteArrayToBase64(certs[0].getEncoded()); String stored = (String) myAuthManager.getRuntimeAuthStorage().getData("svn.ssl.server", myRealm); if (data.equals(stored)) { return; return; ISVNAuthenticationProvider authProvider = myAuthManager.getAuthenticationProvider(); int failures = SVNSSLUtil.getServerCertificateFailures(certs[0], myURL.getHost()); boolean store = myAuthManager.isAuthStorageEnabled(myURL); boolean trustServer = checkServerTrustedByDefault(certs, algorithm); int result; myAuthManager.getRuntimeAuthStorage().putData("svn.ssl.server", myRealm, data); return;
protected SVNSSHAuthentication getDefaultSSHAuthentication() { Map tunnels = getConfigFile().getProperties("tunnels"); if (tunnels == null || !tunnels.containsKey("ssh")) { tunnels = new SVNHashMap(); String userName = getOptionValue(sshProgram, "-l"); String password = getOptionValue(sshProgram, "-pw"); String keyFile = getOptionValue(sshProgram, "-i"); String port = getOptionValue(sshProgram, sshProgram != null && sshProgram.toLowerCase().trim().startsWith("plink") ? "-P" : "-p"); String passphrase = null; return new SVNSSHAuthentication(userName, password, portNumber, isAuthStorageEnabled(null), null, false); } else if (userName != null && keyFile != null) { return new SVNSSHAuthentication(userName, new File(keyFile), passphrase, portNumber, isAuthStorageEnabled(null), null, false);
public SVNAuthentication requestClientAuthentication(String kind, SVNURL url, String realm, SVNErrorMessage errorMessage, SVNAuthentication previousAuth, boolean authMayBeStored) { return (SVNAuthentication) getRuntimeAuthStorage().getData(kind, realm); }