on 03-02-2009 2:36 PM
Hi all,
I need to open a file from KM using its absolute URL (i.e. http://<hostname>/irj/.../<filename>) from a WD java.
I tried to use the URL class to access this file but I have 401 error.
How can I authenticate to the portal from Java?
Best Regards,
Raffaele Frattini
Hi,
How can I authenticate to the portal from Java?
You can use the HTTPClient which is available from apache to do this in Java, If its webdynpro do what sanyev have mentioned above
HTTPClient and its corresponding jars can be downloaded from apache website.
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
first of all thanks for all your replies, however Sanyev solution doesn't work, because I try to open a new Http connection which is independent from the connection to the portal.
But I found a solution, using the class HttpURLConnection and the method setRequestProperty of this class.
Best Regards,
Raffaele Frattini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Venkata,
below you can find some code lines neded for the Basic Authentication:
URL url = new URL("The URL in String format");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
String userPass = <username> + ":"+ <password>;
String encoding = new BASE64Encoder().encode(userPass.getBytes());
conn.setRequestProperty("Authorization", "Basic " + encoding);
InputStream in = conn.getInputStream();
I hope this help you.
Regards,
Raffaele Frattini
Hi,
I've already tried to do this, but it doesn't work.
Any other suggestion?
Best Regards,
Raffaele Frattini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raffaele,
When you are accessing the KM folders through webdynpro, Webdynpro will use the same user permission to access the file. If that user does not have permission to access the content then you will get an authentication error.
So while testing the application it might not work. Integrate your application to the portal and try. Then it will use the logged in user to access the KM folder and if the user has permission it should work.
Regards,
Sanyev
Hi
You can set the Application property Authentication to true in your application. Just open your Webdynpro application and then go to properties. Just add Authentication as a property and set the value to true.
Thanks,
Prasanthi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.