• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTP Get Request with authentication, file Saving and play a sound  RSS feed

 
Greenhorn
Posts: 8
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey

I have a few problems with a tool I am writing >.>
It is a desktop notification tool for our intranet social feed (with sharepoint 2013)

1. I use the 1. Java HttpURLConnection example from mkyong
http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/
but I need an authentication (simple a login name and password),
do you have an excample?

2. I save the received xml String in a file, problem:
my tool will be used under windows and linux (and maybe appleOS)
so where to store the files and how?

3. last is (maybe) the easy part:
I have a small .wav file and want it to be played *yay*

maybe someone can help me with my "small" problems >.>

greetings
Rob
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

#1: http://stackoverflow.com/questions/496651/connecting-to-remote-url-which-requires-authentication-using-java lists a couple of approaches. I found that by searching for "httpurlconnection authentication".

#2: A subdirectory of the directory where the app is installed might work, or a subdirectory of the user's home directory.

#3: See http://stackoverflow.com/questions/2416935/how-to-play-wav-files-with-java. I found that by searching for "java play wav".
 
Rob Ko
Greenhorn
Posts: 8
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply

#2 is now finished, thans

#1 is the most important now,
after contacting the server admins:
need to authenticate via NTLM, but
I don't really know how

found this:
http://hc.apache.org/httpcomponents-client-4.3.x/ntlm.html
but I'm a bit confused about the code

tried it, but there was also an error in generateType3Msg method


The constructor Type3Message(Type2Message, String, String, String, String, int) is undefined


and I'm also not sure about implementing the NTCredentials

looking forward to your replies

greetings Rob
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're supposed to use NTLM, then the link I posted is irrelevant; it's about HTTP basic auth. you should definitely use the HttpComponents library in that case. Start with the "client auth" example in http://hc.apache.org/httpcomponents-client-4.3.x/examples.html, but using NTCredentials. I would leave the jCIFS stuff aside, unless you have a specific reason to think it's applicable in your case; I think that may be server-side stuff.

I'm also not sure about implementing the NTCredentials

What specifically? The 4-argument constructor seems pretty straightforward...?
 
Rob Ko
Greenhorn
Posts: 8
Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
more like: how to implement the NTCredentials into the code



what is the difference between host and domain ? usally www.youtube.com and youtube.com
it is an intranet, so we don't use www ^-^
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With all due respect, if you don't know what a "domain" is in the context of Windows, then you may not be the right person to implement authentication (it has nothing to do with URLs). Your network admin can tell you what it is.

Not sure where you got the "urlString" parameter from - the javadocs mention nothing of the sort: http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/auth/NTCredentials.html. The 3rd and 4th parameters are workstation name and domain, respectively.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!