Class Connection
- All Implemented Interfaces:
PacketReceiver<SMBPacketData<?>>, Closeable, AutoCloseable
public class Connection
extends Pooled<Connection>
implements Closeable, PacketReceiver<SMBPacketData<?>>
A connection to a server.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SMBEventBusprivate final SMBClientprivate SmbConfigprivate ConnectionContextprivate static final Connection.DelegatingSMBMessageConverterprivate PacketEncryptorprivate final ReentrantLockprivate static final org.slf4j.Loggerprivate SMB2MessageConverter(package private) OutstandingRequestsprivate IncomingPacketHandlerprivate PathResolverprivate SessionTable(package private) SequenceWindow(package private) final ServerListprivate SessionTableprivate Signatory(package private) TransportLayer<SMBPacket<?, ?>> -
Constructor Summary
ConstructorsConstructorDescriptionConnection(Connection connection) Connection(SmbConfig config, SMBClient client, SMBEventBus bus, ServerList serverList) -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(AuthenticationContext authContext) Authenticate the user on this connection in order to start a (new) session.private intcalculateGrantedCredits(SMB2Packet packet, int availableCredits) voidclose()voidclose(boolean force) Close the Connection.voidprivate intcreditsNeeded(int payloadSize) [MS-SMB2] 3.1.5.2 Calculating the CreditChargeReturns the negotiated protocol details for this connection.(package private) SessionTable(package private) SessionTablevoidhandle(SMBPacketData<?> uncheckedPacket) voidprivate voidinit()boolean<T extends SMB2Packet>
Future<T> send(SMB2Packet packet) send a packet.(package private) <T extends SMB2Packet>
TsendAndReceive(SMB2Packet packet) private voidsessionLogoff(SessionLoggedOff loggedOff) voidsetMessageConverter(SMB2MessageConverter smb2Converter)
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
converter
-
packetHandlerChain
-
connectionContext
-
sessionTable
-
preauthSessionTable
-
outstandingRequests
OutstandingRequests outstandingRequests -
sequenceWindow
SequenceWindow sequenceWindow -
messageConverter
-
pathResolver
-
client
-
serverList
-
signatory
-
encryptor
-
config
-
transport
TransportLayer<SMBPacket<?,?>> transport -
bus
-
lock
-
-
Constructor Details
-
Connection
-
Connection
-
-
Method Details
-
getClient
-
init
private void init() -
connect
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
close
Close the Connection. Ifforceis set to true, it forgoes theSession.close()operation on the open sessions, and it just calls theTransportLayer.disconnect().If
forceis set to false, the usage counter of the connection reduces with one. If the usage count drops to zero the connection will be closed.- Parameters:
force- if set, does not nicely terminate the open sessions.- Throws:
IOException- If any error occurred during close-ing.
-
authenticate
Authenticate the user on this connection in order to start a (new) session.- Returns:
- a (new) Session that is authenticated for the user.
-
send
send a packet.- Parameters:
packet- SMBPacket to send- Returns:
- a Future to be used to retrieve the response packet
- Throws:
TransportException- When a transport level error occurred
-
sendAndReceive
- Throws:
TransportException
-
calculateGrantedCredits
-
creditsNeeded
private int creditsNeeded(int payloadSize) [MS-SMB2] 3.1.5.2 Calculating the CreditCharge -
getNegotiatedProtocol
Returns the negotiated protocol details for this connection.- Returns:
- The negotiated protocol details
-
handle
- Specified by:
handlein interfacePacketReceiver<SMBPacketData<?>>- Throws:
TransportException
-
handleError
- Specified by:
handleErrorin interfacePacketReceiver<SMBPacketData<?>>
-
getRemoteHostname
-
isConnected
public boolean isConnected() -
getConnectionContext
-
sessionLogoff
-
getSessionTable
SessionTable getSessionTable() -
getPreauthSessionTable
SessionTable getPreauthSessionTable() -
setMessageConverter
-