1 19 20 package com.sslexplorer.networkplaces.store.webdav; 21 22 import java.io.IOException ; 23 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 import org.apache.commons.vfs.FileObject; 27 import org.apache.commons.vfs.FileSystemException; 28 29 import com.sslexplorer.networkplaces.AbstractNetworkPlaceMount; 30 import com.sslexplorer.policyframework.LaunchSession; 31 import com.sslexplorer.security.PasswordCredentials; 32 import com.sslexplorer.vfs.VFSStore; 33 import com.sslexplorer.vfs.utils.URI; 34 import com.sslexplorer.vfs.webdav.DAVAuthenticationRequiredException; 35 import com.sslexplorer.vfs.webdav.DAVUtilities; 36 37 public class WebDAVMount extends AbstractNetworkPlaceMount { 38 39 final static Log log = LogFactory.getLog(WebDAVMount.class); 40 41 public WebDAVMount(LaunchSession launchSession, VFSStore store) { 42 super(launchSession, store); 43 } 44 45 public FileObject createVFSFileObject(String path, PasswordCredentials credentials) throws IOException { 46 try { 47 URI uri = getRootVFSURI(); 48 if (credentials != null) { 49 uri.setUserinfo(DAVUtilities.encodeURIUserInfo(credentials.getUsername() + (credentials.getPassword() != null ? ":" + new String (credentials.getPassword()) : ""))); 50 } 51 uri.setPath(uri.getPath() + (uri.getPath().endsWith("/") ? "" : "/") + DAVUtilities.encodePath(path)); 52 FileObject fileObject = this.getStore().getRepository().getFileSystemManager().resolveFile(uri.toString()); 53 return fileObject; 54 } catch (FileSystemException fse) { 55 if (fse.getCode().equals("vfs.provider.ftp/connect.error")) { 56 throw new DAVAuthenticationRequiredException(getMountString(), true); 57 } 58 throw fse; 59 } 60 } 61 } | Popular Tags |