Package com.hierynomus.smbj.session
Class Session
java.lang.Object
com.hierynomus.smbj.session.Session
- All Implemented Interfaces:
AutoCloseable
A Session
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SMBEventBus
private final SmbConfig
private Connection
private PacketEncryptor
private static final org.slf4j.Logger
private ReentrantReadWriteLock
private final PathResolver
private SessionContext
private long
private PacketSignatory
private TreeConnectTable
private AuthenticationContext
-
Constructor Summary
ConstructorsConstructorDescriptionSession
(Connection connection, SmbConfig config, AuthenticationContext userCredentials, SMBEventBus bus, PathResolver pathResolver, PacketSignatory signatory, PacketEncryptor encryptor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
connectShare
(String shareName) Connect to a share on the remote machine over the authenticated session.private Share
connectTree
(String shareName) private Session
createNestedSession
(SmbPath smbPath) private void
disconnectTree
(TreeDisconnected disconnectEvent) getNestedSession
(SmbPath resolvedSharePath) long
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.boolean
boolean
isGuest()
boolean
void
logoff()
<T extends SMB2Packet>
TprocessSendResponse
(SMB2CreateRequest packet) <T extends SMB2Packet>
Future<T> send
(SMB2Packet packet) send a packet.void
setSessionId
(long sessionId) boolean
Returns whether packets for this session should be encrypted.
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
sessionId
private long sessionId -
connection
-
config
-
bus
-
pathResolver
-
signatory
-
encryptor
-
treeConnectTable
-
nestedSessionsByHost
-
nestedSessionsRwLock
-
userCredentials
-
sessionContext
-
-
Constructor Details
-
Session
public Session(Connection connection, SmbConfig config, AuthenticationContext userCredentials, SMBEventBus bus, PathResolver pathResolver, PacketSignatory signatory, PacketEncryptor encryptor)
-
-
Method Details
-
getSessionId
public long getSessionId() -
setSessionId
public void setSessionId(long sessionId) -
connectTree
-
getNestedSession
-
createNestedSession
-
disconnectTree
-
logoff
- Throws:
TransportException
-
isSigningRequired
public boolean isSigningRequired() -
isGuest
public boolean isGuest() -
isAnonymous
public boolean isAnonymous() -
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getConnection
-
send
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
-
processSendResponse
public <T extends SMB2Packet> T processSendResponse(SMB2CreateRequest packet) throws TransportException - Throws:
TransportException
-
getSigningKey
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
Returns whether packets for this session should be encrypted.- Returns:
- Throws:
TransportException
- When encryption is required and encryption key is missing.
-
getSessionContext
-
getAuthenticationContext
-