Ok I see now. So in practice, adding a new method `forceNoPassword` complicates 
the usage of the options, but treating the empty strings as a hint to indicate 
that no password or private key should be used seems still more obfuscated and 
difficult to use.

The main problem here is that the purpose of the `LoginCredentials` object is 
to transport the credentials, not to choose an authentication method, which is 
what you want to achieve.

To keep the same interface and the current implementation unchanged (and thus, 
any existing code working), but with better semantics, what about creating a 
subclass of the `LoginCredentials`, say `SshAgentAuthentication`? The class 
could throw an `UnsupportedOperationException` when setting the password or 
private key and allow to set the username.

Using that subclass in the `overrideLoginCredentials` should work for you and 
the code would be more readable and the responsibilitties of each class well 
defined.

WDYT?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/486#issuecomment-52407035

Reply via email to