Class Session

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Session
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A Session
    • Method Detail

      • getSessionId

        public long getSessionId()
      • setSessionId

        public void setSessionId​(long sessionId)
      • connectShare

        public Share connectShare​(java.lang.String shareName)
        Connect to a share on the remote machine over the authenticated session.

        [MS-SMB2] 3.2.4.2 Application Requests a Connection to a Share [MS-SMB2] 3.2.4.2.4 Connecting to the Share [MS-SMB2] 3.2.5.5 Receiving an SMB2 TREE_CONNECT Response

        Parameters:
        shareName - The name of the share to connect to.
        Returns:
        the handle to the connected share.
      • getNestedSession

        public Session getNestedSession​(SmbPath resolvedSharePath)
      • isSigningRequired

        public boolean isSigningRequired()
      • isGuest

        public boolean isGuest()
      • isAnonymous

        public boolean isAnonymous()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException
      • getConnection

        public Connection getConnection()
      • send

        public <T extends SMB2Packet> java.util.concurrent.Future<T> send​(SMB2Packet packet)
                                                                   throws TransportException
        send a packet. The packet will be signed or not depending on the session's flags.
        Parameters:
        packet - SMBPacket to send
        Returns:
        a Future to be used to retrieve the response packet
        Throws:
        TransportException
      • getSigningKey

        public javax.crypto.SecretKey getSigningKey​(SMB2PacketHeader header,
                                                    boolean signing)
        If Connection.Dialect belongs to the SMB 3.x dialect family, and the received message is an SMB2 SESSION_SETUP Response without a status code equal to STATUS_SUCCESS in the header, the client MUST verify the signature of the message as specified in section 3.1.5.1, using Session.SigningKey as the signing key, and passing the response message. For all other messages, the client MUST look up the Channel in Session.ChannelList, where the Channel.Connection matches the connection on which this message is received, and MUST use Channel.SigningKey for verifying the signature as specified in section 3.1.5.1.  Otherwise, the client MUST verify the signature of the message as specified in section 3.1.5.1, using Session.SessionKey as the signing key, and passing the response message.
        Parameters:
        signing - If true, check for signing mode, else get for verification mode
        Returns:
      • shouldEncryptData

        public boolean shouldEncryptData()
                                  throws TransportException
        Returns whether packets for this session should be encrypted.
        Returns:
        Throws:
        TransportException - When encryption is required and encryption key is missing.