public final class SessionFactory extends Object
The SessionFactory 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 manipulating jobs in the remote printer queues.
An AdminSession can also be used to access various DCE/RPC services for remote registry, remote eventlog, service manager and server/workstation functions.
Constructor and Description |
---|
SessionFactory() |
Modifier and Type | Method and Description |
---|---|
protected static int |
DefaultPacketSize()
Return the default SMB packet size
|
static void |
disableDebug()
Disable session factory debugging.
|
static void |
disableDialect(int d)
Disable the specified SMB dialect when setting up new sessions.
|
static void |
enableDebug()
Enable session factory debug output.
|
static void |
enableDialect(int d)
Enable the specified SMB dialect when setting up new sessions.
|
static NetBIOSName |
findBrowseMaster()
Find the browse master for this network.
|
static DialectSelector |
getDefaultDialects()
Return the list of SMB dialects that will be negotiated when a new session is created.
|
static String |
getDefaultDomain()
Return the default domain name
|
static String |
getDefaultPassword()
Return the default password.
|
static SessionSettings |
getDefaultSettings()
Return the default session settings
|
static String |
getDefaultUserName()
Return the default user name.
|
static ServerList |
getDomainList()
Return the list of available domains/workgroups.
|
static String |
getLocalDomain()
Return the local domain name, if known.
|
static ServerList |
getLocalServerList()
Return a list of the local servers, if the local domain/workgroup can be determined.
|
static String |
getNetBIOSNameScope()
Return the NetBIOS scope id, or null if not set
|
static int |
getNetBIOSPort()
Return the NetBIOS socket number that new sessions are connected to.
|
static int |
getPrimaryProtocol()
Return the primary connection protocol (either Protocol.TCPNetBIOS or Protocol.NativeSMB)
|
static int |
getSecondaryProtocol()
Return the secondary connection protocol (Protocol.TCPNetBIOS, Protocol.NativeSMB or
Protocol.None)
|
static ServerList |
getServerList(String domnam)
Get the list of nodes in the specified domain
|
static ServerList |
getServerList(String domnam,
int srvFlags)
Get the list of nodes in the specified domain that match the node type flags.
|
static boolean |
hasDebug()
Determine if session factory debugging is enabled.
|
static boolean |
hasGlobalProcessId()
Determine if a global process id is used for all sessions
|
static boolean |
hasNetBIOSNameScope()
Determine if the NetBIOS name scope is set
|
static boolean |
hasSessionDebug()
Determine if SMB session debugging is enabled.
|
static boolean |
isReceivedSMBSigningEnabled()
Determine if received packets should validate the SMB signing value
|
static boolean |
isSMBSigningEnabled()
Determine if SMB signing is enabled
|
static String |
isVersion()
Return a version string for this software release
|
static AdminSession |
OpenAdminSession(PCShare shr)
Open a connection to a remote server admin pipe
|
static AdminSession |
OpenAdminSession(PCShare shr,
SessionSettings settings)
Open a connection to a remote server admin pipe
|
static AuthenticateSession |
OpenAuthenticateSession(PCShare shr)
Open a session to a remote server, negotiate an SMB dialect and get the returned challenge
key.
|
static AuthenticateSession |
OpenAuthenticateSession(PCShare shr,
SessionSettings settings)
Open a session to a remote server, negotiate an SMB dialect and get the returned challenge
key.
|
static DataPipeFile |
OpenDataPipe(PCShare shr,
String pipeName)
Open a connection to a remote pipe/IPC, in data mode
|
static DataPipeFile |
OpenDataPipe(PCShare shr,
String pipeName,
SessionSettings settings)
Open a connection to a remote pipe/IPC, in data mode
|
static DiskSession |
OpenDisk(PCShare shr)
Open a connection to a remote file server disk share.
|
static DiskSession |
OpenDisk(PCShare shr,
Session sess)
Open a connection to a remote file server disk share using the existing sessions network
session.
|
static DiskSession |
OpenDisk(PCShare shr,
SessionSettings settings)
Open a connection to a remote file server disk share.
|
static IPCSession |
OpenPipe(PCShare shr)
Open a connection to a remote pipe/IPC
|
static IPCSession |
OpenPipe(PCShare shr,
SessionSettings settings)
Open a connection to a remote pipe/IPC
|
static PrintSession |
OpenPrinter(PCShare shr,
SessionSettings settings)
Open a connection to a remote print server
|
static void |
SendMessage(String dNode,
String msg)
Send a message to a remote user.
|
static void |
SendMessage(String dNode,
String msg,
int tmo)
Send a message to a remote user.
|
static void |
setDefaultDialects(DialectSelector dialist)
Set the default SMB dialects that are to be negotiated when a new session is created.
|
static void |
setDefaultDomain(String domain)
Set the default domain.
|
static void |
setDefaultPassword(String pwd)
Set the default password.
|
static void |
setDefaultUserName(String user)
Set the default user name.
|
static void |
setGlobalProcessId(boolean ena)
Set/clear the global process id flag.
|
static void |
setNetBIOSNameScope(String scope)
Set the NetBIOS scope id
|
static void |
setNetBIOSPort(int port)
Set the NetBIOS socket number to be used when setting up new sessions.
|
static boolean |
setProtocolOrder(int pri,
int sec)
Set the protocol connection order
|
static void |
setReceivedSMBSigningEnabled(boolean ena)
Enable/disable validation of received SMB signatures when signing is enabled
|
static void |
setSessionDebug(boolean dbg)
Enable/disable SMB session debugging.
|
static void |
setSMBSigningEnabled(boolean ena)
Enable/disable SMB signing support
|
static void |
setSubnetMask(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.
|
protected static final int DefaultPacketSize()
public static final void disableDebug()
public static final void disableDialect(int d)
d
- intpublic static final void enableDebug()
public static final void enableDialect(int d)
d
- intpublic static final NetBIOSName findBrowseMaster() throws SMBException, IOException
SMBException
- The exception description.IOException
public static final DialectSelector getDefaultDialects()
public static String getDefaultDomain()
public static String getDefaultPassword()
public static String getDefaultUserName()
public static SessionSettings getDefaultSettings()
public static final ServerList getDomainList() throws SMBException, IOException
SMBException
- If an SMB error occurs.IOException
- If an I/O error occurs.public static String getLocalDomain()
public static ServerList getLocalServerList() throws SMBException, IOException, UnknownLocalDomainException
SMBException
- The exception description.IOException
- The exception description.UnknownLocalDomainException
public static String getNetBIOSNameScope()
public static int getNetBIOSPort()
public static final int getPrimaryProtocol()
public static final int getSecondaryProtocol()
public static final ServerList getServerList(String domnam) throws IOException, SMBException
domnam
- Domain name to return nodes forIOException
- I/O error occurredSMBException
- SMB error occurredpublic static final ServerList getServerList(String domnam, int srvFlags) throws SMBException, IOException
domnam
- Domain name to return nodes forsrvFlags
- Node type flagsSMBException
- If an SMB exception occurs.IOException
- If an I/O error occurs.public static final boolean hasDebug()
public static final boolean hasGlobalProcessId()
public static final boolean hasNetBIOSNameScope()
public static final boolean hasSessionDebug()
public static final boolean isSMBSigningEnabled()
public static final boolean isReceivedSMBSigningEnabled()
public static final String isVersion()
public static final AdminSession OpenAdminSession(PCShare shr) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.IOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final AdminSession OpenAdminSession(PCShare shr, SessionSettings settings) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.settings
- Session settingsIOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final DiskSession OpenDisk(PCShare shr) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.IOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final DiskSession OpenDisk(PCShare shr, SessionSettings settings) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.settings
- Session settingsIOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final DiskSession OpenDisk(PCShare shr, Session sess) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.sess
- Existing connection to the remote server.IOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final IPCSession OpenPipe(PCShare shr) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.IOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final IPCSession OpenPipe(PCShare shr, SessionSettings settings) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.settings
- Session settingsIOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final DataPipeFile OpenDataPipe(PCShare shr, String pipeName) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.pipeName
- StringIOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final DataPipeFile OpenDataPipe(PCShare shr, String pipeName, SessionSettings settings) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.settings
- Session settingsIOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static final PrintSession OpenPrinter(PCShare shr, SessionSettings settings) throws IOException, UnknownHostException, SMBException
shr
- Remote share information object.settings
- Session settingsIOException
- Network I/O error occurred.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new SMB sessionpublic static AuthenticateSession OpenAuthenticateSession(PCShare shr) throws IOException, UnknownHostException, SMBException
shr
- Remote server share and access control details.IOException
- If an I/O error occurs.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new session.public static AuthenticateSession OpenAuthenticateSession(PCShare shr, SessionSettings settings) throws IOException, UnknownHostException, SMBException
shr
- Remote server share and access control details.settings
- Session settingsIOException
- If an I/O error occurs.UnknownHostException
- Remote node is unknown.SMBException
- Failed to setup a new session.public static final void SendMessage(String dNode, String msg, int tmo) throws SMBException, IOException, UnknownHostException
dNode
- Destination node name.msg
- Message to be sent (maximum of 128 bytes).tmo
- intSMBException
- If an SMB error occurs.IOException
- If an I/O error occurs.UnknownHostException
- If the destination host is invalid/unknown.public static final void SendMessage(String dNode, String msg) throws SMBException, IOException, UnknownHostException
dNode
- Destination node name.msg
- Message to be sent (maximum of 128 bytes).SMBException
- If an SMB error occurs.IOException
- If an I/O error occurs.UnknownHostException
- If the destination host is invalid/unknown.public static final void setDefaultDialects(DialectSelector dialist)
dialist
- DialectSelector containing the SMB dialects to negotiate.public static void setDefaultDomain(String domain)
domain
- Stringpublic static void setDefaultPassword(String pwd)
pwd
- java.lang.Stringpublic static void setDefaultUserName(String user)
user
- java.lang.Stringpublic static final void setGlobalProcessId(boolean ena)
ena
- booleanpublic static void setNetBIOSPort(int port)
port
- intpublic static void setNetBIOSNameScope(String scope)
scope
- Stringpublic static final boolean setProtocolOrder(int pri, int sec)
pri
- Primary connection protocolsec
- Secondary connection protocol, or nonepublic static final void setSMBSigningEnabled(boolean ena)
ena
- booleanpublic static final void setReceivedSMBSigningEnabled(boolean ena)
ena
- booleanpublic static final void setSessionDebug(boolean dbg)
dbg
- true to enable SMB session debugging, else false.public static final void setSubnetMask(String subnet)
subnet
- Subnet mask string, in 'nnn.nnn.nnn.nnn' format.Copyright © 2005–2018 Alfresco Software. All rights reserved.