HttpConnectorAddress httpConnectorAddress = new HttpConnectorAddress(habitat.getComponent(SSLUtils.class).getAdminSocketFactory(certAlias, "TLS"));
AuthenticationInfo authenticationInfo = authenticationInfo(habitat, secureAdmin);
if (authenticationInfo != null) {
httpConnectorAddress.setAuthenticationInfo(authenticationInfo);
}
HttpURLConnection httpURLConnection = (HttpURLConnection) httpConnectorAddress.openConnection(url); // The URL constructed for REST will always be Http(s) so, it is ok to cast here.
//Hack - httpConnectorAddress calls httpURLConnection.setRequestProperty("Content-type", "application/octet-stream"); before returning connection above
//Our resources are only capable of accepting xml, json and form. Override here to apploication/json (randomly picked one of the three). This should not be required after HttpConnectorAddress refactoring in trunk.
httpURLConnection.setRequestProperty("Content-type", "application/json");
return httpURLConnection;
}