Package org.tmatesoft.svn.core.auth

Examples of org.tmatesoft.svn.core.auth.SVNSSLAuthentication


            // convert info to SVNAuthentication.
            if (info != null && ISVNAuthenticationManager.SSL.equals(kind)) {
                String path = (String) info.get("cert");
                String password = (String) info.get("password");
                if (path != null) {
                    return new SVNSSLAuthentication(new File(path), password, authMayBeStored);
                }
            } else if (info != null && !info.isEmpty() && info.get("username") != null) {
                if (ISVNAuthenticationManager.PASSWORD.equals(kind)) {
                    return new SVNPasswordAuthentication((String) info.get("username"), (String) info.get("password"), authMayBeStored);
                } else if (ISVNAuthenticationManager.SSH.equals(kind)) {
View Full Code Here


                }
                if (sshAuth.getPortNumber() >= 0) {
                    info.put("port", Integer.toString(sshAuth.getPortNumber()));
                }
            } else if (auth instanceof SVNSSLAuthentication) {
                SVNSSLAuthentication sslAuth = (SVNSSLAuthentication) auth;
                File path = sslAuth.getCertificateFile();
                String password = sslAuth.getPassword();
                if (path != null) {
                    info.put("cert", path.getAbsolutePath());
                    if (password != null && !"".equals(password)) {
                        info.put("password", password);
                    }
View Full Code Here

            String host = url.getHost();
            Map properties = getHostProperties(host);
            String sslClientCert = (String) properties.get("ssl-client-cert-file"); // PKCS#12
            String sslClientCertPassword = (String) properties.get("ssl-client-cert-password");
            File clientCertFile = sslClientCert != null ? new File(sslClientCert) : null;
            return new SVNSSLAuthentication(clientCertFile, sslClientCertPassword, authMayBeStored);
          }

            File dir = new File(myDirectory, kind);
            if (!dir.isDirectory()) {
                return null;
View Full Code Here

                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) {
                    //
                }
            }
View Full Code Here

                        values.put("passtype", cipherType);
                    }
                }
            }
           
            SVNSSLAuthentication sslAuth = (SVNSSLAuthentication) auth;
            if (maySavePassphrase) {
                values.put("passphrase", cipher.encrypt(sslAuth.getPassword()));
            }
            if (SVNSSLAuthentication.SSL.equals(sslAuth.getSSLKind())) {
                if (sslAuth.getCertificateFile() != null) {
                    String path = sslAuth.getCertificateFile().getAbsolutePath();
                    values.put("key", path);
                }
            } else if (SVNSSLAuthentication.MSCAPI.equals(sslAuth.getSSLKind())) {
                values.put("ssl-kind", sslAuth.getSSLKind());
                values.put("alias", sslAuth.getAlias());
            }

        }
View Full Code Here

                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) {
View Full Code Here

      credentials = new SCMCredentialConfiguration(passAuth.getUserName(), passAuth.getPassword());
    } else if(auth instanceof SVNSSHAuthentication){
      SVNSSHAuthentication sshAuth = (SVNSSHAuthentication)auth;
      credentials = new SCMCredentialConfiguration(sshAuth.getUserName(), sshAuth.getPassword(), sshAuth.getPassphrase(), sshAuth.getPrivateKey());
    } else if(auth instanceof SVNSSLAuthentication){
      SVNSSLAuthentication sslAuth = (SVNSSLAuthentication)auth;
      credentials = new SCMCredentialConfiguration(sslAuth.getUserName(), sslAuth.getPassword());
    } else if(auth instanceof SVNUserNameAuthentication){
      SVNUserNameAuthentication unameAuth = (SVNUserNameAuthentication)auth;
      credentials = new SCMCredentialConfiguration(unameAuth.getUserName());
    }
View Full Code Here

                        ssl.getCause().getCause() instanceof SVNCancelException) {
                    SVNErrorManager.cancel(ssl.getCause().getCause().getMessage());
                }
                if (sslManager != null) {
                    close();
                    SVNSSLAuthentication sslAuth = sslManager.getClientAuthentication();
                    if (sslAuth != null) {
                        SVNErrorMessage sslErr = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "SSL handshake failed: ''{0}''", ssl.getMessage());
                        myRepository.getAuthenticationManager().acknowledgeAuthentication(false, ISVNAuthenticationManager.SSL, sslRealm, sslErr, sslAuth);
                    }
                    sslManager = promptSSLClientCertificate(sslAuth == null, true);
                    continue;
                }
                err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, ssl);
            } catch (UnknownHostException ioe) {
                myRepository.getDebugLog().info(ioe);
                err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, ioe);
            } catch (SocketTimeoutException timeout) {
                myRepository.getDebugLog().info(timeout);
                err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "timed out waiting for server");
            } catch (SVNCancellableOutputStream.IOCancelException cancel) {
                myRepository.getDebugLog().info(cancel);
                SVNErrorManager.cancel(cancel.getMessage());
            } catch (IOException e) {
                myRepository.getDebugLog().info(e);
                if (sslManager != null) {
                    close();
                    SVNSSLAuthentication sslAuth = sslManager.getClientAuthentication();
                    if (sslAuth != null) {
                        SVNErrorMessage sslErr = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "SSL handshake failed: ''{0}''", e.getMessage());
                        myRepository.getAuthenticationManager().acknowledgeAuthentication(false, ISVNAuthenticationManager.SSL, sslRealm, sslErr, sslAuth);
                    }
                    sslManager = promptSSLClientCertificate(sslAuth == null, true);
                    continue;
                }
                err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, e.getMessage());
            } catch (SVNException e) {
                myRepository.getDebugLog().info(e);
                // force connection close on SVNException
                // (could be thrown by user's auth manager methods).
                close();
                throw e;
            } finally {
                finishResponse(request);               
            }
            if (err != null) {
                close();
                if (sslManager != null) {
                    sslManager.acknowledgeSSLContext(false, err);
                }
                break;
            }
            if (sslManager != null) {
                sslManager.acknowledgeSSLContext(true, null);
                SVNSSLAuthentication sslAuth = sslManager.getClientAuthentication();
                if (sslAuth != null) {
                    mySSLManager = sslManager;
                    myRepository.getAuthenticationManager().acknowledgeAuthentication(true, ISVNAuthenticationManager.SSL, sslRealm, null, sslAuth);
                }
            }
View Full Code Here

    private ISVNSSLManager promptSSLClientCertificate(boolean firstAuth, boolean onError) throws SVNException {
        SVNURL location = myRepository.getLocation();
        ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
        ISVNSSLManager sslManager = null;
        SVNSSLAuthentication sslAuth = null;
        String sslRealm = "<" + location.getProtocol() + "://" + location.getHost() + ":" + location.getPort() + ">";
        if (myIsSecured) {
            sslManager = authManager != null ? authManager.getSSLManager(location) : null;
        }
        if (authManager != null && sslManager != null &&
View Full Code Here

            }
            String password = prompt("Passphrase for '" + realm + "'");
            if (password == null) {
                password = "";
            }
            return new SVNSSLAuthentication(new File(path), password, authMayBeStored);
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.auth.SVNSSLAuthentication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.