org.gnu.jcifs
Class SessionImpl

java.lang.Object
  |
  +--org.gnu.jcifs.SessionImpl
All Implemented Interfaces:
CifsSession
Direct Known Subclasses:
DiskImpl, PrinterImpl, RemoteAdminImpl

public abstract class SessionImpl
extends java.lang.Object
implements CifsSession

Abstract base class of all service sessions

Since:
1.0

Field Summary
(package private) static int CAP_BULK_TRANSFER
           
(package private) static int CAP_COMPRESSED_DATA
           
(package private) static int CAP_DFS
           
(package private) static int CAP_EXTENDED_SECURITY
           
(package private) static int CAP_LARGE_FILES
           
(package private) static int CAP_LEVEL_II_OPLOCKS
           
(package private) static int CAP_LOCK_AND_READ
           
(package private) static int CAP_MPX_MODE
           
(package private) static int CAP_NT_FIND
           
(package private) static int CAP_NT_SMBS
           
(package private) static int CAP_RAW_MODE
           
(package private) static int CAP_RPC_REMOTE_APIS
           
(package private) static int CAP_STATUS32
           
(package private) static int CAP_UNICODE
           
protected  java.util.Hashtable fCallerProperties
           
protected  int fCapabilities
           
protected  int fEncryptionKeyLen
           
protected  boolean fExtendedSecurity
           
protected  boolean fLoggedAsGuest
           
protected  int fMaxBufferSize
           
protected  int fMaxPendingMPRequests
           
protected  int fMaxRawSize
           
protected  int fMaxVCs
           
protected  SMBMessage fMsg
           
protected  NBTSession fNBTSession
           
protected static int fPID
           
protected  int fProtocol
           
protected  byte fSecurityMode
           
protected  java.lang.String fServerLanMan
           
protected  java.lang.String fServerOS
           
protected  java.lang.String fServerPrimaryDomain
           
protected  int fSessionKey
           
protected  java.lang.String fSessionName
           
protected  Share fShare
           
protected  long fSystemTime
           
protected  int fTID
           
protected  int fTimeZone
           
protected  int fUID
           
(package private) static int LANMAN_1_0
           
(package private) static int LM_1_2X002
           
(package private) static int NT_LM_0_12
           
(package private) static int SMB_CORE
           
(package private) static java.lang.String[] SUPPORTED_DIALECTS
           
 
Constructor Summary
(package private) SessionImpl(java.lang.String sessionname, int protocol, Share share, NBTSession nbt, SMBMessage msg)
          Constructor
 
Method Summary
(package private) static void addSession(java.lang.String sessionname, CifsSession session)
           
(package private) static SMBMessage allocateSMBMessage()
          Allocates SMB message buffer
protected  void checkConnection()
           
(package private)  void connect()
          session setup and tree connect
 void disconnect()
          Disconnect the connection
 java.lang.String echo(java.lang.String text)
          Ping the server to test the connection to the server and to see if the server is still responding
(package private) static java.util.Enumeration enumerateSessions()
          Enumerates sessions
 void finalize()
          Finalization: disconnect
 long getConnectTime()
          Returns the connect time in milliseconds (base: January 1, 1970 UTC )
 java.lang.String getNetBIOSName()
          Gets NetBIOS name
 java.lang.Object getProperty(java.lang.String key)
          Gets an API-user property
 java.net.InetAddress getServerAddress()
          Gets the address of the server
 java.lang.String getServerLanMan()
          Returns LAN Manager of the server
 java.lang.String getServerOS()
          Returns server OS name
 java.lang.String getServerPrimaryDomain()
          Returns the primary domain of the server
 long getServerTime()
          Returns the server time (from 1970 in msec)
 int getServerTimeZone()
          Time zone of server (min from UTC)
 java.lang.String getSessionName()
          Returns share name
(package private) static CifsSession[] getSessions()
           
 java.lang.String getShareName()
          Returns the name of this session
(package private) abstract  int getSortPosition()
           
(package private)  int howManyBytesCanWeSend()
          Returns the max number of bytes which can be sent
 boolean isConnected()
          Checks if the server is connected
 boolean isUserLevelSecurity()
          Returns true if the share has user level security
(package private) static CifsSession lookupSession(java.lang.String sessionname)
           
(package private) static int negotiate(NBTSession nbt, java.lang.String nbtname, SMBMessage msg)
          Negotiates protocol (we support only NT_LM_0_12).
(package private)  boolean promptLogin()
          Prompts for login dialog
protected  void receiveTransaction(MarshalBuffer param, MarshalBuffer data)
          Receives SMB_COM_TRANSACTION reply message
 void reconnect()
          Reconnects server if disconnected
(package private) static void removeSession(java.lang.String sessionname)
           
protected  void sendTransaction(short[] setup, java.lang.String name, MarshalBuffer param, byte[] data, int ldata)
          Sends SMB_COM_TRANSACTION message
protected  void sendTransaction2(short setup, MarshalBuffer param, byte[] data, int ldata, int fid)
          Sends SMB_COM_TRANSACTION2 message
 void setAllowAutoReconnection(boolean on)
          Sets automatic reconnection
 void setProperty(java.lang.String key, java.lang.Object value)
          Sets an API-user property.
protected  void setupSMBMessage(SMBMessage msg, byte cmd)
          Inititializes SMB message
protected  void setupSMBMessageSecondary(SMBMessage msg, byte cmd)
          Inititializes SMB message for SMB_COM_TRANSACTION_SECONDARY
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SMB_CORE

static final int SMB_CORE

LANMAN_1_0

static final int LANMAN_1_0

LM_1_2X002

static final int LM_1_2X002

NT_LM_0_12

static final int NT_LM_0_12

SUPPORTED_DIALECTS

static final java.lang.String[] SUPPORTED_DIALECTS

CAP_RAW_MODE

static final int CAP_RAW_MODE

CAP_MPX_MODE

static final int CAP_MPX_MODE

CAP_UNICODE

static final int CAP_UNICODE

CAP_LARGE_FILES

static final int CAP_LARGE_FILES

CAP_NT_SMBS

static final int CAP_NT_SMBS

CAP_RPC_REMOTE_APIS

static final int CAP_RPC_REMOTE_APIS

CAP_STATUS32

static final int CAP_STATUS32

CAP_LEVEL_II_OPLOCKS

static final int CAP_LEVEL_II_OPLOCKS

CAP_LOCK_AND_READ

static final int CAP_LOCK_AND_READ

CAP_NT_FIND

static final int CAP_NT_FIND

CAP_DFS

static final int CAP_DFS

CAP_BULK_TRANSFER

static final int CAP_BULK_TRANSFER

CAP_COMPRESSED_DATA

static final int CAP_COMPRESSED_DATA

CAP_EXTENDED_SECURITY

static final int CAP_EXTENDED_SECURITY

fShare

protected Share fShare

fNBTSession

protected NBTSession fNBTSession

fMsg

protected SMBMessage fMsg

fUID

protected int fUID

fTID

protected int fTID

fPID

protected static int fPID

fSecurityMode

protected byte fSecurityMode

fMaxPendingMPRequests

protected int fMaxPendingMPRequests

fMaxVCs

protected int fMaxVCs

fMaxBufferSize

protected int fMaxBufferSize

fMaxRawSize

protected int fMaxRawSize

fSessionKey

protected int fSessionKey

fCapabilities

protected int fCapabilities

fSystemTime

protected long fSystemTime

fTimeZone

protected int fTimeZone

fEncryptionKeyLen

protected int fEncryptionKeyLen

fExtendedSecurity

protected boolean fExtendedSecurity

fLoggedAsGuest

protected boolean fLoggedAsGuest

fServerOS

protected java.lang.String fServerOS

fServerLanMan

protected java.lang.String fServerLanMan

fServerPrimaryDomain

protected java.lang.String fServerPrimaryDomain

fCallerProperties

protected java.util.Hashtable fCallerProperties

fProtocol

protected int fProtocol

fSessionName

protected java.lang.String fSessionName
Constructor Detail

SessionImpl

SessionImpl(java.lang.String sessionname,
            int protocol,
            Share share,
            NBTSession nbt,
            SMBMessage msg)
      throws java.io.IOException
Constructor
Parameters:
share - share object
msg - message containing negotiated data
nbt - NetBios session
Method Detail

setAllowAutoReconnection

public void setAllowAutoReconnection(boolean on)
Sets automatic reconnection
Specified by:
setAllowAutoReconnection in interface CifsSession
Parameters:
on - true if automatic reconnection allowed

getShareName

public final java.lang.String getShareName()
Returns the name of this session
Specified by:
getShareName in interface CifsSession
Returns:
session name

getSessionName

public final java.lang.String getSessionName()
Returns share name
Specified by:
getSessionName in interface CifsSession

getServerOS

public final java.lang.String getServerOS()
Returns server OS name
Specified by:
getServerOS in interface CifsSession
Returns:
os name or blank if unknown

getServerLanMan

public final java.lang.String getServerLanMan()
Returns LAN Manager of the server
Specified by:
getServerLanMan in interface CifsSession
Returns:
LAN Manager or blank if unknown

getServerPrimaryDomain

public final java.lang.String getServerPrimaryDomain()
Returns the primary domain of the server
Specified by:
getServerPrimaryDomain in interface CifsSession
Returns:
primary domain or blank if unknown

getNetBIOSName

public final java.lang.String getNetBIOSName()
Gets NetBIOS name
Specified by:
getNetBIOSName in interface CifsSession
Returns:
NetBIOS name of the server

getServerAddress

public final java.net.InetAddress getServerAddress()
Gets the address of the server
Specified by:
getServerAddress in interface CifsSession
Returns:
InetAddress address

getServerTimeZone

public final int getServerTimeZone()
Time zone of server (min from UTC)
Specified by:
getServerTimeZone in interface CifsSession
Returns:
minutes

getServerTime

public final long getServerTime()
Returns the server time (from 1970 in msec)
Specified by:
getServerTime in interface CifsSession
Returns:
msec

isConnected

public boolean isConnected()
Checks if the server is connected
Specified by:
isConnected in interface CifsSession
Returns:
true if the connection is alive

setProperty

public final void setProperty(java.lang.String key,
                              java.lang.Object value)
Sets an API-user property. The value is not interpreted by CifsService
Specified by:
setProperty in interface CifsSession
Parameters:
key - property name
value - property value;
See Also:
getProperty(String)

getProperty

public final java.lang.Object getProperty(java.lang.String key)
Gets an API-user property
Specified by:
getProperty in interface CifsSession
Parameters:
key - property name
Returns:
property value;
See Also:
#setProperty(String)

isUserLevelSecurity

public final boolean isUserLevelSecurity()
Returns true if the share has user level security
Specified by:
isUserLevelSecurity in interface CifsSession
Returns:
true user level, false share level

getConnectTime

public final long getConnectTime()
Returns the connect time in milliseconds (base: January 1, 1970 UTC )
Specified by:
getConnectTime in interface CifsSession
Returns:
time in milliseconds

reconnect

public void reconnect()
               throws java.io.IOException
Reconnects server if disconnected
Specified by:
reconnect in interface CifsSession
Throws:
java.io.IOException - if an I/O error occurs

checkConnection

protected void checkConnection()
                        throws java.io.IOException

connect

void connect()
       throws java.io.IOException
session setup and tree connect
Throws:
java.io.IOException - if an I/O error occurs

disconnect

public void disconnect()
Disconnect the connection
Specified by:
disconnect in interface CifsSession

finalize

public void finalize()
Finalization: disconnect
Overrides:
finalize in class java.lang.Object

allocateSMBMessage

static SMBMessage allocateSMBMessage()
Allocates SMB message buffer
Returns:
SMBMessage SMB message

negotiate

static int negotiate(NBTSession nbt,
                     java.lang.String nbtname,
                     SMBMessage msg)
              throws java.io.IOException
Negotiates protocol (we support only NT_LM_0_12). Calls NetBIOS
Parameters:
nbt - NetBios session
nbtname - NetBIOS name
msg - SMB message
Returns:
negotiated protocol
Throws:
java.io.IOException - if an I/O error occurs

echo

public java.lang.String echo(java.lang.String text)
                      throws java.io.IOException
Ping the server to test the connection to the server and to see if the server is still responding
Specified by:
echo in interface CifsSession
Parameters:
text - text to send
Returns:
text returned by server (must be the same as the input text)
Throws:
java.io.IOException - if an I/O error occurs.

sendTransaction

protected void sendTransaction(short[] setup,
                               java.lang.String name,
                               MarshalBuffer param,
                               byte[] data,
                               int ldata)
                        throws java.io.IOException
Sends SMB_COM_TRANSACTION message
Parameters:
setup - setup words
name - name string
param - parameter buffer
data - data to send
ldata - length of data
Throws:
java.io.IOException - if an I/O error occurs

sendTransaction2

protected final void sendTransaction2(short setup,
                                      MarshalBuffer param,
                                      byte[] data,
                                      int ldata,
                                      int fid)
                               throws java.io.IOException
Sends SMB_COM_TRANSACTION2 message
Parameters:
setup - setup words
name - name string
param - parameter buffer
data - data to send
ldata - length of data
fid - file id
Throws:
java.io.IOException - if an I/O error occurs

receiveTransaction

protected final void receiveTransaction(MarshalBuffer param,
                                        MarshalBuffer data)
                                 throws java.io.IOException
Receives SMB_COM_TRANSACTION reply message
Parameters:
param - parameters
data - data buffer
Throws:
java.io.IOException - if an I/O error occurs

setupSMBMessage

protected final void setupSMBMessage(SMBMessage msg,
                                     byte cmd)
                              throws java.io.IOException
Inititializes SMB message
Parameters:
msg - SMB message
cmd - command

setupSMBMessageSecondary

protected final void setupSMBMessageSecondary(SMBMessage msg,
                                              byte cmd)
Inititializes SMB message for SMB_COM_TRANSACTION_SECONDARY
Parameters:
msg - SMB message
cmd - command

promptLogin

final boolean promptLogin()
Prompts for login dialog
Returns:
false if dialog cancelled

howManyBytesCanWeSend

final int howManyBytesCanWeSend()
Returns the max number of bytes which can be sent
Returns:
number of bytes

enumerateSessions

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

getSessions

static CifsSession[] getSessions()

lookupSession

static CifsSession lookupSession(java.lang.String sessionname)

addSession

static void addSession(java.lang.String sessionname,
                       CifsSession session)

removeSession

static void removeSession(java.lang.String sessionname)

getSortPosition

abstract int getSortPosition()