Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save uhbif19/9063043 to your computer and use it in GitHub Desktop.
Save uhbif19/9063043 to your computer and use it in GitHub Desktop.
def authenticate(user: String, password: String) = {
/* Установить логин и пароль по умолчанию, необходимые для доступа к прокси.
Идея отсюда: http://blog.vinodsingh.com/2008/05/proxy-authentication-in-java.html*/
import java.net.{Authenticator, PasswordAuthentication}
class ProxyAuthenticator(var user: String, var password: String)
extends Authenticator {
protected override def getPasswordAuthentication(): PasswordAuthentication = {
return new PasswordAuthentication(user, password.toCharArray());
}
}
Authenticator.setDefault(new ProxyAuthenticator(user, password));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment