All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dstadler.commons.util.SimpleAuthenticator Maven / Gradle / Ivy

There is a newer version: 1.3.4
Show newest version
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