}
try {
Credentials credentials = null;
if (authscheme instanceof NTLMScheme) {
AuthenticationDialog pwDialog = new AuthenticationDialog(
ownerFrame, "Authentication Required",
"<html>Host <b>" + host + ":" + port + "</b> requires Windows authentication</html>", true);
pwDialog.setVisible(true);
if (pwDialog.getUser().length() > 0) {
credentials = new NTCredentials(pwDialog.getUser(), pwDialog.getPassword(),
host, pwDialog.getDomain());
}
pwDialog.dispose();
} else
if (authscheme instanceof RFC2617Scheme) {
AuthenticationDialog pwDialog = new AuthenticationDialog(
ownerFrame, "Authentication Required",
"<html><center>Host <b>" + host + ":" + port + "</b>"
+ " requires authentication for the realm:<br><b>" + authscheme.getRealm() + "</b></center></html>", false);
pwDialog.setVisible(true);
if (pwDialog.getUser().length() > 0) {
credentials = new UsernamePasswordCredentials(pwDialog.getUser(), pwDialog.getPassword());
}
pwDialog.dispose();
} else {
throw new CredentialsNotAvailableException("Unsupported authentication scheme: " +
authscheme.getSchemeName());
}
return credentials;