I have a web service client that has an Authenticator class. The Authenticator requires a username/password. Looking for ideas on how best to wire this. Should I inject the user/pass into the Authenticator or into the client that is instantiating the Authenticator. These are what the two components look like:
The Authenticator that includes the user/pass:Code:@Controller public class WSClient { @Autowired MyAuthenticator myAuthenticator; }
Code:public class MyAuthenticator extends Authenticator { private final String userName; private final String passWord; public MyAuthenticator(String userName, String passWord) { this.userName = userName; this.passWord = passWord; } @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(this.userName, this.passWord.toCharArray()); } }


Reply With Quote
