Reputation: 1179
I want to write a Java Websocket client which needs digest authentication to authenticate at a server.
I played around with the Jetty Websocket client example but I have no idea how to easily add the digest authentication. Furthermore I found no online resources which give a hint on how it could be done.
I also find it quite hard to find information online as most people use Jetty as server (obviously). For example this is not a duplicate: How to authenticate websocket client in jetty?
Therefore I am wondering if it is possible to use digest authentication with the Jetty Websocket client?
Upvotes: 0
Views: 1243
Reputation: 21
you can try these two method:
put your username and password in the websocket url.
eg. ws://username:[email protected]/resturl
generate Authorization and put this to the request header.
String userpass = accessKey + ":" + secretKey;
String authorization = "Basic " + new String(new Base64().encode(userpass.getBytes())).trim();
ClientUpgradeRequest request = new ClientUpgradeRequest();
request.setHeader("Authorization", authorization);
Upvotes: 2