Using Azure EventHub behind a proxy with authentication - java

UPDATE
There are some News on that, see here: https://blogs.msdn.microsoft.com/eventhubs/2018/09/21/azure-event-hubs-websockets-and-proxy-support/
====
Azure's EventProcessorHost can be used to register and EventProcessor against an EventHub:
EventProcessorHost host = new EventProcessorHost(
EventProcessorHost.createHostName(null),
connectionStringBuilder.getEventHubName(),
"$Default",
ConnectionStringBuilder.toString(),
this.storageConnectionString,
this.storageContainerName
);
host.registerEventProcessor(MyEventProcessor.class, options).get();
One can add a proxy beforehand:
OperationContext.setDefaultProxy(
new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.url.com", 1234))
);
Question: How to provide an authentication (username/password) to this proxy?

TLDR: EventProcessorHost java library doesn't support proxy yet. This is a feature under construction.
Event Hubs Java Client sdk currently uses AMQPs protocol over TCP (on socket 5671, standard port assigned by IANA) to communicate to Event Hubs Service. We just built, support for Websockets transport; here' the PR. Building a snapshot version on dev branch and adding parameter TransportType=AmqpWebSockets in the ConnectionString should enable the client to talk to the EventHubs service over port 443.
We are building support for proxy using basic auth - by end of September. follow this for updates.

Related

Java client connectivity issue - OPC DA

Recent Microsoft patch has broken our Java client connectivity to OPC server. Microsoft raised Authentication level to Packet Integrity. we are using Utgard java OPC library to connect to OPC server which internally uses Jinterop java based COM library. with the patch Our client is not able to add subscription groups to listen to the data changes on the OPC server. We couldn't find where in the library the authentication level is configured. if we can configure it ti DEFAULT the issue will be resolved.
Please let me know if you have any pointers on this.
JISession session = JISession.createSession(ipAddress,userName,pasword);
JIComServer comServer = new JIComServer(JIClassId.valueOf(classId), address, session);
IJIComObject instance = comServer.createInstance();
IJIComObject opcServer = new OPCServer(instance);
//after we will create access base groups and add them to the server, during attaching handler it is failing.
ERROR
*JIException: The RPC server is unavailable. Please check if the COM server is up and running and that route to the COM Server is accessible (A simple "Ping" to the Server machine would do). Also please confirm if the Windows Firewall is not blocking DCOM access. [0x800706BA]
at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:1004) at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:951) at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:293) at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:159) at org.jinterop.dcom.core.JIFrameworkHelper.attachEventHandler(JIFrameworkHelper.java:285) at org.openscada.opc.dcom.da.impl.OPCGroupStateMgt.attach(OPCGroupStateMgt.java:179)
*

Channel binding when connecting in Java to LDAP server - is it possible?

Microsoft has new patch with LDAP connection.
Servers with this patch will not accept connections with no 'channel binding'
My code connects today with 'InitialLdapContext'.
I'm preparing the env and create a new InitialLdapContext.
LDAP/LDAPs working fine.
After this patch,
Will servers reject LDAPs connection?
Will I have to add channel binding handling?
I don't see that InitialLdapContext has channel binding handling.

Jersey Client gives read timeout but Apache HTTP Client connects normally

I was using Jersey 2.25 client with Jackson, I configured everything correctly in Jersey, it worked normally on my development machine when I ran it in a test class, but Jersey client could never connect to a certain host that we have when deployed on our STG environment and always throws a read timeout exception.
I also know that the problem is not in our environment because I can connect using curl
But when switched to HTTPClient it worked normally.
This is how we created our Jersey Client:
Client client = ClientBuilder.newBuilder()
.register(JacksonFeature.class)
.property(ClientProperties.CONNECT_TIMEOUT,5000)
.property(ClientProperties.READ_TIMEOUT,15000)
.build();
The only difference here is the flow of the app, and also the major change that happens in the flow that could affect the connection is that somewhere before calling the Jersey client another class sets a proxy in the system config:
System.setProperty("http.proxyHost",strProxyHost);
System.setProperty("http.proxyPort",strProxyPort);
System.setProperty("https.proxyHost",strProxyHost);
System.setProperty("https.proxyPort",strProxyPort);
However we can establish a connection normally using HTTPClient:
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setConnectionTimeout(5000);
params.setSoTimeout(10000);
HttpConnectionManager manager = new SimpleHttpConnectionManager();
manager.setParams(params);
HttpClient httpClient = new HttpClient(manager);
We are using HTTPClient 3 because part of this app is legacy and we cannot update the version, but it works normally.
What could be causing this connection problem with Jersey? is there something global that Jersey reads when it's trying to connect?
Jersey by default uses HttpURLConnection and HttpURLConnection uses following global settings for proxy configuration -
System.setProperty("http.proxyHost",strProxyHost);
System.setProperty("http.proxyPort",strProxyPort);
System.setProperty("https.proxyHost",strProxyHost);
System.setProperty("https.proxyPort",strProxyPort);
It means if these system variables are set, Jersey will send all the requests through this configured proxy. Check Details here
However, Apache HttpClient does not follow these settings. For using proxy in Apache HttpClient, you have to use HostConfiguration class. Check details here
So, now to your problem, It looks that your STG environment is not able to connect to specified proxy but able to connect with the service directly.
So, while using Jersey, client is not able to connect to proxy and hence ReadTimeoutException is occurring. Since, you haven't configured HttpClient for using any proxy, it is able to connect with the service directly.

JAX-WS client authentication on proxy server

I'm trying to use JAX-WS api to send some soap messages on a client application. However, I'm behind a firewall and the only option is to use a proxy server to go outside.
I'm trying to find on google any answer about this and so far all fail: To Use System.setProperty for http.proxyHost, http.proxyPort, http.proxyUser, http.proxyPassword. To use Authenticator like is described here.
I'm running out of options, if someone could help me on this would be great.
Also, I have a option to use org.apache.commons.httpclient but then I need to generate manually the XML. So could you suggest any other approach or API for WS?
You can use ws import command when creating web client to configure proxy.
-httpproxy::
use above command to configure proxy.
How to do this depend on your IDE.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/rwbs_wsimport.html
For Jax-ws webservice client, use the following
//set proxy info to the ClientProxyFeature
ClientProxyFeature cpf = new ClientProxyFeature();
cpf.setProxyHost("proxyhost");
cpf.setProxyPort(8888);
cpf.setProxyUserName("proxyuser");
cpf.setProxyPassword("proxypwd");
//get the port with the Feature
MyPort port = myService.getPort(cpf);

How to Connect to a web service (SSL enabled and proxy interface)

There is a web service running on tomcat on a server. It is built on Java Servlet. It is listening others to call itself on a SSL enabled http port. so its web service adreess looks
like: https://172.29.12.12/axis/services/XYZClient?wsdl
On the other hand I want to connect the web service above from a windows application which is built on .NET frame work.
Finally, when I want to connect the web service from my computer; I get some specific erros;
Firstly I get; Proxy authentication error; then I added some new line to my code;
Dim cr As System.Net.NetworkCredential = New System.Net.NetworkCredential("xname", "xsurname", "xdomainname")
Dim myProxy As New WebProxy("http://mar.xxxyyy.com", True)
myProxy.Credentials = cr
Secondly, after this modifications It says that bad request.
I did not get over this error.
Moreover I did try to connect the web server on the same computer. I copied my executable program to the computer where the web service runs. The error was like;
The underlying connection was closed:
Could not establish trust relationship
for SSL/TLS secure channel
PS: When I try to connect to web service by using Internet Explorer; I see firstly some warnings about accepting an unknown certificate and I click take me to web service an I get there clearly.
I want to know what are the basic elements to connect a web service, could you please tell me the requirements that I have to use on my windows project.
regards bk
This page offers a simple step-by-step guide on building a web service client with C#.NET.
Step 5 on this page shows how to add a certificate to your trusted store and Step 6 is another way to build a very simple web service client in C#.NET.

Categories