}
// If an AuthException occurred, gets login credential from the user.
catch(Exception e) {
if(e instanceof AuthException) {
// Prompts the user for a login and password.
AuthException authException = (AuthException)e;
FileURL url = authException.getURL();
AuthDialog authDialog = new AuthDialog(WindowManager.getCurrentMainFrame(), url, true, authException.getMessage());
authDialog.showDialog();
newCredentialsMapping = authDialog.getCredentialsMapping();
if(newCredentialsMapping !=null) {
// Use the provided credentials
CredentialsManager.authenticate(url, newCredentialsMapping);