Skip to content

Instantly share code, notes, and snippets.

@shellac
Created March 3, 2010 21:07
Show Gist options
  • Save shellac/321025 to your computer and use it in GitHub Desktop.
Save shellac/321025 to your computer and use it in GitHub Desktop.
require 'java'
class Auth < java.net.Authenticator
def getPasswordAuthentication
if (requesting_host = "www.bbc.co.uk")
return make_auth("libby","bunny")
else
return nil
end
end
def make_auth(user, password)
java.net.PasswordAuthentication.new(user, password.to_java.to_char_array)
end
end
java.net.Authenticator.setDefault(Auth.new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment