use of com.mucommander.commons.file.Credentials in project mucommander by mucommander.
the class OvirtPanel method getServerURL.
@Override
public FileURL getServerURL() throws MalformedURLException {
FileURL url = FileURL.getFileURL(String.format("ovirt://%s:%s/", serverField.getText(), lastPort = (int) portSpinner.getValue()));
url.setCredentials(new Credentials(usernameField.getText(), new String(passwordField.getPassword())));
url.setProperty("proxy", Boolean.toString(useProxy));
return url;
}
use of com.mucommander.commons.file.Credentials in project mucommander by mucommander.
the class HDFSPanel method getServerURL.
// //////////////////////////////
// ServerPanel implementation //
// //////////////////////////////
@Override
public FileURL getServerURL() throws MalformedURLException {
updateValues();
if (!lastInitialDir.startsWith("/"))
lastInitialDir = "/" + lastInitialDir;
FileURL url = FileURL.getFileURL(FileProtocols.HDFS + "://" + lastServer + lastInitialDir);
// Set user and group
url.setCredentials(new Credentials(lastUsername, ""));
// url.setProperty(HDFSFile.GROUP_PROPERTY_NAME, lastGroup);
// Set port
url.setPort(lastPort);
return url;
}
use of com.mucommander.commons.file.Credentials in project mucommander by mucommander.
the class S3File method getHadoopFileSystem.
// /////////////////////////////
// HadoopFile implementation //
// /////////////////////////////
@Override
protected FileSystem getHadoopFileSystem(FileURL url) throws IOException {
if (!url.containsCredentials())
throw new AuthException(url);
// Note: getRealm returns a fresh instance every time
FileURL realm = url.getRealm();
// Import credentials
Credentials creds = url.getCredentials();
if (creds != null) {
// URL-encode secret as it may contain non URL-safe characters ('+' and '/')
realm.setCredentials(new Credentials(creds.getLogin(), URLEncoder.encode(creds.getPassword(), "UTF-8")));
}
// Change the scheme to the actual Hadoop fileystem (s3 -> s3n)
realm.setScheme("s3n");
return FileSystem.get(URI.create(realm.toString(true, false)), DEFAULT_CONFIGURATION);
}
use of com.mucommander.commons.file.Credentials in project mucommander by mucommander.
the class AuthDialog method setCredentialMapping.
/**
* Called when the dialog has been validated by the user, when the OK button has been pressed or when enter has
* 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;
}
}
}
}
use of com.mucommander.commons.file.Credentials in project mucommander by mucommander.
the class EditCredentialsDialog method updateComponents.
/**
* Updates text fields and buttons' enabled state based on the current selection. Should be called
* whenever the list selection has changed.
*/
private void updateComponents() {
String loginValue = null;
String passwordValue = null;
boolean componentsEnabled = false;
if (!credentialsList.isSelectionEmpty() && credentials.size() > 0) {
componentsEnabled = true;
CredentialsMapping credentialsMapping = (CredentialsMapping) credentialsList.getSelectedValue();
Credentials credentials = credentialsMapping.getCredentials();
loginValue = credentials.getLogin();
passwordValue = credentials.getPassword();
}
loginField.setText(loginValue);
loginField.setEnabled(componentsEnabled);
passwordField.setText(passwordValue);
passwordField.setEnabled(componentsEnabled);
removeButton.setEnabled(componentsEnabled);
}
Aggregations