| View previous topic :: View next topic |
| Author |
Message |
IveCal Guest
|
Posted: Mon Apr 17, 2006 6:12 am Post subject: "NetworkCredential" |
|
|
Hello, guys... What is the Java equivalent class for C# class
"NetworkCredential"? Please reply. .Thanks |
|
| Back to top |
|
 |
Oliver Wong Guest
|
Posted: Mon Apr 17, 2006 5:12 pm Post subject: Re: "NetworkCredential" |
|
|
"IveCal" <ive.cal (AT) gmail (DOT) com> wrote in message
news:1145252105.787400.239240 (AT) u72g2000cwu (DOT) googlegroups.com...
| Quote: | Hello, guys... What is the Java equivalent class for C# class
"NetworkCredential"? Please reply. .Thanks
|
I couldn't find the "NetworkCredential" class. Did you perhaps mean the
System.Net.ICredentials interface?
There isn't nescessarily a one to one correspondence between C# classes
and Java classes. You'll probably get more answers if you explain the
problem you're trying to solve, and ask questions indicating where you're
stuck.
- Oliver |
|
| Back to top |
|
 |
Roedy Green Guest
|
Posted: Mon Apr 17, 2006 7:12 pm Post subject: Re: "NetworkCredential" |
|
|
On 16 Apr 2006 22:35:05 -0700, "IveCal" <ive.cal (AT) gmail (DOT) com> wrote,
quoted or indirectly quoted someone who said :
| Quote: | Hello, guys... What is the Java equivalent class for C# class
"NetworkCredential"? Please reply. .Thanks
|
I am not familiar with C#, but the name suggests you might look at
http://mindprod.com/jgloss/authentication.html
or possibly
http://mindprod.com/jgloss/ssl.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching. |
|
| Back to top |
|
 |
IveCal Guest
|
Posted: Thu Apr 20, 2006 7:12 am Post subject: Re: "NetworkCredential" |
|
|
The code snippet below shows the use of NetworkCredential...
I'm curious over the object (networkCredential in this case) it creates
because it was used once only for authentication purposes... (exactly
before accessing the webpage...) Do you have any idea how is this going
to be implemented in Java? Thanks...
void Page_Load(Object sender, EventArgs e) {
XmlDocument doc = new XmlDocument();
NetworkCredential networkCredential = new
NetworkCredential("username","password"); ==> THIS IS WHAT I MEAN...
HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create(
"http://api.keyworddiscovery.com/free.php?q="
+ HttpUtility.UrlEncode(Request.Form["query"])
);
HttpWReq.PreAuthenticate = true;
HttpWReq.Credentials = networkCredential;
HttpWebResponse HttpWResp =
(HttpWebResponse)HttpWReq.GetResponse();
if (HttpWResp.StatusCode == HttpStatusCode.OK) {
doc.Load(HttpWResp.GetResponseStream());
}
XslTransform trans = new XslTransform();
trans.Load(Server.MapPath("output_template.xsl"));
xml1.Document = doc;
xml1.Transform = trans;
} |
|
| Back to top |
|
 |
Oliver Wong Guest
|
Posted: Thu Apr 20, 2006 3:12 pm Post subject: Re: "NetworkCredential" |
|
|
"IveCal" <ive.cal (AT) gmail (DOT) com> wrote in message
news:1145515682.514898.187790 (AT) i40g2000cwc (DOT) googlegroups.com...
| Quote: | The code snippet below shows the use of NetworkCredential...
I'm curious over the object (networkCredential in this case) it creates
because it was used once only for authentication purposes... (exactly
before accessing the webpage...) Do you have any idea how is this going
to be implemented in Java? Thanks...
void Page_Load(Object sender, EventArgs e) {
XmlDocument doc = new XmlDocument();
NetworkCredential networkCredential = new
NetworkCredential("username","password"); ==> THIS IS WHAT I MEAN...
HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create(
"http://api.keyworddiscovery.com/free.php?q="
+ HttpUtility.UrlEncode(Request.Form["query"])
);
HttpWReq.PreAuthenticate = true;
HttpWReq.Credentials = networkCredential;
HttpWebResponse HttpWResp =
(HttpWebResponse)HttpWReq.GetResponse();
if (HttpWResp.StatusCode == HttpStatusCode.OK) {
doc.Load(HttpWResp.GetResponseStream());
}
XslTransform trans = new XslTransform();
trans.Load(Server.MapPath("output_template.xsl"));
xml1.Document = doc;
xml1.Transform = trans;
}
|
Looks like it's doing HTTP authentication. Try:
http://java.sun.com/j2se/1.5.0/docs/api/java/net/Authenticator.html
and
http://java.sun.com/j2se/1.5.0/docs/api/java/net/PasswordAuthentication.html
- Oliver |
|
| Back to top |
|
 |
IveCal Guest
|
Posted: Wed Apr 26, 2006 2:12 am Post subject: Re: "NetworkCredential" |
|
|
| Thanks a lot MR. Oliver Wong... Thanks... |
|
| Back to top |
|
 |
|