Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
16 years ago

Using groovy/java to verify protected image (need username/password)

Hello,
I need to verify a url which has protected images and requires a username/pass. Trying the url in the browser causes a popup asking for username/password. I have heard that you need to add the username/pass to the http header etc.
How can I do this in groovy / java.

my current code for open images url is
URL url = new URL(myurl);
def foo = new java.net.URL( myurl ).openStream()
foo.close()

Thanks

Ali
  • The format depends on the individual site, it is normally something like

    urls/?uname=bob&pwd=fred

    But the actual value depends on the security implementation

    Some sites also use POST to pass the username/password combination.
  • Sounds to me like the Web Server is using HTTP Authentication, which comes in two variants, Basic and the more advanced Digest. You can tell which one is used by looking at the response headers when issuing the request without any authentication.

    Regards,
    Dain
    eviware.com