1public static final String USERNAME_KEY = "username";
2public static final String PASSWORD_KEY = "password";
3private final PasswordAuthentication authentication;
4
5public MyAuthenticator(Properties properties) {
6 String userName = properties.getProperty(USERNAME_KEY);
7 String password = properties.getProperty(PASSWORD_KEY);
8 if (userName == null || password == null) {
9 authentication = null;
10 } else {
11 authentication = new PasswordAuthentication(userName, password.toCharArray());
12 }
13}
14
15protected PasswordAuthentication getPasswordAuthentication() {
16 return authentication;
17}