CredentialsMapping newCredentialsMapping = null;
// True if Guest authentication was selected in the authentication dialog (guest credentials must not be
// added to CredentialsManager)
boolean guestCredentialsSelected = false;
AuthenticationType authenticationType = folderURL.getAuthenticationType();
if(credentialsMapping!=null) {
newCredentialsMapping = credentialsMapping;
CredentialsManager.authenticate(folderURL, newCredentialsMapping);
}
// If the URL doesn't contain any credentials and authentication for this file protocol is required, or