org.gnu.jcifs
Class CifsSessionManager

java.lang.Object
  |
  +--org.gnu.jcifs.CifsSessionManager

public abstract class CifsSessionManager
extends java.lang.Object

This abtract class implements the factory methods for CIFS services (Disk, Printer, RemoteAdmin).

How to mount a disk?

   // share_name has UNC- (\\server\share) or URL-Syntax (cifs://server/share)
   CifsLogin login = new CifsLogin( user, password);

   CifsDisk disk = CifsServiceManager.connectDisk(diskname,"\\server\share",login);


Field Summary
static int DEBUG_BUFFER
          Debug errors, warnings, infos, buffers
static int DEBUG_ERROR
          Debug errors
static int DEBUG_INFO
          Debug errors, warnings, infos
static int DEBUG_NONE
          Debug none
static int DEBUG_WARNING
          Debug errors, warnings
static int SESSION_SORT_NAME
          Sort sessions by name
static int SESSION_SORT_TYPE
          Sort sessions by type
 
Method Summary
(package private) static void ()
           
static void clearNameResolverCache()
          Clears the name resolver cache and reload LMHOST file
static CifsDisk connectDisk(java.lang.String sessionname, java.lang.String sharename)
          Connect to the given share.
static CifsDisk connectDisk(java.lang.String sessionname, java.lang.String sharename, CifsLogin login)
          Connect to the given share
static CifsPrinter connectPrinter(java.lang.String sessionname, java.lang.String printer)
           
static CifsPrinter connectPrinter(java.lang.String sessionname, java.lang.String printer, CifsLogin login)
           
static CifsRemoteAdmin connectRemoteAdmin(java.lang.String admname, java.lang.String host)
          Connect to Remote Admin Protocol
static CifsRemoteAdmin connectRemoteAdmin(java.lang.String sessionname, java.lang.String host, CifsLogin login)
          Connect to Remote Admin Protocol
static java.lang.String createUSN()
          Creates an unique session name.
static void disconnectSession(java.lang.String sessionname)
          Disconnects the given session
static java.util.Enumeration enumerateDiskSessions()
          Enumerates disk sessions
static java.util.Enumeration enumeratePrinterSessions()
          Enumerates printer sessions
static java.util.Enumeration enumerateRemoteAdminSessions()
          Enumerates remote admin sessions
static java.util.Enumeration enumerateSessions()
          Enumerates connected sessions (unsorted)
static boolean getAllowLoginDialog()
           
static java.lang.String getPackageCopyright()
          Returns the copyright text
static java.lang.String getPackageVersion()
          Returns the version number of the JCIFS package
static CifsSession[] getSessions(int sortby)
          List sessions
static boolean installCifsProtocolHandler()
          Install protocol handler package.
 boolean isProtocolHandlerInstalled()
          Returns true if the protocol handler "cifs" was installed
static boolean loginDialog(java.awt.Frame frame)
          Opens a dialog box and requests login data (account name and password).
static CifsDisk lookupConnectedDisk(java.lang.String sessionname)
          Lookup disk with the given session name
static CifsPrinter lookupPrinterSession(java.lang.String sessionname)
          Lookup printer session
static CifsRemoteAdmin lookupRemoteAdminSession(java.lang.String sessionname)
          Lookup remote admin session
static CifsSession lookupSession(java.lang.String sessionname)
           
static void setAccount(java.lang.String account)
          Sets the account name for all connections.
static void setAllowLoginDialog(boolean on)
           
static void setDebugFile(java.lang.String fname)
          Sets debug file.
static void setDebugLevel(int level)
          Sets debug level
static void setPassword(java.lang.String password)
          Sets the password for all connections
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_SORT_NAME

public static final int SESSION_SORT_NAME
Sort sessions by name

SESSION_SORT_TYPE

public static final int SESSION_SORT_TYPE
Sort sessions by type

DEBUG_NONE

public static final int DEBUG_NONE
Debug none

DEBUG_ERROR

public static final int DEBUG_ERROR
Debug errors

DEBUG_WARNING

public static final int DEBUG_WARNING
Debug errors, warnings

DEBUG_INFO

public static final int DEBUG_INFO
Debug errors, warnings, infos

DEBUG_BUFFER

public static final int DEBUG_BUFFER
Debug errors, warnings, infos, buffers
Method Detail

getPackageVersion

public static java.lang.String getPackageVersion()
Returns the version number of the JCIFS package
Returns:
version number

getPackageCopyright

public static java.lang.String getPackageCopyright()
Returns the copyright text
Returns:
copyright text

setDebugLevel

public static void setDebugLevel(int level)
Sets debug level
Parameters:
level - debug level (DEBUG_*)

setDebugFile

public static void setDebugFile(java.lang.String fname)
Sets debug file. If fname is null, the debug file is closed
Parameters:
fname - debug output file

setAccount

public static void setAccount(java.lang.String account)
Sets the account name for all connections. If user name is not set, the user name of the process is used.
Parameters:
account - account name

setPassword

public static void setPassword(java.lang.String password)
Sets the password for all connections
Parameters:
password - password

loginDialog

public static boolean loginDialog(java.awt.Frame frame)
Opens a dialog box and requests login data (account name and password). The login data is used if a connect call has no explicit login data.
Parameters:
frame - frame or null
false - of dialog cancelled

lookupSession

public static CifsSession lookupSession(java.lang.String sessionname)

enumerateSessions

public static java.util.Enumeration enumerateSessions()
Enumerates connected sessions (unsorted)
Returns:
Enumeration

getSessions

public static CifsSession[] getSessions(int sortby)
List sessions
Parameters:
sortby - sorted by (SESSION_SORT_NAME or SESSION_SORT_TYPE)
Returns:
CifsSession array

connectDisk

public static CifsDisk connectDisk(java.lang.String sessionname,
                                   java.lang.String sharename)
                            throws java.io.IOException
Connect to the given share. The default user name and password will be used
Parameters:
sessionname - a symbolic name of this session. Names with the prefix $ are reserved for internal use.
sharename: - \\host\share or cifs://host/share
Returns:
disk

connectDisk

public static CifsDisk connectDisk(java.lang.String sessionname,
                                   java.lang.String sharename,
                                   CifsLogin login)
                            throws java.io.IOException
Connect to the given share
Parameters:
sessionname - a symbolic name of the session
sharename: - \\host\share or cifs://host/share
login - authentication data
Returns:
disk

lookupConnectedDisk

public static CifsDisk lookupConnectedDisk(java.lang.String sessionname)
Lookup disk with the given session name
Parameters:
sessionname - disk session name
Returns:
CifsDisk or null if no disk

enumerateDiskSessions

public static java.util.Enumeration enumerateDiskSessions()
Enumerates disk sessions
Returns:
Enumeration of disk sessions (objects of type CifsDisk

disconnectSession

public static void disconnectSession(java.lang.String sessionname)
                              throws java.io.IOException
Disconnects the given session
Parameters:
sessionname - the name of session
Throws:
java.io.IOException - IO failure

connectRemoteAdmin

public static CifsRemoteAdmin connectRemoteAdmin(java.lang.String admname,
                                                 java.lang.String host)
                                          throws java.io.IOException
Connect to Remote Admin Protocol
Parameters:
admname - local alias name for this connection
host - host name
login - authentication data
Returns:
disk

connectRemoteAdmin

public static CifsRemoteAdmin connectRemoteAdmin(java.lang.String sessionname,
                                                 java.lang.String host,
                                                 CifsLogin login)
                                          throws java.io.IOException
Connect to Remote Admin Protocol
Parameters:
admname - local alias name for this connection
host - host name
login - authentication data
Returns:
disk

lookupRemoteAdminSession

public static CifsRemoteAdmin lookupRemoteAdminSession(java.lang.String sessionname)
Lookup remote admin session
Parameters:
sessionname - remote admin session name
Returns:
CifsRemoteAdmin or null if no session

enumerateRemoteAdminSessions

public static java.util.Enumeration enumerateRemoteAdminSessions()
Enumerates remote admin sessions
Returns:
Enumeration of remote admin sessions (objects of type CifsRemoteAdmin

connectPrinter

public static CifsPrinter connectPrinter(java.lang.String sessionname,
                                         java.lang.String printer)
                                  throws java.io.IOException

connectPrinter

public static CifsPrinter connectPrinter(java.lang.String sessionname,
                                         java.lang.String printer,
                                         CifsLogin login)
                                  throws java.io.IOException

lookupPrinterSession

public static CifsPrinter lookupPrinterSession(java.lang.String sessionname)
Lookup printer session
Parameters:
sessionname - printer session name
Returns:
CifsRemoteAdmin or null if no session

enumeratePrinterSessions

public static java.util.Enumeration enumeratePrinterSessions()
Enumerates printer sessions
Returns:
Enumeration of remote admin sessions (objects of type CifsPrinter

setAllowLoginDialog

public static void setAllowLoginDialog(boolean on)

getAllowLoginDialog

public static boolean getAllowLoginDialog()

clearNameResolverCache

public static void clearNameResolverCache()
Clears the name resolver cache and reload LMHOST file

createUSN

public static java.lang.String createUSN()
Creates an unique session name. The generated name has the prefix:$usn_
Returns:
unique session name
Since:
1.1

installCifsProtocolHandler

public static boolean installCifsProtocolHandler()
Install protocol handler package. This method can be called more than one time. If the protocol handler package cannot be installed, you must install the protocol stream handler factory explicitly:

URL.setURLStreamHandlerFactory(new CifsURLStreamHandlerFactory ());

Returns:
true if the protocol handler package is installed
Since:
1.1

isProtocolHandlerInstalled

public boolean isProtocolHandlerInstalled()
Returns true if the protocol handler "cifs" was installed
Returns:
true protocol handler installed
Since:
1.1

static void ()