com.starla.smb
Class SMBSessionFactory

java.lang.Object
  |
  +--com.starla.smb.SMBSessionFactory

public final class SMBSessionFactory
extends java.lang.Object

The SMBSessionFactory static class is used to create sessions to remote shared resources using the SMB/CIFS protocol. A PCShare object is used to specify the remote node and share details, as well as required access control details.

The OpenDisk () method opens a session to a remote disk share. The returned session object provides disk specific methods such as opening remote files, file and directory operations such as deleting files, renaming files etc. The disk session may also be used to start directory searches to list files/directories in a particular remote path.

The OpenPrinter () method opens a session to a remote printer share. The returned session object provides print spooling functionality. To perform remote printer admin functions use the OpenAdminSession () method to create an admin session to the remote node.

The OpenPipe () method opens a session to a remote named pipe share.

The OpenAdminSession () method creates a session that is connected to the remote IPC$ share, that is used for admin related functions, such as listing the available shares on the remote node, listing print queues and manipulting jobs in the remote printer queues.


Constructor Summary
SMBSessionFactory()
           
 
Method Summary
static SMBServerList getDomainList()
          Return the list of available domains/workgroups.
 java.lang.String getLocalDomain()
          Return the local domain name, if known.
static SMBServerList getServerList(java.lang.String domnam)
          Get the list of nodes in the specified domain
static SMBServerList getServerList(java.lang.String domnam, int srvFlags)
          Get the list of nodes in the specified domain that match the node type flags.
static boolean hasSessionDebug()
          Determine if SMB session debugging is enabled.
static java.lang.String isVersion()
          Return a version string for this software release
static SMBAdminSession OpenAdminSession(PCShare shr)
          Open a connection to a remote server admin pipe
static SMBDiskSession OpenDisk(PCShare shr)
          Open a connection to a remote file server disk share.
static com.starla.smb.SMBIPCSession OpenPipe(PCShare shr)
          Open a connection to a remote pipe/IPC
static SMBPrintSession OpenPrinter(PCShare shr)
          Open a connection to a remote print server
static void setSessionDebug(boolean dbg)
          Enable/disable SMB session debugging.
static void setSubnetMask(java.lang.String subnet)
          Set the subnet mask string for network broadcast requests If the subnet mask is not set a default broadcast mask for the TCP/IP address class will be used.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMBSessionFactory

public SMBSessionFactory()
Method Detail

getDomainList

public static final SMBServerList getDomainList()
                                         throws SMBException,
                                                java.io.IOException
Return the list of available domains/workgroups.
Returns:
com.starla.smb.SMBServerList List of available domains.
Throws:
SMBException - If an SMB error occurs.
java.io.IOException - If an I/O error occurs.

getLocalDomain

public java.lang.String getLocalDomain()
Return the local domain name, if known.
Returns:
Local domain name string, else null.

getServerList

public static final SMBServerList getServerList(java.lang.String domnam)
                                         throws java.io.IOException,
                                                SMBException
Get the list of nodes in the specified domain
Parameters:
domnam - Domain name to return nodes for
Returns:
SMBServerList containing the details of the nodes found
Throws:
java.io.IOException - I/O error occurred
SMBException - SMB error occurred

getServerList

public static final SMBServerList getServerList(java.lang.String domnam,
                                                int srvFlags)
                                         throws SMBException,
                                                java.io.IOException
Get the list of nodes in the specified domain that match the node type flags.
Parameters:
domnam - Domain name to return nodes for
srvFlags - Node type flags
Returns:
SMBServerList containing the details of the nodes found.
Throws:
SMBException - If an SMB exception occurs.
java.io.IOException - If an I/O error occurs.

hasSessionDebug

public static final boolean hasSessionDebug()
Determine if SMB session debugging is enabled.
Returns:
true if SMB session debugging is enabled, else false.

isVersion

public static final java.lang.String isVersion()
Return a version string for this software release
Returns:
Software version number string

OpenAdminSession

public static final SMBAdminSession OpenAdminSession(PCShare shr)
                                              throws java.io.IOException,
                                                     java.net.UnknownHostException,
                                                     SMBException
Open a connection to a remote server admin pipe
Parameters:
shr - Remote share information object.
Returns:
SMBAdminSession used to perform admin operations
Throws:
java.io.Exception - Network I/O error occurred.
java.net.UnkownHostException - Remote node is unknown.
SMBException - Failed to setup a new SMB session

OpenDisk

public static final SMBDiskSession OpenDisk(PCShare shr)
                                     throws java.io.IOException,
                                            java.net.UnknownHostException,
                                            SMBException
Open a connection to a remote file server disk share.
Parameters:
shr - Remote share information object.
Returns:
SMBSession used to access the remote share.
Throws:
java.io.Exception - Network I/O error occurred.
java.net.UnkownHostException - Remote node is unknown.
SMBException - Failed to setup a new SMB session

OpenPipe

public static final com.starla.smb.SMBIPCSession OpenPipe(PCShare shr)
                                                   throws java.io.IOException,
                                                          java.net.UnknownHostException,
                                                          SMBException
Open a connection to a remote pipe/IPC
Parameters:
shr - Remote share information object.
Returns:
SMBSession used to access the pipe/IPC session.
Throws:
java.io.Exception - Network I/O error occurred.
java.net.UnkownHostException - Remote node is unknown.
SMBException - Failed to setup a new SMB session

OpenPrinter

public static final SMBPrintSession OpenPrinter(PCShare shr)
                                         throws java.io.IOException,
                                                java.net.UnknownHostException,
                                                SMBException
Open a connection to a remote print server
Parameters:
shr - Remote share information object.
Returns:
SMBSession used to access the remote share.
Throws:
java.io.Exception - Network I/O error occurred.
java.net.UnkownHostException - Remote node is unknown.
SMBException - Failed to setup a new SMB session

setSessionDebug

public static final void setSessionDebug(boolean dbg)
Enable/disable SMB session debugging.
Parameters:
dbg - true to enable SMB session debugging, else false.

setSubnetMask

public static final void setSubnetMask(java.lang.String subnet)
Set the subnet mask string for network broadcast requests If the subnet mask is not set a default broadcast mask for the TCP/IP address class will be used.
Parameters:
subnet - Subnet mask string, in 'nnn.nnn.nnn.nnn' format.