Java Authenticator getPasswordAuthentication() 方法

2025 年 3 月 20 日 | 阅读 2 分钟

Authenticator 类的 getPasswordAuthentication() 方法在需要密码授权时被调用。子类必须覆盖 getPasswordAuthentication() 的默认实现,该默认实现返回 null。

语法

参数

不传递任何参数。

返回

从用户处收集的 Password Authentication,如果未提供则为 null。

Throw

不抛出任何异常

示例 1

输出

password validating...

示例 2

输出

null
null