// if the file exists, check for writeability
if (!file.exists() || (file.exists() && file.canWrite())) {
logger.debug("File is writable");
// enter password for the 1st time
PasswordInputDialog passwordDialog = new PasswordInputDialog(shell,
"Password for " + file.getName(), "Enter password ", "",
new DummyInputValidator());
passwordDialog.open();
String password1 = passwordDialog.getValue();
logger.debug("Entered password for the 1st time, length is "
+ password1.length());
// Re-enter password. Reusing the same dialog here is quicker to
// implement than using a dialog with two password fields.
passwordDialog = new PasswordInputDialog(shell, "Password for "
+ file.getName(), "Re-Enter password ", "",
new DummyInputValidator());
passwordDialog.open();
String password2 = passwordDialog.getValue();
logger.debug("Entered password for the 1st time, length is "
+ password1.length());
if (password1.equals(password2)) {
logger.info("Entered passwords match, OK");