This content has been marked as final. Show 4 replies
885522 wrote:Or the credentials are in fact wrong. I'm rusty, but I believe the password needs to be Base64 encoded.
It says unauthorised for the url.
Does that mean the authenticator is not being called?
Is there any other authentication configuration missing on the server.The server seems to be doing its job - keeping you out. So the authentication configuration must be present.
Thanks so much for the reply.
The credentials are correct.If I paste the same url in my IE .I am prompted for userid and password and I give the same credentials
it works fine and the url opens up.
Its only when i try to connect from Java it is giving unauthorised error 401.
Strangely I dont know why the systemouts in ReportAuthenticator are now showing up?
How can I try to have password as base64 authenticated.I have tried changing
Still the same error looks like the authenticator class is not working .
I have been struggling with this for a couple of days now and still no solution Please help
repCon.setRequestMethod("POST");"POST" is the default when you call doOutput(true). Remove that.
repCon.setRequestProperty("Content-type", "application/pdf" );You are sending a PDF? Doesn't seem likey, as you have it in a String. Remove that.
repCon.setRequestProperty("Content-length", Integer.toString(parameterString.length()));Don't set that. Java will do it, and do it accurately. Remove that.
repCon.setRequestProperty("Authorization","Basic");The Authenticator will do this when necessary. Remove that. At present you are saying there is authorization with the request even when there isn't (i.e. the first time, before the server asks for it).
Does that mean the authenticator is not being called?You can test that for yourself.
Is there any other authentication configuration missing on the server.You've already overdone it. Try the changes mentioned above.