response = JOptionPane.showConfirmDialog(null, msg, "Authenticate",
JOptionPane.OK_CANCEL_OPTION);
if ((response == JOptionPane.CANCEL_OPTION) ||
(response == JOptionPane.CLOSED_OPTION)) {
throw new CredentialsNotAvailableException("User cancled windows authentication.");
}
return new NTCredentials(userField.getText(), new String(passwordField.getPassword()),
host, domainField.getText());
} else if (scheme instanceof RFC2617Scheme) {
Object[] msg = {
host + ":" + port + " requires authentication with the realm '" +
scheme.getRealm() + "'",
"User Name",
userField,
"Password",
passwordField
};
response = JOptionPane.showConfirmDialog(null, msg, "Authenticate",
JOptionPane.OK_CANCEL_OPTION);
if ((response == JOptionPane.CANCEL_OPTION) ||
(response == JOptionPane.CLOSED_OPTION)) {
throw new CredentialsNotAvailableException("User cancled windows authentication.");
}
return new UsernamePasswordCredentials(userField.getText(),
new String(passwordField.getPassword()));
} else {
throw new CredentialsNotAvailableException("Unsupported authentication scheme: " +
scheme.getSchemeName());
}
} catch (IOException ioe) {
throw new CredentialsNotAvailableException(ioe.getMessage(), ioe);
}
}