public void saveFingerprints(String realm, byte[] fingerprints) { Map info = new SVNHashMap(); info.put("svn:realmstring", realm); info.put("hostkey", fingerprints); try { Platform.addAuthorizationInfo(DEFAULT_URL, realm, "svn.ssh.server", info); } catch (CoreException e) { } }
public void saveAuthentication(SVNAuthentication auth, String kind, String realm) { if (!(auth instanceof SVNSSLAuthentication) && (auth.getUserName() == null || "".equals(auth.getUserName()))) { return; } realm = realm == null ? DEFAULT_URL.toString() : realm; Map info = new SVNHashMap(); // convert info to SVNAuthentication. info.put("username", auth.getUserName()); if (auth instanceof SVNPasswordAuthentication) { info.put("password", ((SVNPasswordAuthentication) auth).getPassword()); } else if (auth instanceof SVNSSHAuthentication) { SVNSSHAuthentication sshAuth = (SVNSSHAuthentication) auth; if (sshAuth.getPrivateKeyFile() != null) { info.put("key", sshAuth.getPrivateKeyFile().getAbsolutePath()); if (sshAuth.getPassphrase() != null) { info.put("passphrase", sshAuth.getPassphrase()); } } else if (sshAuth.getPassword() != null) { info.put("password", sshAuth.getPassword()); } if (sshAuth.getPortNumber() >= 0) { info.put("port", Integer.toString(sshAuth.getPortNumber())); } } else if (auth instanceof SVNSSLAuthentication) { SVNSSLAuthentication sslAuth = (SVNSSLAuthentication) auth; String password = sslAuth.getPassword(); if (password != null && !"".equals(password)) { info.put("password", password); } if (SVNSSLAuthentication.SSL.equals(sslAuth.getSSLKind())) { String path = sslAuth.getCertificatePath(); if (path != null) { info.put("cert", path); } } else if (SVNSSLAuthentication.MSCAPI.equals(sslAuth.getSSLKind())) { info.put("ssl-kind", sslAuth.getSSLKind()); info.put("alias", sslAuth.getAlias()); } } try { Platform.addAuthorizationInfo(DEFAULT_URL, realm, kind, info); } catch (CoreException e) { } }