entity.removeHeaders("Transfer-Encoding");
entity.removeHeaders("Content-Type");
entity.setEntity(null);
}
BasicHttpContext ctx = new BasicHttpContext();
if (AsyncHTTPConduit.this.proxyAuthorizationPolicy != null
&& AsyncHTTPConduit.this.proxyAuthorizationPolicy.getUserName() != null) {
ctx.setAttribute(ClientContext.CREDS_PROVIDER, new CredentialsProvider() {
public void setCredentials(AuthScope authscope, Credentials credentials) {
}
public Credentials getCredentials(AuthScope authscope) {
return new UsernamePasswordCredentials(AsyncHTTPConduit.this
.proxyAuthorizationPolicy.getUserName(),
AsyncHTTPConduit.this.proxyAuthorizationPolicy.getPassword());
}
public void clear() {
}
});
}
if (tlsClientParameters != null && tlsClientParameters.hashCode() == lastTlsHash && sslState != null) {
ctx.setAttribute(ClientContext.USER_TOKEN , sslState);
}
final AsyncSchemeRegistry reg = new AsyncSchemeRegistry();
reg.register(new AsyncScheme("http", 80, null));
if ("https".equals(url.getScheme())) {
try {
// check tlsClientParameters from message header
TLSClientParameters tlsClientParameters = outMessage.get(TLSClientParameters.class);
if (tlsClientParameters == null) {
tlsClientParameters = getTlsClientParameters();
}
if (tlsClientParameters == null) {
tlsClientParameters = new TLSClientParameters();
}
final SSLContext sslcontext = getSSLContext(tlsClientParameters);
reg.register(new AsyncScheme("https", 443, new SSLLayeringStrategy(sslcontext) {
@Override
protected void initializeEngine(SSLEngine engine) {
initializeSSLEngine(sslcontext, engine);
}
@Override
protected void verifySession(final IOSession iosession,
final SSLSession sslsession) throws SSLException {
super.verifySession(iosession, sslsession);
iosession.setAttribute("cxf.handshake.done", Boolean.TRUE);
CXFHttpRequest req = (CXFHttpRequest)iosession
.removeAttribute(CXFHttpRequest.class.getName());
if (req != null) {
req.getOutputStream().setSSLSession(sslsession);
}
}
}));
} catch (GeneralSecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
ctx.setAttribute(ClientContext.SCHEME_REGISTRY, reg);
connectionFuture = new BasicFuture<Boolean>(callback);
DefaultHttpAsyncClient c = getHttpAsyncClient();
CredentialsProvider credProvider = c.getCredentialsProvider();
Credentials creds = (Credentials)outMessage.getContextualProperty(Credentials.class.getName());
if (creds != null && credProvider != null) {
credProvider.setCredentials(AuthScope.ANY, creds);
}
if (credProvider != null && credProvider.getCredentials(AuthScope.ANY) != null) {
ctx.setAttribute(ClientContext.USER_TOKEN,
credProvider.getCredentials(AuthScope.ANY).getUserPrincipal());
}
c.execute(new CXFHttpAsyncRequestProducer(entity, outbuf),
new CXFHttpAsyncResponseConsumer(this, inbuf, responseCallback),