hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Re: SSL with Certificate
Date Fri, 29 Jul 2005 12:49:15 GMT
Michael, what is the value of servletPath?

Oleg


On Fri, Jul 29, 2005 at 08:46:21AM -0400, Michael Clovis wrote:
> 
> Oleg thanks in advance..
> 
>  This is from the class that extends HttpClient.. all methods prepare servlet request
first like so.. 
> 
> 
> public boolean authorizeIS(){
> 		NameValuePair[] form_data = new NameValuePair[8];
> 		form_data[0] = new NameValuePair("sourceid", SOURCE_ID);		//APPLICATION ID
> 		form_data[1] = new NameValuePair("destid", DEST_ID); 			//DEST ID
> 		form_data[2] = new NameValuePair("requesttype",BULKLOADERSESSIONID_REQ);	//TYPE OF
REQUEST
> 		form_data[3] = new NameValuePair("requestid", "111");			//ID OF THE REQUEST
> 		form_data[4] = new NameValuePair("username",isUser);			//USER ID
> 		form_data[5] = new NameValuePair("password",isPass);			//PASSWORD
> 		form_data[6] = new NameValuePair("sent",Long.toString(System.currentTimeMillis()));
> 		form_data[7] = new NameValuePair("ntlmlogin",ntlmlogin);
> 		
> 		StringBuffer servBuff = new StringBuffer(servletPath);
> 		servBuff.append("?sourceid=").append(SOURCE_ID).append("&destid=").append(DEST_ID);
> 		//System.out.println(servBuff.toString());
> 		
> 		ReqResult reqRes = this.sendRequest(servBuff.toString(), form_data, "Session");
> 		if(reqRes == null){
>  System.out.println("Requested Result is null");
> 			//writeErrLog("Request Result was null", SERVLET_ERR);
> 			return false;
> 		}
> 		
> 		System.out.println("Request result: " + reqRes.isAccepted());
> 		
> 		if(reqRes.isAccepted()){
> 			this.sessionID = reqRes.getSessionId();
>  this.isAdmin = reqRes.isAdmin();
> 			System.out.println("SESSION ID: " + this.sessionID);
>  System.out.println("UserAdmin: "+isAdmin);
> 		}else{
> 			writeErrLog(reqRes.getErrorMessage(),Integer.parseInt(reqRes.getErrorCode()));
> 			return false;
> 		}
> 		
> 		return true;
> 	}
> 
> ... sendRequest is where PostMethod is executed as follows...
> 
> 
> protected ReqResult sendRequest(String host, NameValuePair[] data, String resultType){
> 		PostMethod post = new PostMethod(host);
> 		post.addParameters(data);
>  try {
>  return sendRequest(post, resultType);
>  } catch (Exception e) {
>  this.writeErrException(e);
>  e.printStackTrace();
>  //throw e;
>  return null;
>  }
> 
>  }
> 	
> 	protected ReqResult sendRequest(ExpectContinueMethod post, String resultType){
> 		ReqResult reqResult = null;
> 		post.setDoAuthentication(true);
> 		try{
> 			this.executeMethod(post);
> 			
> 			//handle any errors that'll come down the pipe
> 			if(post.getStatusCode() >= 300){
> 				writeErrLog(post.getStatusLine().getReasonPhrase(), post.getStatusCode());
> 				return null;
> 			}
> 			
> 			String responseBody = new String(post.getResponseBodyAsString());
>  System.out.println(responseBody);
> 			reqResult = new ReqResult(responseBody, resultType);
> 			
> 		}catch(HttpException hte){
> 			this.writeErrException(hte);
> 			hte.printStackTrace();
> 		}catch(IOException ioe){
> 			this.writeErrException(ioe);
> 			ioe.printStackTrace();
> 		}
>  catch(Exception e){
>  this.writeErrException(e);
>  e.printStackTrace();
>  }
> 		return reqResult;
> 	}
> 
> I again appreciate in advance your insight!
> 
> 
> ---------- Original Message ----------
> Date: 7/29/05
> From: Oleg Kalnichevski <olegk@apache.org>
> To: httpclient-user@jakarta.apache.org
> Subject: Re: SSL with Certificate
> 
> >Michael,
> >
> >Could you please post a code snippet showing how the HttpMethod is
> >instantiated and executed?
> >
> >Oleg
> >
> >
> >On Thu, Jul 28, 2005 at 05:52:30PM -0400, Michael Clovis wrote:
> >> I am maintaining an application that is using HTTPClient 2.0.2 and one clas=
> >> s extends HttpClient in particular ( one reason for not upgrading to 3x). N=
> >> eed to support SSL and have started to test code using self-signed certs. M=
> >> ade sure through Apache the servlet the application accesses can not be acc=
> >> essed other than through SSL and wire info reads that the header informatio=
> >> n can be seen yet when method is sent to servlet get a 401. Furthermore doi=
> >> ng tcpdumps reveal app never ran on port 443 but port 80. Am using simple p=
> >> aradigm (as in example code) of :
> >> 
> >> StrictSSLProtocolSocketFactory sf =3D new StrictSSLProtocolSocketFactory()=
> >> ;
> >> =20
> >> 
> >> Protocol stricthttps =3D new Protocol( "https", sf, 443);
> >> Protocol.registerProtocol("https",stricthttps);
> >> // du is client instance du.getHostConfiguration().setHost(this.hostname.ge=
> >> tText().trim(),443,stricthttps)
> >> 
> >> 
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message