* been pressed in a text field.
*/
private void setCredentialMapping() {
if(guestRadioButton!=null && guestRadioButton.isSelected()) {
guestCredentialsSelected = true;
selectedCredentialsMapping = new CredentialsMapping(fileURL.getGuestCredentials(), fileURL, false);
}
else {
Credentials enteredCredentials = new Credentials(loginField.getText(), new String(passwordField.getPassword()));
guestCredentialsSelected = false;
boolean isPersistent = saveCredentialsCheckBox.isSelected();
selectedCredentialsMapping = new CredentialsMapping(enteredCredentials, fileURL, isPersistent);
// Look for an existing matching CredentialsMapping instance to re-use the realm which may contain
// connection properties.
int nbCredentials = credentialsMappings.length;
CredentialsMapping cm;
for(int i=0; i<nbCredentials; i++) {
cm = credentialsMappings[i];
if(cm.getCredentials().equals(enteredCredentials, true)) { // Comparison must be password-sensitive
// Create a new CredentialsMapping instance in case the 'isPersistent' flag has changed.
// (original credentials may have originally been added as 'volatile' and then made persistent by
// ticking the checkbox, or vice-versa)
selectedCredentialsMapping = new CredentialsMapping(cm.getCredentials(), cm.getRealm(), isPersistent);
break;
}
}
}
}