hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Filiz (JIRA)" <j...@apache.org>
Subject [jira] Created: (HTTPCLIENT-1025) Can't connect HttpUrl wiht Authentication
Date Tue, 30 Nov 2010 15:14:11 GMT
Can't connect HttpUrl wiht Authentication
-----------------------------------------

                 Key: HTTPCLIENT-1025
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1025
             Project: HttpComponents HttpClient
          Issue Type: New Feature
          Components: HttpAuth, HttpClient
         Environment: Windows 7,
Eclipse Galelio Eclipse 
Java EE IDE for Web Developers.

Build id: 20100218-1602

Android 2.2 
            Reporter: Filiz


Hi,
I have a service that gives xml data. But it didn't connect, I reseach all of documents on
internet  and you site, I develop my code on you site example
I give the example of my code :

protected InputStream getInputStream() {
		try {
			SchemeRegistry schemeRegistry = new SchemeRegistry();

    		// http scheme
    		schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    		// https scheme
    		schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443));

    		params = new BasicHttpParams();
    		params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 1);
    		params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(1));
    		params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
    		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    		HttpProtocolParams.setContentCharset(params, "utf8");

    		// ignore that the ssl cert is self signed
    		CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    		credentialsProvider.setCredentials(new AuthScope("www.yemeksepeti.com", AuthScope.ANY_PORT),
    				new UsernamePasswordCredentials("cs_basari", "bas0102ari"));
    		clientConnectionManager = new ThreadSafeClientConnManager(params, schemeRegistry);

    		context = new BasicHttpContext();
    		context.setAttribute("http.auth.credentials-provider", credentialsProvider);
    		 System.out.println("----------------yemeksepetiandroid-----------------------http://www.yemeksepeti.com/YemeksepetiCatalogWebService/CatalogExportMobile.asmx/Mobile_GetCities?");
             
    		DefaultHttpClient client = new DefaultHttpClient(clientConnectionManager, params);
    		HttpGet get = new HttpGet("http://www.yemeksepeti.com/YemeksepetiCatalogWebService/CatalogExportMobile.asmx/Mobile_GetCities?");
    		HttpResponse response = client.execute(get, context);
    	    HttpEntity entity = response.getEntity();
            System.out.println(response.getStatusLine());
            if (entity != null) {
                System.out.println("Response content length: " + entity.getContentLength());
            }
           return entity.getContent();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	static class PreemptiveAuth implements HttpRequestInterceptor {

        public void process(
                final HttpRequest request, 
                final HttpContext context) throws HttpException, IOException {
            
            AuthState authState = (AuthState) context.getAttribute(
                    ClientContext.TARGET_AUTH_STATE);
            
            // If no auth scheme avaialble yet, try to initialize it preemptively
            if (authState.getAuthScheme() == null) {
                AuthScheme authScheme = (AuthScheme) context.getAttribute(
                        "preemptive-auth");
                CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
                        ClientContext.CREDS_PROVIDER);
                HttpHost targetHost = (HttpHost) context.getAttribute(
                        ExecutionContext.HTTP_TARGET_HOST);
                if (authScheme != null) {
                    Credentials creds = credsProvider.getCredentials(
                            new AuthScope(
                                    targetHost.getHostName(), 
                                    targetHost.getPort()));
                    if (creds == null) {
                        throw new HttpException("No credentials for preemptive authentication");
                    }
                    authState.setAuthScheme(authScheme);
                    authState.setCredentials(creds);
                }
            }
            
        }


    }



And it gives these error log:

11-30 16:41:08.902: WARN/etAuthenticationHandler(629): Authentication scheme ntlm not supported
11-30 16:41:08.932: WARN/DefaultRequestDirector(629): Authentication error: Unable to respond
to any of these challenges: {ntlm=WWW-Authenticate: NTLM, negotiate=WWW-Authenticate: Negotiate}
11-30 16:41:08.952: INFO/System.out(629): HTTP/1.1 401 Unauthorized
11-30 16:41:08.952: INFO/System.out(629): Response content length: 1656
11-30 16:42:56.021: WARN/jdwp(629): Debugger is telling the VM to exit with code=1
11-30 16:42:56.021: INFO/dalvikvm(629): GC lifetime allocation: 2845 bytes
11-30 16:42:56.342: DEBUG/Zygote(33): Process 629 exited cleanly (1)
11-30 16:42:56.382: INFO/ActivityManager(69): Process com.basarimobile.android.yemeksepeti
(pid 629) has died.
11-30 16:42:56.442: INFO/WindowManager(69): WIN DEATH: Window{4511be98 com.basarimobile.android.yemeksepeti/com.basarimobile.android.yemeksepeti.Login
paused=false}
11-30 16:42:56.602: INFO/UsageStats(69): Unexpected resume of com.android.launcher while already
resumed in com.basarimobile.android.yemeksepeti
11-30 16:42:56.692: WARN/InputManagerService(69): Got RemoteException sending setActive(false)
notification to pid 629 uid 10036

        

How I can solve my problem thanks?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message