Package com.hierynomus.smbj.connection
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 class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SMBEventBus
private final SMBClient
private SmbConfig
private ConnectionContext
private static final Connection.DelegatingSMBMessageConverter
private PacketEncryptor
private final ReentrantLock
private static final org.slf4j.Logger
private SMB2MessageConverter
(package private) OutstandingRequests
private IncomingPacketHandler
private PathResolver
private SessionTable
(package private) SequenceWindow
(package private) final ServerList
private SessionTable
private PacketSignatory
(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 int
calculateGrantedCredits
(SMB2Packet packet, int availableCredits) void
close()
void
close
(boolean force) Close the Connection.void
private int
creditsNeeded
(int payloadSize) [MS-SMB2] 3.1.5.2 Calculating the CreditChargeReturns the negotiated protocol details for this connection.(package private) SessionTable
(package private) SessionTable
void
handle
(SMBPacketData<?> uncheckedPacket) void
private void
init()
boolean
<T extends SMB2Packet>
Future<T> send
(SMB2Packet packet) send a packet.(package private) <T extends SMB2Packet>
TsendAndReceive
(SMB2Packet packet) private void
sessionLogoff
(SessionLoggedOff loggedOff) void
setMessageConverter
(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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
close
Close the Connection. Ifforce
is set to true, it forgoes theSession.close()
operation on the open sessions, and it just calls theTransportLayer.disconnect()
.If
force
is 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:
handle
in interfacePacketReceiver<SMBPacketData<?>>
- Throws:
TransportException
-
handleError
- Specified by:
handleError
in interfacePacketReceiver<SMBPacketData<?>>
-
getRemoteHostname
-
isConnected
public boolean isConnected() -
getConnectionContext
-
sessionLogoff
-
getSessionTable
SessionTable getSessionTable() -
getPreauthSessionTable
SessionTable getPreauthSessionTable() -
setMessageConverter
-