org.dstadler.commons.util.SimpleAuthenticator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-dost Show documentation
Show all versions of commons-dost Show documentation
Common utilities I find useful in many of my projects.
package org.dstadler.commons.util;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
public class SimpleAuthenticator extends Authenticator {
private static final ThreadLocal username = new ThreadLocal<>(), password = new ThreadLocal<>();
public SimpleAuthenticator(String username, String password) {
SimpleAuthenticator.username.set(username);
SimpleAuthenticator.password.set(password);
}
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username.get(), password.get().toCharArray());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy