Package org.tmatesoft.svn.core.auth

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


    // create a destination directory
    File destinationDir = new File(destPath);

    if (!user.isEmpty() && !password.isEmpty()) {

      ISVNAuthenticationManager authManager = new BasicAuthenticationManager(
          user, password);
      clientManager.setAuthenticationManager(authManager);
    }

    SVNUpdateClient updateClient = clientManager.getUpdateClient();
View Full Code Here


    SVNClientManager svnClientManager = SVNClientManager.newInstance();

    if (!svnUser.isEmpty() && !svnPassword.isEmpty()) {

      ISVNAuthenticationManager authManager = new BasicAuthenticationManager(
          svnUser, svnPassword);
      svnClientManager.setAuthenticationManager(authManager);
    }

    SVNWCClient wcClient = svnClientManager.getWCClient();
View Full Code Here

    try {
      ISVNAuthenticationProvider authProvider = CredentialsSVNAuthenticationProviderImpl.createAuthenticationProvider(
              context, getTagsDir(), getCredentialsId(), null
      );
      ISVNAuthenticationManager authManager = SubversionSCM.createSvnAuthenticationManager(authProvider);
      SVNURL repoURL = SVNURL.parseURIDecoded(getTagsDir());

      SVNRepository repo = SVNRepositoryFactory.create(repoURL);
      repo.setAuthenticationManager(authManager);
      SVNLogClient logClient = new SVNLogClient(authManager, null);
View Full Code Here

        @Override
        protected void perform(TaskListener listener) {
            try {
                File configDir = SVNWCUtil.getDefaultConfigurationDirectory();
                ISVNAuthenticationManager sam = new SVNAuthenticationManager(configDir, null, null);
                sam.setAuthenticationProvider(new CredentialsSVNAuthenticationProviderImpl(upc));
                final SvnClientManager cm = new SvnClientManager(
                        SVNClientManager.newInstance(SubversionSCM.createDefaultSVNOptions(), sam)
                );
                try {
                    for (Entry<SvnInfo, String> e : tagSet.entrySet()) {
View Full Code Here

   *
   * @return svn client manager
   */
  public SVNClientManager getSVNClientManager() {
    DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(subversionHome, true);
    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(subversionHome,
        getCurrentUserId(), null, false);
    return SVNClientManager.newInstance(options, authManager);
  }
View Full Code Here

            return getLocation().getUserInfo();
        }
        if (getAuthenticationManager() != null) {
            try {
                String realm = getRepositoryUUID(true);
                ISVNAuthenticationManager authManager = getAuthenticationManager();
                SVNAuthentication auth = authManager.getFirstAuthentication(ISVNAuthenticationManager.USERNAME, realm, getLocation());

                while (auth != null) {
                    String userName = auth.getUserName();
                    if (userName == null || "".equals(userName.trim())) {
                        userName = System.getProperty("user.name");
                    }
                    auth = new SVNUserNameAuthentication(userName, auth.isStorageAllowed());
                    if (userName != null && !"".equals(userName.trim())) {
                        authManager.acknowledgeAuthentication(true, ISVNAuthenticationManager.USERNAME, realm, null, auth);
                        return auth.getUserName();
                    }
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.AUTHN_CREDS_UNAVAILABLE, "Empty user name is not allowed");
                    authManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.USERNAME, realm, err, auth);
                    auth = authManager.getNextAuthentication(ISVNAuthenticationManager.USERNAME, realm, getLocation());
                }
                // auth manager returned null - that is cancellation.
                SVNErrorManager.cancel("Authentication cancelled", SVNLogType.FSFS);
            } catch (SVNCancelException e) {
                throw e;
View Full Code Here

        if (mechs == null || mechs.size() == 0) {
            return;
        }
        myRealm = SVNReader.getString(items, 1);
       
        ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
        if (authManager != null && authManager.isAuthenticationForced() && mechs.contains("ANONYMOUS") &&
                (mechs.contains("CRAM-MD5") || mechs.contains("DIGEST-MD5"))) {
            mechs.remove("ANONYMOUS");
        }
        SVNAuthenticator authenticator = createSASLAuthenticator();
        authenticator.authenticate(mechs, myRealm, repository);
View Full Code Here

        myIsUseConnectionPing = useConnectionPing;
        myIsUseSessionPing = useSessionPing;
    }

    public void open(SVNRepositoryImpl repository) throws SVNException {
        ISVNAuthenticationManager authManager = repository.getAuthenticationManager();
        if (authManager == null) {
            SVNErrorManager.authenticationFailed("Authentication required for ''{0}''", repository.getLocation());
            return;
        }

        String realm = repository.getLocation().getProtocol() + "://" + repository.getLocation().getHost();
        if (repository.getLocation().hasPort()) {
            realm += ":" + repository.getLocation().getPort();
        }
        if (repository.getLocation().getUserInfo() != null && !"".equals(repository.getLocation().getUserInfo())) {
            realm = repository.getLocation().getUserInfo() + "@" + realm;
        }

        int reconnect = 1;
        while(true) {
            SVNSSHAuthentication authentication = (SVNSSHAuthentication) authManager.getFirstAuthentication(ISVNAuthenticationManager.SSH, realm, repository.getLocation());
            SSHConnectionInfo connection = null;
           
            // lock SVNSSHSession to make sure connection opening and session creation is atomic.
            SVNSSHSession.lock(Thread.currentThread());
            try {
                while (authentication != null) {
                    try {
                        connection = SVNSSHSession.getConnection(repository.getLocation(), authentication, authManager.getConnectTimeout(repository), myIsUseConnectionPing);
                        if (connection == null) {
                            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_CONNECTION_CLOSED, "Cannot connect to ''{0}''", repository.getLocation().setPath("", false));
                            SVNErrorManager.error(err, SVNLogType.NETWORK);
                        }
                        authManager.acknowledgeAuthentication(true, ISVNAuthenticationManager.SSH, realm, null, authentication);
                        break;
                    } catch (SVNAuthenticationException e) {
                        SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, e);
                        authManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.SSH, realm, e.getErrorMessage(), authentication);
                        authentication = (SVNSSHAuthentication) authManager.getNextAuthentication(ISVNAuthenticationManager.SSH, realm, repository.getLocation());
                        connection = null;
                    }
                }
                if (authentication == null) {
                    SVNErrorManager.cancel("authentication cancelled", SVNLogType.NETWORK);
                } else if (connection == null) {
                    SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_CONNECTION_CLOSED, "Can not establish connection to ''{0}''", realm), SVNLogType.NETWORK);
                }
                try {
                    mySession = connection.openSession();
                    SVNAuthentication author = authManager.getFirstAuthentication(ISVNAuthenticationManager.USERNAME, realm, repository.getLocation());
                    if (author == null) {
                        SVNErrorManager.cancel("authentication cancelled", SVNLogType.NETWORK);
                    }
                    String userName = author.getUserName();
                    if (userName == null || "".equals(userName.trim())) {
                        userName = authentication.getUserName();
                    }
                    if (author.getUserName() == null || author.getUserName().equals(authentication.getUserName()) ||
                            "".equals(author.getUserName())) {
                        repository.setExternalUserName("");
                    } else {
                        repository.setExternalUserName(author.getUserName());
                    }
                    author = new SVNUserNameAuthentication(userName, author.isStorageAllowed());
                    authManager.acknowledgeAuthentication(true, ISVNAuthenticationManager.USERNAME, realm, null, author);
   
                    if ("".equals(repository.getExternalUserName())) {
                        mySession.execCommand(SVNSERVE_COMMAND);
                    } else {
                        mySession.execCommand(SVNSERVE_COMMAND_WITH_USER_NAME + "\"" + repository.getExternalUserName() + "\"");
View Full Code Here

    public void authenticate(List mechs, String realm, SVNRepositoryImpl repos) throws SVNException {
        SVNErrorMessage failureReason = null;
        if (mechs == null || mechs.size() == 0) {
            return;
        }
        ISVNAuthenticationManager authManager = repos.getAuthenticationManager();
        if (authManager != null && authManager.isAuthenticationForced() && mechs.contains("ANONYMOUS") && mechs.contains("CRAM-MD5")) {
            mechs.remove("ANONYMOUS");
        }
        SVNURL location = repos.getLocation();
        SVNPasswordAuthentication auth = null;
        if (repos.getExternalUserName() != null && mechs.contains("EXTERNAL")) {
            getConnection().write("(w(s))", new Object[]{"EXTERNAL", ""});
            failureReason = readAuthResponse();
        } else if (mechs.contains("ANONYMOUS")) {
            getConnection().write("(w(s))", new Object[]{"ANONYMOUS", ""});
            failureReason = readAuthResponse();
        } else if (mechs.contains("CRAM-MD5")) {
            while (true) {
                CramMD5 authenticator = new CramMD5();
                if (location != null) {
                    realm = "<" + location.getProtocol() + "://"
                            + location.getHost() + ":"
                            + location.getPort() + "> " + realm;
                }
                try {
                    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);
                    }
                } catch (SVNException e) {
                    if (e.getErrorMessage().getErrorCode() == SVNErrorCode.CANCELLED) {
                        throw e;
                    } else if (getLastError() != null) {
                        SVNErrorManager.error(getLastError(), SVNLogType.NETWORK);
                    }
                    throw e;
                }
                if (auth == null) {
                    failureReason = SVNErrorMessage.create(SVNErrorCode.CANCELLED, "Authentication cancelled");
                    setLastError(failureReason);
                    break;
                   
                }
                if (auth.getUserName() == null || auth.getPassword() == null) {
                    failureReason = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "Can''t get password. Authentication is required for ''{0}''", realm);
                    break;
                }
                getConnection().write("(w())", new Object[]{"CRAM-MD5"});
                while (true) {
                    authenticator.setUserCredentials(auth);
                    List items = getConnection().readTuple("w(?s)", true);
                    String status = SVNReader.getString(items, 0);
                    if (SVNAuthenticator.SUCCESS.equals(status)) {
                        authManager.acknowledgeAuthentication(true, ISVNAuthenticationManager.PASSWORD, realm, null, auth);
                        return;
                    } else if (SVNAuthenticator.FAILURE.equals(status)) {                       
                        failureReason = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "Authentication error from server: {0}", SVNReader.getString(items, 1));
                        String message = SVNReader.getString(items, 1);
                        if (message != null) {
View Full Code Here

      if (mySocket == null || SVNSocketFactory.isSocketStale(mySocket)) {
            close();
            String host = location.getHost();
            int port = location.getPort();
           
          ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
          ISVNProxyManager proxyAuth = authManager != null ? authManager.getProxyManager(location) : null;
          int connectTimeout = authManager != null ? authManager.getConnectTimeout(myRepository) : 0;
            int readTimeout = authManager != null ? authManager.getReadTimeout(myRepository) : DEFAULT_HTTP_TIMEOUT;
            if (readTimeout < 0) {
                readTimeout = DEFAULT_HTTP_TIMEOUT;
            }
        if (proxyAuth != null && proxyAuth.getProxyHost() != null) {
          myRepository.getDebugLog().logFine(SVNLogType.NETWORK, "Using proxy " + proxyAuth.getProxyHost() + " (secured=" + myIsSecured + ")");
View Full Code Here

TOP

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

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.