Search in sources :

Example 6 with Credentials

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;
}
Also used : FileURL(com.mucommander.commons.file.FileURL) Credentials(com.mucommander.commons.file.Credentials)

Example 7 with Credentials

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;
}
Also used : FileURL(com.mucommander.commons.file.FileURL) Credentials(com.mucommander.commons.file.Credentials)

Example 8 with Credentials

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);
}
Also used : FileURL(com.mucommander.commons.file.FileURL) AuthException(com.mucommander.commons.file.AuthException) Credentials(com.mucommander.commons.file.Credentials)

Example 9 with Credentials

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;
            }
        }
    }
}
Also used : Credentials(com.mucommander.commons.file.Credentials) CredentialsMapping(com.mucommander.auth.CredentialsMapping)

Example 10 with Credentials

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);
}
Also used : Credentials(com.mucommander.commons.file.Credentials) CredentialsMapping(com.mucommander.auth.CredentialsMapping)

Aggregations

Credentials (com.mucommander.commons.file.Credentials)25 FileURL (com.mucommander.commons.file.FileURL)16 CredentialsMapping (com.mucommander.auth.CredentialsMapping)5 DefaultSchemeHandler (com.mucommander.commons.file.DefaultSchemeHandler)4 DefaultSchemeParser (com.mucommander.commons.file.DefaultSchemeParser)4 FileProtocolService (com.mucommander.commons.file.osgi.FileProtocolService)4 ProtocolPanelProvider (com.mucommander.protocol.ui.ProtocolPanelProvider)4 ServerPanelListener (com.mucommander.protocol.ui.ServerPanelListener)4 JFrame (javax.swing.JFrame)4 AuthException (com.mucommander.commons.file.AuthException)2 IOException (java.io.IOException)2 JSch (com.jcraft.jsch.JSch)1 JSchException (com.jcraft.jsch.JSchException)1 XmlAttributes (com.mucommander.commons.util.xml.XmlAttributes)1 XmlWriter (com.mucommander.commons.util.xml.XmlWriter)1 InterruptedIOException (java.io.InterruptedIOException)1 StringTokenizer (java.util.StringTokenizer)1 Jets3tProperties (org.jets3t.service.Jets3tProperties)1 S3Service (org.jets3t.service.S3Service)1 RestS3Service (org.jets3t.service.impl.rest.httpclient.RestS3Service)1