更新时间:2023-12-04 07:57:52
事实证明,这是一种简单,标准的方法实现我想要的:
It turned out that there's a simple, standard way to achieve what I wanted:
import java.net.Authenticator;
import java.net.PasswordAuthentication;
Authenticator myAuth = new Authenticator()
{
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("german", "german".toCharArray());
}
};
Authenticator.setDefault(myAuth);
没有自定义sun类或外部依赖项,也没有手动编码任何内容。
No custom "sun" classes or external dependencies, and no manually encode anything.
我知道BASIC安全性不是很安全,但我们也使用HTTPS。
I'm aware that BASIC security is not, well, secure, but we are also using HTTPS.