开发者

Java - Retrieving an Image from a site after Login

Hey, folks. What I'm trying to do is write a Confluence plugin containing a servlet that generates a pdf based on the Active Directory. Anyway, there is an attachment repository on the confluence space. Problem is, when I try to create an IText image from the pdf, it gets all buggy. I'm assuming it is because the page is behind a login. Any other images work just fine.

At any rate, is there a way, in Java, I can retrieve the image in even just a byte[] after logging in with some sort of credentials?

Error Example:

Image portrait = Image.getInstance(new URL("http://*Local Network*/download/attachments/3409000/PdfTestImage.JPG"));

^^ throws java.io.IOException: http://*Local Network*/download/attachments/3409000/John.Doe.JPG is not a recognized imageformat. at com.itextpdf.text.Image.getInstance(Image.java:317)

While

Image portrait = Image.getInstance(new URL("http://www.dominionpaper.ca/files/dominion-img/hedgehog.JPG"));

or anything else I put in there doesn't cause a problem. Any suggestions? I've used HttpClient before bu开发者_JAVA百科t I'm not positive if it'd be applicable.


You problem description is quite confusing. Let me repeat it to make sure I've got it right: you need to extract an image from a password-protected site, but you are not logged in into that site (user may be logged in, but not your server-side code)?

Then I'd suggest to user HttpClient to provide the correct credentials and download the file to local storage where you can process it the way you like. Note that if the site uses MS SSO, the task could be quite complicated, as your code would need a service account with AD/Kerberos.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜