1 19 20 package com.sslexplorer.networkplaces.store.cifs; 21 22 import jcifs.Config; 23 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 27 import com.sslexplorer.networkplaces.AbstractNetworkPlaceMount; 28 import com.sslexplorer.networkplaces.AbstractNetworkPlaceStore; 29 import com.sslexplorer.policyframework.LaunchSession; 30 import com.sslexplorer.properties.Property; 31 import com.sslexplorer.properties.impl.systemconfig.SystemConfigKey; 32 import com.sslexplorer.vfs.utils.URI; 33 import com.sslexplorer.vfs.utils.URI.MalformedURIException; 34 import com.sslexplorer.vfs.webdav.DAVUtilities; 35 36 42 public class CIFSStore extends AbstractNetworkPlaceStore { 43 final static Log log = LogFactory.getLog(CIFSStore.class); 44 47 public final static String CIFS_SCHEME = "cifs"; 48 51 public final static String SMB_SCHEME = "smb"; 52 53 56 public CIFSStore() { 57 super("cifs", System.getProperty("jcifs.encoding", "cp860")); 58 try { 59 setIfNotEmpty("jcifs.netbios.wins"); 60 setIfNotEmpty("jcifs.netbios.baddr"); 61 setIfNotEmpty("jcifs.netbios.scope"); 62 setIfNotEmpty("jcifs.smb.client.laddr"); 63 setIfNotEmpty("jcifs.netbios.laddr"); 64 setIfNotEmpty("jcifs.netbios.lmhosts"); 65 setIfNotEmpty("jcifs.smb.client.disablePlainTextPasswords"); 66 setIfNotEmpty("jcifs.netbios.hostname"); 67 setIfNotEmpty("jcifs.netbios.soTimeout"); 68 setIfNotEmpty("jcifs.netbios.retryCount"); 69 setIfNotEmpty("jcifs.netbios.retryTimeout"); 70 setIfNotEmpty("jcifs.resolveOrder"); 71 setIfNotEmpty("jcifs.smb.client.responseTimeout"); 72 setIfNotEmpty("jcifs.smb.client.soTimeout"); 73 74 String guestUser = Property.getProperty(new SystemConfigKey("cifs.guestUser")).replace('\\', ';').replace('/', ';'); 75 String guestPassword = Property.getProperty(new SystemConfigKey("cifs.guestPassword")); 76 if(!guestUser.equals("")) { 77 Config.setProperty("cifs.guestUser", guestUser); 78 } 79 if(!guestPassword.equals("")) { 80 Config.setProperty("cifs.guestUser", guestPassword); 81 } 82 } catch (Exception e) { 83 log.error("Failed to configure JCIFS. CIFS browsing may not act as expected.", e); 84 } 85 } 86 87 90 static void setIfNotEmpty(String name) { 91 String val =Property.getProperty(new SystemConfigKey(name)).trim(); 92 if (!val.equals("")) { 93 Config.setProperty(name, val); 94 } 95 96 } 97 98 101 protected AbstractNetworkPlaceMount createMount(LaunchSession launchSession) throws Exception { 102 return new CIFSMount(launchSession, this); 103 } 104 105 108 public String getGuestUsername() { 109 return Property.getProperty(new SystemConfigKey("cifs.guestUser")); 110 } 111 112 115 public char[] getGuestPassword() { 116 return Property.getProperty(new SystemConfigKey("cifs.guestPassword")).toCharArray(); 117 } 118 } | Popular Tags |