Package org.tmatesoft.svn.core.auth

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


   * Ugly method to convert a SVN authentication into a SCMCredentialConfiguration
   */
  public SCMCredentialConfiguration createSCMCredentialConfiguration(SVNAuthentication auth){
        SCMCredentialConfiguration credentials = null;
    if(auth instanceof SVNPasswordAuthentication){
      SVNPasswordAuthentication passAuth = (SVNPasswordAuthentication)auth;
      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;
View Full Code Here


        ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
        if (authManager != null && authManager.isAuthenticationForced() && mechs.contains("ANONYMOUS") && mechs.contains("CRAM-MD5")) {
            mechs.remove("ANONYMOUS");
        }
        SVNURL location = myRepository.getLocation();       
        SVNPasswordAuthentication auth = null;
        if (repository.getExternalUserName() != null && mechs.contains("EXTERNAL")) {
            write("(w(s))", new Object[] { "EXTERNAL", repository.getExternalUserName() });
            failureReason = readAuthResponse();
        } else if (mechs.contains("ANONYMOUS")) {
            write("(w())", new Object[] { "ANONYMOUS" });
            failureReason = readAuthResponse();
        } else if (mechs.contains("CRAM-MD5")) {
            while (true) {
                CramMD5 authenticator = new CramMD5();
                String realm = getRealm();
                if (location != null) {
                    realm = "<" + location.getProtocol() + "://"
                            + location.getHost() + ":"
                            + location.getPort() + "> " + realm;
                }
                if (auth == null && authManager != null) {
                    auth = (SVNPasswordAuthentication) authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, realm, location);                   
                } else if (authManager != null) {
                    authManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, failureReason, auth);
                    auth = (SVNPasswordAuthentication) authManager.getNextAuthentication(ISVNAuthenticationManager.PASSWORD, realm, location);
                }
                if (auth == null || auth.getUserName() == null || auth.getPassword() == null) {
                    failureReason = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "Can''t get password. Authentication is required for ''{0}''", realm);
                    break;
                }
                write("(w())", new Object[] { "CRAM-MD5" });
                while (true) {
View Full Code Here

            }
            String password = prompt("Password for '" + name + "'");
            if (password == null) {
                password = "";
            }
            return new SVNPasswordAuthentication(name, password, authMayBeStored);
        } else if (ISVNAuthenticationManager.SSH.equals(kind)) {
            String name = null;
            printRealm(realm);
            while(name == null) {
                name = prompt("Username");
View Full Code Here

                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;
    }
View Full Code Here

                    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)) {
                        String userName = System.getProperty("svnkit.ssh2.author", System.getProperty("javasvn.ssh2.author"));
                        if (userName != null) {
                            return new SVNUserNameAuthentication(userName, myIsStore);
View Full Code Here

                    String passphrase = (String) values.get("passphrase");
                    passphrase = cipher.decrypt(passphrase);
                    String port = (String) values.get("port");
                    port = port == null ? ("" + getDefaultSSHPortNumber()) : port;
                    if (ISVNAuthenticationManager.PASSWORD.equals(kind)) {
                        return new SVNPasswordAuthentication(userName, password, authMayBeStored);
                    } else if (ISVNAuthenticationManager.SSH.equals(kind)) {
                        // get port from config file or system property?
                        int portNumber;
                        try {
                            portNumber = Integer.parseInt(port);
View Full Code Here

            if (cipherType != null) {
                values.put("passtype", cipherType);
            }
            if (ISVNAuthenticationManager.PASSWORD.equals(kind)) {
                SVNPasswordAuthentication passwordAuth = (SVNPasswordAuthentication) auth;
                values.put("password", cipher.encrypt(passwordAuth.getPassword()));
            } else if (ISVNAuthenticationManager.SSH.equals(kind)) {
                SVNSSHAuthentication sshAuth = (SVNSSHAuthentication) auth;
                if (sshAuth.getPassword() != null) {
                    values.put("password", cipher.encrypt(sshAuth.getPassword()));
                }
View Full Code Here

                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)) {
                    int port = url.hasPort() ? url.getPort() : -1;
                    if (port < 0 && info.get("port") != null) {
                        port = Integer.parseInt((String) info.get("port"));
                    }
View Full Code Here

                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;
    }
View Full Code Here

                if (clientFactory == null) {
                    continue;
                }
                SVNAuthentication auth = null;
                if ("ANONYMOUS".equals(mech)) {
                    auth = new SVNPasswordAuthentication("", "", false);
                } else if ("EXTERNAL".equals(mech)) {
                    String name = repos.getExternalUserName();
                    if (name == null) {
                        name = "";
                    }
                    auth = new SVNPasswordAuthentication(name, "", false);
                } else {               
                    if (myAuthenticationManager == null) {
                        SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "Authentication required for ''{0}''", realm),
                                SVNLogType.NETWORK);
                    }
View Full Code Here

TOP

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

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.