java.lang.Object
org.codelibs.jcifs.smb.internal.smb2.ServerMessageBlock2
org.codelibs.jcifs.smb.internal.smb2.ServerMessageBlock2Response
org.codelibs.jcifs.smb.internal.smb2.nego.Smb2NegotiateResponse
- All Implemented Interfaces:
CommonServerMessageBlock,CommonServerMessageBlockResponse,SmbNegotiationResponse,Message,Response
public class Smb2NegotiateResponse
extends ServerMessageBlock2Response
implements SmbNegotiationResponse
SMB2 Negotiate Protocol response message.
This response contains the server's protocol capabilities,
security mode, and negotiated dialect version.
- Author:
- mbechler
-
Field Summary
Fields inherited from class org.codelibs.jcifs.smb.internal.smb2.ServerMessageBlock2
SMB2_CANCEL, SMB2_CHANGE_NOTIFY, SMB2_CLOSE, SMB2_CREATE, SMB2_ECHO, SMB2_FLAGS_ASYNC_COMMAND, SMB2_FLAGS_DFS_OPERATIONS, SMB2_FLAGS_PRIORITY_MASK, SMB2_FLAGS_RELATED_OPERATIONS, SMB2_FLAGS_REPLAY_OPERATION, SMB2_FLAGS_SERVER_TO_REDIR, SMB2_FLAGS_SIGNED, SMB2_FLUSH, SMB2_IOCTL, SMB2_LOCK, SMB2_LOGOFF, SMB2_NEGOTIATE, SMB2_OPLOCK_BREAK, SMB2_QUERY_DIRECTORY, SMB2_QUERY_INFO, SMB2_READ, SMB2_SESSION_SETUP, SMB2_SET_INFO, SMB2_TREE_CONNECT, SMB2_TREE_DISCONNECT, SMB2_WRITE -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an SMB2 negotiate response with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanReuse(CIFSContext tc, boolean forceSigning) Checks whether a connection can be reused for the given configuration.protected static NegotiateContextResponsecreateContext(int type) Creates a negotiate context response based on the context type.final intGets the capabilities returned by the server.final intGets the common capabilities negotiated between client and server.intGets the SMB dialect revision selected by the server.intGets the number of initial credits granted by the server for SMB2.intGets the maximum transaction size supported by the server.Gets the negotiate contexts from the SMB 3.1.1 negotiation response.intGets the negotiated receive buffer size.byte[]Gets the initial security blob for authentication negotiation.intGets the security mode flags from the server.intGets the encryption cipher selected for SMB3 encryption.Gets the SMB dialect version selected by the server.intGets the pre-authentication integrity hash algorithm selected for SMB 3.1.1.intGets the negotiated send buffer size.byte[]Gets the server GUID used for identification.longGets the server start time timestamp.intGets the negotiated maximum transaction buffer size.booleanhaveCapabilitiy(int cap) Checks whether a specific capability has been negotiated.booleanChecks whether the server supports Distributed File System (DFS).booleanChecks whether SMB3 encryption is supported by the server.booleanChecks whether the server has SMB message signing enabled.booleanChecks whether SMB message signing has been successfully negotiated.booleanChecks whether the server requires SMB message signing.booleanisValid(CIFSContext tc, SmbNegotiationRequest req) Check if the negotiation response is validprotected intreadBytesWireFormat(byte[] buffer, int bufferIndex) Reads the message body from the wire format.voidsetupRequest(CommonServerMessageBlock request) Sets up the given request with negotiated parameters.voidsetupResponse(Response resp) Sets up the given response with negotiated parameters.toString()protected intwriteBytesWireFormat(byte[] dst, int dstIndex) Writes the message body to the wire format.Methods inherited from class org.codelibs.jcifs.smb.internal.smb2.ServerMessageBlock2Response
clearReceived, error, exception, getErrorCode, getException, getExpiration, getGrantedCredits, getNextResponse, haveResponse, isAsyncHandled, isError, isReceived, isSigned, isVerifyFailed, prepare, received, reset, setAsyncHandled, setExpiration, verifySignatureMethods inherited from class org.codelibs.jcifs.smb.internal.smb2.ServerMessageBlock2
addFlags, chain, clearFlags, decode, decode, encode, equals, getAsyncId, getCommand, getConfig, getCredit, getCreditCharge, getDigest, getErrorContextCount, getErrorData, getFlags, getHeaderStart, getLength, getMid, getNext, getNextCommandOffset, getRawPayload, getResponse, getSessionId, getStatus, getTreeId, hashCode, isAsync, isErrorResponseStatus, isRetainPayload, pad8, readErrorResponse, readHeaderWireFormat, retainPayload, setAsyncId, setCommand, setCredit, setDigest, setExtendedSecurity, setMid, setNext, setRawPayload, setReadSize, setResponse, setSessionId, setTreeId, setUid, size8, size8, writeHeaderWireFormatMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.codelibs.jcifs.smb.internal.CommonServerMessageBlock
decode, encode, getCommand, getDigest, getMid, getResponse, reset, setCommand, setDigest, setExtendedSecurity, setMid, setResponse, setSessionId, setUidMethods inherited from interface org.codelibs.jcifs.smb.internal.CommonServerMessageBlockResponse
isAsyncMethods inherited from interface org.codelibs.jcifs.smb.util.transport.Message
getRawPayload, isRetainPayload, retainPayload, setRawPayloadMethods inherited from interface org.codelibs.jcifs.smb.util.transport.Response
clearReceived, error, exception, getErrorCode, getException, getExpiration, getGrantedCredits, getMid, isError, isReceived, isVerifyFailed, received, reset, setExpiration, setMid, verifySignature
-
Constructor Details
-
Smb2NegotiateResponse
Constructs an SMB2 negotiate response with the given configuration.- Parameters:
cfg- the configuration for this response
-
-
Method Details
-
getInitialCredits
public int getInitialCredits()Gets the number of initial credits granted by the server for SMB2.- Specified by:
getInitialCreditsin interfaceSmbNegotiationResponse- Returns:
- number of initial credits the server grants
- See Also:
-
getDialectRevision
public int getDialectRevision()Gets the SMB dialect revision selected by the server.- Returns:
- the dialectRevision
-
getServerGuid
public byte[] getServerGuid()Gets the server GUID used for identification.- Returns:
- the serverGuid
-
getSelectedDialect
Description copied from interface:SmbNegotiationResponseGets the SMB dialect version selected by the server.- Specified by:
getSelectedDialectin interfaceSmbNegotiationResponse- Returns:
- the selectedDialect
-
getSelectedCipher
public int getSelectedCipher()Gets the encryption cipher selected for SMB3 encryption.- Returns:
- the selectedCipher
-
getSelectedPreauthHash
public int getSelectedPreauthHash()Gets the pre-authentication integrity hash algorithm selected for SMB 3.1.1.- Returns:
- the selectedPreauthHash
-
getCapabilities
public final int getCapabilities()Gets the capabilities returned by the server.- Returns:
- the server returned capabilities
-
getCommonCapabilities
public final int getCommonCapabilities()Gets the common capabilities negotiated between client and server.- Returns:
- the common/negotiated capabilities
-
getSecurityBlob
public byte[] getSecurityBlob()Gets the initial security blob for authentication negotiation.- Returns:
- initial security blob
-
getMaxTransactSize
public int getMaxTransactSize()Gets the maximum transaction size supported by the server.- Returns:
- the maxTransactSize
-
getTransactionBufferSize
public int getTransactionBufferSize()Gets the negotiated maximum transaction buffer size.- Specified by:
getTransactionBufferSizein interfaceSmbNegotiationResponse- Returns:
- the transaction buffer size
- See Also:
-
getNegotiateContexts
Gets the negotiate contexts from the SMB 3.1.1 negotiation response.- Returns:
- the negotiateContexts
-
getServerStartTime
public long getServerStartTime()Gets the server start time timestamp.- Returns:
- the serverStartTime
-
getSecurityMode
public int getSecurityMode()Gets the security mode flags from the server.- Returns:
- the securityMode
-
haveCapabilitiy
public boolean haveCapabilitiy(int cap) Checks whether a specific capability has been negotiated.- Specified by:
haveCapabilitiyin interfaceSmbNegotiationResponse- Parameters:
cap- the capability flag to check- Returns:
- whether capability is negotiated
- See Also:
-
isDFSSupported
public boolean isDFSSupported()Checks whether the server supports Distributed File System (DFS).- Specified by:
isDFSSupportedin interfaceSmbNegotiationResponse- Returns:
- whether the server supports DFS
- See Also:
-
isEncryptionSupported
public boolean isEncryptionSupported()Checks whether SMB3 encryption is supported by the server.- Returns:
- whether SMB encryption is supported by the server
-
canReuse
Checks whether a connection can be reused for the given configuration.- Specified by:
canReusein interfaceSmbNegotiationResponse- Parameters:
tc- the CIFS context to check compatibility withforceSigning- whether signing is being forced- Returns:
- whether a connection can be reused for this config
- See Also:
-
isValid
Description copied from interface:SmbNegotiationResponseCheck if the negotiation response is valid- Specified by:
isValidin interfaceSmbNegotiationResponse- Parameters:
tc- the CIFS contextreq- the negotiation request- Returns:
- whether the protocol negotiation was successful
-
getReceiveBufferSize
public int getReceiveBufferSize()Gets the negotiated receive buffer size.- Specified by:
getReceiveBufferSizein interfaceSmbNegotiationResponse- Returns:
- the receive buffer size
- See Also:
-
getSendBufferSize
public int getSendBufferSize()Gets the negotiated send buffer size.- Specified by:
getSendBufferSizein interfaceSmbNegotiationResponse- Returns:
- the send buffer size
- See Also:
-
isSigningEnabled
public boolean isSigningEnabled()Checks whether the server has SMB message signing enabled.- Specified by:
isSigningEnabledin interfaceSmbNegotiationResponse- Returns:
- whether the server has signing enabled
- See Also:
-
isSigningRequired
public boolean isSigningRequired()Checks whether the server requires SMB message signing.- Specified by:
isSigningRequiredin interfaceSmbNegotiationResponse- Returns:
- whether the server requires signing
- See Also:
-
isSigningNegotiated
public boolean isSigningNegotiated()Checks whether SMB message signing has been successfully negotiated.- Specified by:
isSigningNegotiatedin interfaceSmbNegotiationResponse- Returns:
- whether signing has been negotiated
- See Also:
-
setupRequest
Sets up the given request with negotiated parameters.- Specified by:
setupRequestin interfaceSmbNegotiationResponse- Parameters:
request- the request to configure- See Also:
-
setupResponse
Sets up the given response with negotiated parameters.- Specified by:
setupResponsein interfaceSmbNegotiationResponse- Parameters:
resp- the response to configure- See Also:
-
readBytesWireFormat
protected int readBytesWireFormat(byte[] buffer, int bufferIndex) throws SMBProtocolDecodingException Description copied from class:ServerMessageBlock2Reads the message body from the wire format.- Specified by:
readBytesWireFormatin classServerMessageBlock2- Parameters:
buffer- the buffer to read frombufferIndex- the starting position in the buffer- Returns:
- number of bytes read
- Throws:
SMBProtocolDecodingException- if decoding fails
-
createContext
Creates a negotiate context response based on the context type.- Parameters:
type- the negotiate context type- Returns:
- the appropriate negotiate context response, or null if not recognized
-
writeBytesWireFormat
protected int writeBytesWireFormat(byte[] dst, int dstIndex) Writes the message body to the wire format.- Specified by:
writeBytesWireFormatin classServerMessageBlock2- Parameters:
dst- the destination bufferdstIndex- the starting position in the buffer- Returns:
- number of bytes written
- See Also:
-
toString
- Overrides:
toStringin classServerMessageBlock2
-