Package com.mucommander.commons.file

Examples of com.mucommander.commons.file.FileURL


  public FileURL[] getForwardFolders() {
    if(!hasForwardFolder())
      return new FileURL[0];

    int historySize = history.size();
    FileURL urls[] = new FileURL[historySize-historyIndex-1];

    int cur = 0;
    for(int i=historyIndex+1; i<historySize; i++)
      urls[cur++] = history.get(i);
View Full Code Here


            // 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);
                        path = url.toString(true);
                    }
                    // If the user cancels, we fall back to the default path.
                    else {
                        return getHomeFolder().getURL();
                    }
View Full Code Here

            this.action = action;
        }

        @Override
        public JPopupMenu getPopupMenu() {
            FileURL history[] = action instanceof GoBackAction?
                    mainFrame.getActivePanel().getFolderHistory().getBackFolders()
                    :mainFrame.getActivePanel().getFolderHistory().getForwardFolders();
            int historyLen = history.length;       

            // If no back/forward folder, do not display popup menu
View Full Code Here

     * @param credentialsMapping the credentials to use to authenticate the given FileURL
     */
    public static void authenticate(FileURL location, CredentialsMapping credentialsMapping) {
        location.setCredentials(credentialsMapping.getCredentials());

        FileURL realm = credentialsMapping.getRealm();
        Enumeration<String> propertyKeys = realm.getPropertyNames();
        String key;
        while(propertyKeys.hasMoreElements()) {
            key = propertyKeys.nextElement();

            if(location.getProperty(key)==null)
                location.setProperty(key, realm.getProperty(key));
        }
    }
View Full Code Here

     * @param location the location to find matching credentials for
     * @param credentials the Vector containing the CredentialsMapping instances to compare to the given location
     * @param matches the Vector where matching CredentialsMapping instances will be added
     */
    private static void findMatches(FileURL location, List<CredentialsMapping> credentials, List<CredentialsMapping> matches) {
        FileURL tempRealm;

        int nbEntries = credentials.size();
        for(CredentialsMapping tempCredentialsMapping: credentials) {
            tempRealm = tempCredentialsMapping.getRealm();
            if(location.schemeEquals(tempRealm)
View Full Code Here

        int nbTokens = pathTokensV.size();
        String pathTokens[] = new String[nbTokens];
        pathTokensV.toArray(pathTokens);

        CredentialsMapping tempCredentialsMapping;
        FileURL tempURL;
        String tempPath;
        int nbMatchingToken;
        int maxTokens = 0;
        int bestMatchIndex = 0;

        // Compares the location's path against all the one of all CredentialsMapping instances
        int nbMatches = matches.size();
        for(int i=0; i<nbMatches; i++) {
            tempCredentialsMapping = matches.get(i);
            tempURL = tempCredentialsMapping.getRealm();
            tempPath = tempURL.getPath();

            // We found a perfect match (same path), it can't get any better than this, return the CredentialsMapping' index
            if(tempPath.equalsIgnoreCase(path))
                return i;
View Full Code Here

        out.startElement(ELEMENT_ROOT, attributes);
        out.println();

        Iterator<CredentialsMapping> iterator = CredentialsManager.getPersistentCredentialMappings().iterator();
        CredentialsMapping credentialsMapping;
        FileURL realm;
        Enumeration<String> propertyKeys;
        String name;

        while(iterator.hasNext()) {
            credentialsMapping = iterator.next();
            realm = credentialsMapping.getRealm();

            // Start credentials element
            out.startElement(ELEMENT_CREDENTIALS);
            out.println();

            // Write URL
            out.startElement(ELEMENT_URL);
            out.writeCData(realm.toString(false));
            out.endElement(ELEMENT_URL);

            Credentials credentials = credentialsMapping.getCredentials();

            // Write login
            out.startElement(ELEMENT_LOGIN);
            out.writeCData(credentials.getLogin());
            out.endElement(ELEMENT_LOGIN);

            // Write password (XOR encrypted)
            out.startElement(ELEMENT_PASSWORD);
            out.writeCData(XORCipher.encryptXORBase64(credentials.getPassword()));
            out.endElement(ELEMENT_PASSWORD);

            // Write properties, each property is stored in a separate 'property' element
            propertyKeys = realm.getPropertyNames();
            while(propertyKeys.hasMoreElements()) {
                name = propertyKeys.nextElement();
                attributes = new XmlAttributes();
                attributes.add(ATTRIBUTE_NAME, name);
                attributes.add(ATTRIBUTE_VALUE, realm.getProperty(name));
                out.startElement(ELEMENT_PROPERTY, attributes);
                out.endElement(ELEMENT_PROPERTY);
            }

            // End credentials element
View Full Code Here

TOP

Related Classes of com.mucommander.commons.file.FileURL

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.