Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling IIS web page from java (that is deployed in Weblogic) using Windows security

 
get started
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble calling a IIS webpage, which enables Windows security. The code works fine in stand alone Java application, but not after deploying to weblogic.

Here is the sample code:

String auth = domain + "\\" + userName ":" + password;
String encodedAuth = new BASE64Encoder().encode(auth.getBytes());
URL url = new URL(serviceURL);
URLConnection yc = url.openConnection();
yc.setRequestProperty ("Authorization", "Basic " + encodedAuth);
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));

How do we specify windows authentication? Is it the correct way? Thanks,
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think URLConnection supports Windows Security. If that's the same as NTLM, then check out HttpClient - it supports that.
 
get started
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where do I specify domain name? this is only accepting username and password?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try "domain\user" for your user name.
 
get started
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpMethodBase method = null;
try {
HttpClient client = new HttpClient();
client.getState().setCredentials(AuthScope.ANY,
new NTCredentials(userName, pwd, host, domain) );
System.out.println(httpServiceURL);

method = new GetMethod(httpServiceURL);
method.setDoAuthentication( true );
int status = client.executeMethod(method);
System.out.println(status + "\n" + method.getResponseBodyAsString());
}

This works fine on stand alone java application, but when I deploy it to Weblogic.. it just hangs at GetMethod. No exception, nothing..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic