Rebased, and pushed one more commit incorporating review comments.

I've deprecated `LoginCredentials.getPrivateKey()` and 
LoginCredentials.getPassword()`. I've updated all usages to use 
`getOptionalPrivateKey()` and `getOptionalPassword()`.

I also considered (but have not) adding a `checkState` in `LoginCredentials` 
constructor that password is present if `authenticateSudo==true`.

`LoginCredentials.shouldAuthenticateSudo` returns true "if a password is 
required to access the root user". However, if `shouldAuthenticateSudo==true` 
and password was absent, then it would previously break (in hard-to-debug ways) 
things like `RunScriptOnNodeUsingSsh.execAsRoot` and 
`SudoAwareInitManager.execScriptAsRoot`. These would use a password of `"null"` 
in the generated command. Now they will throw `IllegalStateException` on 
`getOptionalPassword().get()`.

I tried out this line in `LoginCredentials` constructor:
    if (authenticateSudo) checkState(password.isPresent(), "password must be 
supplied if authenticateSudo");

All the unit tests passed, but I'm still not confident enough that it won't 
break live cloud providers. Could the password come from any other source 
(making `authenticateSudo==true` reasonable even if password was absent)? I'll 
defer any such change to a separate pull request.

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

Reply via email to