Examples of ISVNProxyManager


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

            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 + ")");
                mySocket = SVNSocketFactory.createPlainSocket(proxyAuth.getProxyHost(), proxyAuth.getProxyPort(), connectTimeout, readTimeout, myRepository.getCanceller());
                if (myProxyAuthentication == null) {
                    myProxyAuthentication = new HTTPBasicAuthentication(proxyAuth.getProxyUserName(), proxyAuth.getProxyPassword(), myCharset);
                }
                myIsProxied = true;
                if (myIsSecured) {
                    HTTPRequest connectRequest = new HTTPRequest(myCharset);
                    connectRequest.setConnection(this);
                    connectRequest.initCredentials(myProxyAuthentication, "CONNECT", host + ":" + port);
                    connectRequest.setProxyAuthentication(myProxyAuthentication.authenticate());
                    connectRequest.setForceProxyAuth(true);
                    connectRequest.dispatch("CONNECT", host + ":" + port, null, 0, 0, null);
                    HTTPStatus status = connectRequest.getStatus();
                    if (status.getCode() == HttpURLConnection.HTTP_OK) {
                        myInputStream = null;
                        myOutputStream = null;
                        mySocket = SVNSocketFactory.createSSLSocket(keyManager != null ? new KeyManager[] { keyManager } : new KeyManager[0], trustManager, host, port, mySocket, readTimeout);
                        proxyAuth.acknowledgeProxyContext(true, null);
                        return;
                    }
                    SVNURL proxyURL = SVNURL.parseURIEncoded("http://" + proxyAuth.getProxyHost() + ":" + proxyAuth.getProxyPort());
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "{0} request failed on ''{1}''", new Object[] {"CONNECT", proxyURL});
                    proxyAuth.acknowledgeProxyContext(false, err);
                    SVNErrorManager.error(err, connectRequest.getErrorMessage(), SVNLogType.NETWORK);
                }
            } else {
                myIsProxied = false;
                myProxyAuthentication = null;
View Full Code Here

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

                }

                err = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "HTTP proxy authorization failed");
                SVNURL location = myRepository.getLocation();
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(false, err);
                }
                close();

                break;
            } else if (status.getCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
                authAttempts++;//how many times did we try?
               
                Collection authHeaderValues = request.getResponseHeader().getHeaderValues(HTTPHeader.AUTHENTICATE_HEADER);
                if (authHeaderValues == null || authHeaderValues.size() == 0) {
                    err = request.getErrorMessage();
                    status.setError(SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, err.getMessageTemplate(), err.getRelatedObjects()));
                    if ("LOCK".equalsIgnoreCase(method)) {
                        status.getError().setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
                                "Probably you are trying to lock file in repository that only allows anonymous access"));
                    }
                    SVNErrorManager.error(status.getError(), SVNLogType.NETWORK);
                    return status; 
                }

                //we should work around a situation when a server
                //does not support Basic authentication while we're
                //forcing it, credentials should not be immediately
                //thrown away
                boolean skip = false;
                isAuthForced = myRepository.getAuthenticationManager() != null ? myRepository.getAuthenticationManager().isAuthenticationForced() : false;
                if (isAuthForced) {
                    if (httpAuth != null && myChallengeCredentials != null && !HTTPAuthentication.isSchemeSupportedByServer(myChallengeCredentials.getAuthenticationScheme(), authHeaderValues)) {
                        skip = true;
                    }
                }
               
                try {
                    myChallengeCredentials = HTTPAuthentication.parseAuthParameters(authHeaderValues, myChallengeCredentials, myCharset);
                } catch (SVNException svne) {
                    err = svne.getErrorMessage();
                    break;
                }

                myChallengeCredentials.setChallengeParameter("methodname", method);
                myChallengeCredentials.setChallengeParameter("uri", HTTPParser.getCanonicalPath(path, null).toString());
               
                if (skip) {
                    close();
                    continue;
                }
               
                HTTPNTLMAuthentication ntlmAuth = null;
                HTTPNegotiateAuthentication negoAuth = null;
                if (myChallengeCredentials instanceof HTTPNTLMAuthentication) {
                    ntlmAuthIsRequired = true;
                    ntlmAuth = (HTTPNTLMAuthentication)myChallengeCredentials;
                    if (ntlmAuth.isInType3State()) {
                        continue;
                    }
                } else if (myChallengeCredentials instanceof HTTPDigestAuthentication) {
                    // continue (retry once) if previous request was acceppted?
                    if (myLastValidAuth != null) {
                        myLastValidAuth = null;
                        continue;
                    }
                } else if (myChallengeCredentials instanceof HTTPNegotiateAuthentication) {
                    negoAuthIsRequired = true;
                    negoAuth = (HTTPNegotiateAuthentication)myChallengeCredentials;
                    if (negoAuth.isStarted()) {
                        continue;
                    }
                }

                myLastValidAuth = null;

                if (ntlmAuth != null && ntlmAuth.isNative() && authAttempts == 1) {
                    /*
                     * if this is the first time we get HTTP_UNAUTHORIZED, NTLM is the target auth scheme
                     * and JNA is available, we should try a native auth mechanism first without calling
                     * auth providers.
                     */
                    continue;
                }

                if (negoAuth != null && !negoAuth.needsLogin()) {
                    continue;
                }

                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                if (authManager == null) {
                    err = request.getErrorMessage();
                    break;
                }

                realm = myChallengeCredentials.getChallengeParameter("realm");
                realm = realm == null ? "" : " " + realm;
                realm = "<" + myHost.getProtocol() + "://" + myHost.getHost() + ":" + myHost.getPort() + ">" + realm;
               
                if (httpAuth == null) {
                    httpAuth = authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());
                } else if (authAttempts >= requestAttempts) {
                    authManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, request.getErrorMessage(), httpAuth);
                    httpAuth = authManager.getNextAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());
                }
               
                if (httpAuth == null) {
                    err = SVNErrorMessage.create(SVNErrorCode.CANCELLED, "HTTP authorization cancelled");
                    break;
                }
                if (httpAuth != null) {
                    myChallengeCredentials.setCredentials((SVNPasswordAuthentication) httpAuth);
                }
                continue;
            } else if (status.getCode() == HttpURLConnection.HTTP_MOVED_PERM || status.getCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
                close();
                String newLocation = request.getResponseHeader().getFirstHeaderValue(HTTPHeader.LOCATION_HEADER);
                if (newLocation == null) {
                    err = request.getErrorMessage();
                    break;
                }
                int hostIndex = newLocation.indexOf("://");
                if (hostIndex > 0) {
                    hostIndex += 3;
                    hostIndex = newLocation.indexOf("/", hostIndex);
                }
                if (hostIndex > 0 && hostIndex < newLocation.length()) {
                    String newPath = newLocation.substring(hostIndex);
                    if (newPath.endsWith("/") &&
                            !newPath.endsWith("//") && !path.endsWith("/") &&
                            newPath.substring(0, newPath.length() - 1).equals(path)) {
                        path += "//";
                        continue;
                    }
                }
                err = request.getErrorMessage();
            } else if (request.getErrorMessage() != null) {
                err = request.getErrorMessage();
            } else {
                ntlmProxyAuthIsRequired = false;
                ntlmAuthIsRequired = false;
                negoAuthIsRequired = false;
            }
           
            if (err != null) {
                break;
            }
           
            if (myIsProxied) {
                SVNURL location = myRepository.getLocation();
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(true, null);
                }
            }
           
            if (httpAuth != null && realm != null && myRepository.getAuthenticationManager() != null) {
                myRepository.getAuthenticationManager().acknowledgeAuthentication(true, ISVNAuthenticationManager.PASSWORD, realm, null, httpAuth);
View Full Code Here

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

            close();
            String host = location.getHost();
            int port = location.getPort();
           
            ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
            ISVNProxyManager proxyAuth = authManager != null ? authManager.getProxyManager(location) : null;
            if (proxyAuth != null && proxyAuth.getProxyHost() != null) {
                mySocket = SVNSocketFactory.createPlainSocket(proxyAuth.getProxyHost(), proxyAuth.getProxyPort());
                if (myProxyAuthentication == null) {
                    myProxyAuthentication = new HTTPBasicAuthentication(proxyAuth.getProxyUserName(), proxyAuth.getProxyPassword(), myCharset);
                }
                myIsProxied = true;
                if (myIsSecured) {
                    HTTPRequest connectRequest = new HTTPRequest(myCharset);
                    connectRequest.setConnection(this);
                    connectRequest.initCredentials(myProxyAuthentication, "CONNECT", host + ":" + port);
                    connectRequest.setProxyAuthentication(myProxyAuthentication.authenticate());
                    connectRequest.setForceProxyAuth(true);
                    connectRequest.dispatch("CONNECT", host + ":" + port, null, 0, 0, null);
                    HTTPStatus status = connectRequest.getStatus();
                    if (status.getCode() == HttpURLConnection.HTTP_OK) {
                        myInputStream = null;
                        myOutputStream = null;
                        mySocket = SVNSocketFactory.createSSLSocket(sslManager, host, port, mySocket);
                        proxyAuth.acknowledgeProxyContext(true, null);
                        return;
                    }
                    SVNURL proxyURL = SVNURL.parseURIEncoded("http://" + proxyAuth.getProxyHost() + ":" + proxyAuth.getProxyPort());
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "{0} request failed on ''{1}''", new Object[] {"CONNECT", proxyURL});
                    proxyAuth.acknowledgeProxyContext(false, err);
                    SVNErrorManager.error(err, connectRequest.getErrorMessage());
                }
            } else {
                myIsProxied = false;
                myProxyAuthentication = null;
View Full Code Here

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

                }

                err = SVNErrorMessage.create(SVNErrorCode.CANCELLED, "HTTP proxy authorization cancelled");
                SVNURL location = myRepository.getLocation();
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(false, err);
                }
                close();

                break;
            } else if (status.getCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
                Collection authHeaderValues = request.getResponseHeader().getHeaderValues(HTTPHeader.AUTHENTICATE_HEADER);
                if (authHeaderValues == null || authHeaderValues.size() == 0) {
                    err = request.getErrorMessage();
                    status.setError(SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, err.getMessageTemplate(), err.getRelatedObjects()));
                    if ("LOCK".equalsIgnoreCase(method)) {
                        status.getError().setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
                                "Probably you are trying to lock file in repository that only allows anonymous access"));
                    }
                    SVNErrorManager.error(status.getError());
                    return status; 
                }

                //we should work around a situation when a server
                //does not support Basic authentication while we're
                //forcing it, credentials should not be immediately
                //thrown away
                boolean skip = false;
                isAuthForced = myRepository.getAuthenticationManager() != null ? myRepository.getAuthenticationManager().isAuthenticationForced() : false;
                if (isAuthForced) {
                    if (httpAuth != null && myChallengeCredentials != null && !HTTPAuthentication.isSchemeSupportedByServer(myChallengeCredentials.getAuthenticationScheme(), authHeaderValues)) {
                        skip = true;
                    }
                }
               
                try {
                    myChallengeCredentials = HTTPAuthentication.parseAuthParameters(authHeaderValues, myChallengeCredentials, myCharset);
                } catch (SVNException svne) {
                    err = svne.getErrorMessage();
                    break;
                }

                myChallengeCredentials.setChallengeParameter("methodname", method);
                myChallengeCredentials.setChallengeParameter("uri", path);
               
                if (skip) {
                    close();
                    continue;
                }
               
                if (myChallengeCredentials instanceof HTTPNTLMAuthentication) {
                    HTTPNTLMAuthentication ntlmAuth = (HTTPNTLMAuthentication)myChallengeCredentials;
                    if (ntlmAuth.isInType3State()) {
                        continue;
                    }
                } else if (myChallengeCredentials instanceof HTTPDigestAuthentication) {
                    // continue (retry once) if previous request was acceppted?
                    if (myLastValidAuth != null) {
                        myLastValidAuth = null;
                        continue;
                    }
                }

                myLastValidAuth = null;
                close();
               
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                if (authManager == null) {
                    err = request.getErrorMessage();
                    break;
                }

                realm = myChallengeCredentials.getChallengeParameter("realm");
                realm = realm == null ? "" : " " + realm;
                realm = "<" + myHost.getProtocol() + "://" + myHost.getHost() + ":" + myHost.getPort() + ">" + realm;
                if (httpAuth == null) {
                    httpAuth = authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());
                } else {
                    authManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, request.getErrorMessage(), httpAuth);
                    httpAuth = authManager.getNextAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());
                }
                if (httpAuth == null) {
                    err = SVNErrorMessage.create(SVNErrorCode.CANCELLED, "HTTP authorization cancelled");
                    break;
                }
                myChallengeCredentials.setCredentials((SVNPasswordAuthentication)httpAuth);
                continue;
            } else if (status.getCode() == HttpURLConnection.HTTP_MOVED_PERM || status.getCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
                close();
                String newLocation = request.getResponseHeader().getFirstHeaderValue(HTTPHeader.LOCATION_HEADER);
                if (newLocation == null) {
                    err = request.getErrorMessage();
                    break;
                }
                int hostIndex = newLocation.indexOf("://");
                if (hostIndex > 0) {
                    hostIndex += 3;
                    hostIndex = newLocation.indexOf("/", hostIndex);
                }
                if (hostIndex > 0 && hostIndex < newLocation.length()) {
                    String newPath = newLocation.substring(hostIndex);
                    if (newPath.endsWith("/") &&
                            !newPath.endsWith("//") && !path.endsWith("/") &&
                            newPath.substring(0, newPath.length() - 1).equals(path)) {
                        path += "//";
                        continue;
                    }
                }
                err = request.getErrorMessage();
            } else if (request.getErrorMessage() != null) {
                err = request.getErrorMessage();
            }
            if (err != null) {
                break;
            }
           
            if (myIsProxied) {
                SVNURL location = myRepository.getLocation();
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(true, null);
                }
            }
           
            if (httpAuth != null && realm != null && myRepository.getAuthenticationManager() != null) {
                myRepository.getAuthenticationManager().acknowledgeAuthentication(true, ISVNAuthenticationManager.PASSWORD, realm, null, httpAuth);
View Full Code Here

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

            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 + ")");
                mySocket = SVNSocketFactory.createPlainSocket(proxyAuth.getProxyHost(), proxyAuth.getProxyPort(), connectTimeout, readTimeout);
                if (myProxyAuthentication == null) {
                    myProxyAuthentication = new HTTPBasicAuthentication(proxyAuth.getProxyUserName(), proxyAuth.getProxyPassword(), myCharset);
                }
                myIsProxied = true;
                if (myIsSecured) {
                    HTTPRequest connectRequest = new HTTPRequest(myCharset);
                    connectRequest.setConnection(this);
                    connectRequest.initCredentials(myProxyAuthentication, "CONNECT", host + ":" + port);
                    connectRequest.setProxyAuthentication(myProxyAuthentication.authenticate());
                    connectRequest.setForceProxyAuth(true);
                    connectRequest.dispatch("CONNECT", host + ":" + port, null, 0, 0, null);
                    HTTPStatus status = connectRequest.getStatus();
                    if (status.getCode() == HttpURLConnection.HTTP_OK) {
                        myInputStream = null;
                        myOutputStream = null;
                        mySocket = SVNSocketFactory.createSSLSocket(keyManager != null ? new KeyManager[] { keyManager } : new KeyManager[0], trustManager, host, port, mySocket, readTimeout);
                        proxyAuth.acknowledgeProxyContext(true, null);
                        return;
                    }
                    SVNURL proxyURL = SVNURL.parseURIEncoded("http://" + proxyAuth.getProxyHost() + ":" + proxyAuth.getProxyPort());
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "{0} request failed on ''{1}''", new Object[] {"CONNECT", proxyURL});
                    proxyAuth.acknowledgeProxyContext(false, err);
                    SVNErrorManager.error(err, connectRequest.getErrorMessage(), SVNLogType.NETWORK);
                }
            } else {
                myIsProxied = false;
                myProxyAuthentication = null;
View Full Code Here

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

                }

                err = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "HTTP proxy authorization failed");
                SVNURL location = myRepository.getLocation();
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(false, err);
                }
                close();

                break;
            } else if (status.getCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
                Collection authHeaderValues = request.getResponseHeader().getHeaderValues(HTTPHeader.AUTHENTICATE_HEADER);
                if (authHeaderValues == null || authHeaderValues.size() == 0) {
                    err = request.getErrorMessage();
                    status.setError(SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, err.getMessageTemplate(), err.getRelatedObjects()));
                    if ("LOCK".equalsIgnoreCase(method)) {
                        status.getError().setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
                                "Probably you are trying to lock file in repository that only allows anonymous access"));
                    }
                    SVNErrorManager.error(status.getError(), SVNLogType.NETWORK);
                    return status; 
                }

                //we should work around a situation when a server
                //does not support Basic authentication while we're
                //forcing it, credentials should not be immediately
                //thrown away
                boolean skip = false;
                isAuthForced = myRepository.getAuthenticationManager() != null ? myRepository.getAuthenticationManager().isAuthenticationForced() : false;
                if (isAuthForced) {
                    if (httpAuth != null && myChallengeCredentials != null && !HTTPAuthentication.isSchemeSupportedByServer(myChallengeCredentials.getAuthenticationScheme(), authHeaderValues)) {
                        skip = true;
                    }
                }
               
                try {
                    myChallengeCredentials = HTTPAuthentication.parseAuthParameters(authHeaderValues, myChallengeCredentials, myCharset);
                } catch (SVNException svne) {
                    err = svne.getErrorMessage();
                    break;
                }

                myChallengeCredentials.setChallengeParameter("methodname", method);
                myChallengeCredentials.setChallengeParameter("uri", path);
               
                if (skip) {
                    close();
                    continue;
                }
               
                if (myChallengeCredentials instanceof HTTPNTLMAuthentication) {
                    HTTPNTLMAuthentication ntlmAuth = (HTTPNTLMAuthentication)myChallengeCredentials;
                    if (ntlmAuth.isInType3State()) {
                        continue;
                    }
                } else if (myChallengeCredentials instanceof HTTPDigestAuthentication) {
                    // continue (retry once) if previous request was acceppted?
                    if (myLastValidAuth != null) {
                        myLastValidAuth = null;
                        continue;
                    }
                }

                myLastValidAuth = null;
               
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                if (authManager == null) {
                    err = request.getErrorMessage();
                    break;
                }

                realm = myChallengeCredentials.getChallengeParameter("realm");
                realm = realm == null ? "" : " " + realm;
                realm = "<" + myHost.getProtocol() + "://" + myHost.getHost() + ":" + myHost.getPort() + ">" + realm;
                if (httpAuth == null) {
                    httpAuth = authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());
                } else {
                    authManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, request.getErrorMessage(), httpAuth);
                    httpAuth = authManager.getNextAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());
                }
                if (httpAuth == null) {
                    err = SVNErrorMessage.create(SVNErrorCode.CANCELLED, "HTTP authorization cancelled");
                    break;
                }
                myChallengeCredentials.setCredentials((SVNPasswordAuthentication)httpAuth);
                continue;
            } else if (status.getCode() == HttpURLConnection.HTTP_MOVED_PERM || status.getCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
                close();
                String newLocation = request.getResponseHeader().getFirstHeaderValue(HTTPHeader.LOCATION_HEADER);
                if (newLocation == null) {
                    err = request.getErrorMessage();
                    break;
                }
                int hostIndex = newLocation.indexOf("://");
                if (hostIndex > 0) {
                    hostIndex += 3;
                    hostIndex = newLocation.indexOf("/", hostIndex);
                }
                if (hostIndex > 0 && hostIndex < newLocation.length()) {
                    String newPath = newLocation.substring(hostIndex);
                    if (newPath.endsWith("/") &&
                            !newPath.endsWith("//") && !path.endsWith("/") &&
                            newPath.substring(0, newPath.length() - 1).equals(path)) {
                        path += "//";
                        continue;
                    }
                }
                err = request.getErrorMessage();
            } else if (request.getErrorMessage() != null) {
                err = request.getErrorMessage();
            }
            if (err != null) {
                break;
            }
           
            if (myIsProxied) {
                SVNURL location = myRepository.getLocation();
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(true, null);
                }
            }
           
            if (httpAuth != null && realm != null && myRepository.getAuthenticationManager() != null) {
                myRepository.getAuthenticationManager().acknowledgeAuthentication(true, ISVNAuthenticationManager.PASSWORD, realm, null, httpAuth);
View Full Code Here

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

            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 + ")");
                mySocket = SVNSocketFactory.createPlainSocket(proxyAuth.getProxyHost(), proxyAuth.getProxyPort(), connectTimeout, readTimeout);
                if (myProxyAuthentication == null) {
                    myProxyAuthentication = new HTTPBasicAuthentication(proxyAuth.getProxyUserName(), proxyAuth.getProxyPassword(), myCharset);
                }
                myIsProxied = true;
                if (myIsSecured) {
                    HTTPRequest connectRequest = new HTTPRequest(myCharset);
                    connectRequest.setConnection(this);
                    connectRequest.initCredentials(myProxyAuthentication, "CONNECT", host + ":" + port);
                    connectRequest.setProxyAuthentication(myProxyAuthentication.authenticate());
                    connectRequest.setForceProxyAuth(true);
                    connectRequest.dispatch("CONNECT", host + ":" + port, null, 0, 0, null);
                    HTTPStatus status = connectRequest.getStatus();
                    if (status.getCode() == HttpURLConnection.HTTP_OK) {
                        myInputStream = null;
                        myOutputStream = null;
                        mySocket = SVNSocketFactory.createSSLSocket(keyManager != null ? new KeyManager[] { keyManager } : new KeyManager[0], trustManager, host, port, mySocket, readTimeout);
                        proxyAuth.acknowledgeProxyContext(true, null);
                        return;
                    }
                    SVNURL proxyURL = SVNURL.parseURIEncoded("http://" + proxyAuth.getProxyHost() + ":" + proxyAuth.getProxyPort());
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "{0} request failed on ''{1}''", new Object[] {"CONNECT", proxyURL});
                    proxyAuth.acknowledgeProxyContext(false, err);
                    SVNErrorManager.error(err, connectRequest.getErrorMessage(), SVNLogType.NETWORK);
                }
            } else {
                myIsProxied = false;
                myProxyAuthentication = null;
View Full Code Here

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

                }

                err = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "HTTP proxy authorization failed");
                SVNURL location = myRepository.getLocation();
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(false, err);
                }
                close();

                break;
            } else if (status.getCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
                authAttempts++;//how many times did we try?
               
                Collection authHeaderValues = request.getResponseHeader().getHeaderValues(HTTPHeader.AUTHENTICATE_HEADER);
                if (authHeaderValues == null || authHeaderValues.size() == 0) {
                    err = request.getErrorMessage();
                    status.setError(SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, err.getMessageTemplate(), err.getRelatedObjects()));
                    if ("LOCK".equalsIgnoreCase(method)) {
                        status.getError().setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
                                "Probably you are trying to lock file in repository that only allows anonymous access"));
                    }
                    SVNErrorManager.error(status.getError(), SVNLogType.NETWORK);
                    return status; 
                }

                //we should work around a situation when a server
                //does not support Basic authentication while we're
                //forcing it, credentials should not be immediately
                //thrown away
                boolean skip = false;
                isAuthForced = myRepository.getAuthenticationManager() != null ? myRepository.getAuthenticationManager().isAuthenticationForced() : false;
                if (isAuthForced) {
                    if (httpAuth != null && myChallengeCredentials != null && !HTTPAuthentication.isSchemeSupportedByServer(myChallengeCredentials.getAuthenticationScheme(), authHeaderValues)) {
                        skip = true;
                    }
                }
               
                try {
                    myChallengeCredentials = HTTPAuthentication.parseAuthParameters(authHeaderValues, myChallengeCredentials, myCharset);
                } catch (SVNException svne) {
                    err = svne.getErrorMessage();
                    break;
                }

                myChallengeCredentials.setChallengeParameter("methodname", method);
                myChallengeCredentials.setChallengeParameter("uri", path);
               
                if (skip) {
                    close();
                    continue;
                }
               
                HTTPNTLMAuthentication ntlmAuth = null;
                HTTPNegotiateAuthentication negoAuth = null;
                if (myChallengeCredentials instanceof HTTPNTLMAuthentication) {
                    ntlmAuthIsRequired = true;
                    ntlmAuth = (HTTPNTLMAuthentication)myChallengeCredentials;
                    if (ntlmAuth.isInType3State()) {
                        continue;
                    }
                } else if (myChallengeCredentials instanceof HTTPDigestAuthentication) {
                    // continue (retry once) if previous request was acceppted?
                    if (myLastValidAuth != null) {
                        myLastValidAuth = null;
                        continue;
                    }
                } else if (myChallengeCredentials instanceof HTTPNegotiateAuthentication) {
                    negoAuthIsRequired = true;
                    negoAuth = (HTTPNegotiateAuthentication)myChallengeCredentials;
                    if (negoAuth.isStarted()) {
                        continue;
                    }
                }

                myLastValidAuth = null;

                if (ntlmAuth != null && ntlmAuth.isNative() && authAttempts == 1) {
                    /*
                     * if this is the first time we get HTTP_UNAUTHORIZED, NTLM is the target auth scheme
                     * and JNA is available, we should try a native auth mechanism first without calling
                     * auth providers.
                     */
                    continue;
                }

                if (negoAuth != null) {
                    continue;
                }

                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                if (authManager == null) {
                    err = request.getErrorMessage();
                    break;
                }

                realm = myChallengeCredentials.getChallengeParameter("realm");
                realm = realm == null ? "" : " " + realm;
                realm = "<" + myHost.getProtocol() + "://" + myHost.getHost() + ":" + myHost.getPort() + ">" + realm;
               
                if (httpAuth == null) {
                    httpAuth = authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());
                } else {
                    authManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, request.getErrorMessage(), httpAuth);
                    httpAuth = authManager.getNextAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());
                }
               
                if (httpAuth == null) {
                    err = SVNErrorMessage.create(SVNErrorCode.CANCELLED,
                            "HTTP authorization cancelled");
                    break;
                }
                if (httpAuth != null) {
                    myChallengeCredentials.setCredentials((SVNPasswordAuthentication)httpAuth);
                }
                continue;
            } else if (status.getCode() == HttpURLConnection.HTTP_MOVED_PERM || status.getCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
                close();
                String newLocation = request.getResponseHeader().getFirstHeaderValue(HTTPHeader.LOCATION_HEADER);
                if (newLocation == null) {
                    err = request.getErrorMessage();
                    break;
                }
                int hostIndex = newLocation.indexOf("://");
                if (hostIndex > 0) {
                    hostIndex += 3;
                    hostIndex = newLocation.indexOf("/", hostIndex);
                }
                if (hostIndex > 0 && hostIndex < newLocation.length()) {
                    String newPath = newLocation.substring(hostIndex);
                    if (newPath.endsWith("/") &&
                            !newPath.endsWith("//") && !path.endsWith("/") &&
                            newPath.substring(0, newPath.length() - 1).equals(path)) {
                        path += "//";
                        continue;
                    }
                }
                err = request.getErrorMessage();
            } else if (request.getErrorMessage() != null) {
                err = request.getErrorMessage();
            } else {
                ntlmProxyAuthIsRequired = false;
                ntlmAuthIsRequired = false;
                negoAuthIsRequired = false;
            }
           
            if (err != null) {
                break;
            }
           
            if (myIsProxied) {
                SVNURL location = myRepository.getLocation();
                ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();
                ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(location) : null;
                if (proxyManager != null) {
                    proxyManager.acknowledgeProxyContext(true, null);
                }
            }
           
            if (httpAuth != null && realm != null && myRepository.getAuthenticationManager() != null) {
                myRepository.getAuthenticationManager().acknowledgeAuthentication(true, ISVNAuthenticationManager.PASSWORD, realm, null, httpAuth);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.